2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2012-04-17 00:11:17 -04:00
|
|
|
require 'test/unit'
|
2014-04-05 19:52:52 -04:00
|
|
|
require 'tmpdir'
|
|
|
|
require 'rbconfig'
|
2012-04-17 00:11:17 -04:00
|
|
|
|
|
|
|
module Bug
|
|
|
|
module Win32
|
|
|
|
class TestDln < Test::Unit::TestCase
|
|
|
|
def test_check_imported
|
|
|
|
bug = '[Bug #6303]'
|
2016-09-25 18:29:16 -04:00
|
|
|
so = ::File.expand_path("../ext/-test-/win32/dln/dlntest.dll", ::EnvUtil.rubybin)
|
|
|
|
assert_send([::File, :file?, so])
|
|
|
|
path = ::ENV['PATH']
|
2017-09-28 09:55:48 -04:00
|
|
|
path = ::File.dirname(so) + ::File::PATH_SEPARATOR + path
|
2016-09-22 02:35:27 -04:00
|
|
|
assert_in_out_err([{'PATH'=>path}, '-r-test-/win32/dln', '-eexit'], '', [], [], bug, timeout: 10)
|
2012-04-17 00:11:17 -04:00
|
|
|
end
|
2014-04-05 19:52:52 -04:00
|
|
|
|
|
|
|
def test_nonascii_load
|
|
|
|
bug9699 = '[ruby-core:61845] [Bug #9699]'
|
2016-09-25 18:29:16 -04:00
|
|
|
so = "-test-/dln/empty." + ::RbConfig::CONFIG["DLEXT"]
|
2014-04-10 03:39:44 -04:00
|
|
|
so = $:.find {|d| d = ::File.join(d, so); break d if ::File.exist?(d)}
|
2014-04-05 19:52:52 -04:00
|
|
|
assert_not_nil(so)
|
2016-09-25 18:29:16 -04:00
|
|
|
::Dir.mkdir(dir = ::File.join(testdir = ::Dir.mktmpdir("test"), "\u{30c6 30b9 30c8}"))
|
2014-04-10 03:39:44 -04:00
|
|
|
::File.copy_stream(so, ::File.join(dir, ::File.basename(so)))
|
|
|
|
assert_separately(['-', bug9699, testdir, ::File.basename(so)], <<-'end;')
|
2014-04-05 19:52:52 -04:00
|
|
|
bug, dir, so = *ARGV
|
|
|
|
assert_nothing_raised(LoadError, bug) do
|
2014-04-10 03:39:44 -04:00
|
|
|
require ::File.join(dir, "\u{30c6 30b9 30c8}", so)
|
2014-04-05 19:52:52 -04:00
|
|
|
end
|
|
|
|
end;
|
|
|
|
ensure
|
2014-04-10 03:39:44 -04:00
|
|
|
::File.unlink(::File.join(dir, ::File.basename(so))) rescue nil
|
2016-09-25 18:29:16 -04:00
|
|
|
::Dir.rmdir(dir) rescue nil
|
|
|
|
::Dir.rmdir(testdir) rescue nil
|
2014-04-05 19:52:52 -04:00
|
|
|
end
|
|
|
|
|
2012-04-17 00:11:17 -04:00
|
|
|
end
|
|
|
|
end
|
2012-04-17 07:14:24 -04:00
|
|
|
end if /mswin|mingw/ =~ RUBY_PLATFORM
|