File: test_dln.rb

package info (click to toggle)
ruby3.3 3.3.8-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 153,620 kB
  • sloc: ruby: 1,244,308; ansic: 836,474; yacc: 28,074; pascal: 6,748; sh: 3,913; python: 1,719; cpp: 1,158; makefile: 742; asm: 712; javascript: 394; lisp: 97; perl: 62; awk: 36; sed: 23; xml: 4
file content (39 lines) | stat: -rw-r--r-- 1,449 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: false
require 'test/unit'
require 'tmpdir'
require 'rbconfig'

module Bug
  module Win32
    class TestDln < Test::Unit::TestCase
      def test_check_imported
        bug = '[Bug #6303]'
        so = ::File.expand_path("../ext/-test-/win32/dln/dlntest.dll", ::EnvUtil.rubybin)
        assert_send([::File, :file?, so])
        path = ::ENV['PATH']
        path = ::File.dirname(so) + ::File::PATH_SEPARATOR + path
        assert_in_out_err([{'PATH'=>path}, '-r-test-/win32/dln', '-eexit'], '', [], [], bug, timeout: 10)
      end

      def test_nonascii_load
        bug9699 = '[ruby-core:61845] [Bug #9699]'
        so = "-test-/dln/empty." + ::RbConfig::CONFIG["DLEXT"]
        so = $:.find {|d| d = ::File.join(d, so); break d if ::File.exist?(d)}
        assert_not_nil(so)
        ::Dir.mkdir(dir = ::File.join(testdir = ::Dir.mktmpdir("test"), "\u{30c6 30b9 30c8}"))
        ::File.copy_stream(so, ::File.join(dir, ::File.basename(so)))
        assert_separately(['-', bug9699, testdir, ::File.basename(so)], <<-'end;')
          bug, dir, so = *ARGV
          assert_nothing_raised(LoadError, bug) do
            require ::File.join(dir, "\u{30c6 30b9 30c8}", so)
          end
        end;
      ensure
        ::File.unlink(::File.join(dir, ::File.basename(so))) rescue nil
        ::Dir.rmdir(dir) rescue nil
        ::Dir.rmdir(testdir) rescue nil
      end

    end
  end
end if /mswin|mingw/ =~ RUBY_PLATFORM