summaryrefslogtreecommitdiff
path: root/bootstraptest/test_load.rb
blob: 3253582a3249953b8a998cab5ebf4ea2f8e5098c (plain)
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
assert_equal 'ok', %q{
  open("require-lock-test.rb", "w") {|f|
    f.puts "sleep 0.1"
    f.puts "module M"
    f.puts "end"
  }
  $:.unshift Dir.pwd
  vs = (1..2).map {|i|
    Thread.start {
      require "require-lock-test"
      M
    }
  }.map {|t| t.value }
  vs[0] == M && vs[1] == M ? :ok : :ng
}, '[ruby-dev:32048]' unless ENV.fetch('RUN_OPTS', '').include?('rjit') # Thread seems to be switching during JIT. To be fixed later.

assert_equal 'ok', %q{
  %w[a a/foo b].each {|d| Dir.mkdir(d)}
  open("b/foo", "w") {|f| f.puts "$ok = :ok"}
  $:.replace(%w[a b])
  begin
    load "foo"
    $ok
  rescue => e
    e.message
  end
}, '[ruby-dev:38097]'