1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

fix for multi-run test.

TestAutoload#test_source_location can't run multiple test-run so
that use assert_separately().

repro command:
make yes-test-all TESTS='--repeat-count=50 ruby/test_autoload -n test_source_location'
This commit is contained in:
Koichi Sasada 2020-05-15 14:27:06 +09:00
parent 6fa8455ebb
commit e89b875081
Notes: git 2020-05-15 14:54:26 +09:00

View file

@ -428,15 +428,18 @@ p Foo::Bar
end
def test_source_location
klass = self.class
bug = "Bug16764"
Dir.mktmpdir('autoload') do |tmpdir|
path = "#{tmpdir}/test-#{bug}.rb"
File.write(path, "#{klass}::#{bug} = __FILE__\n")
klass.autoload(:Bug16764, path)
assert_equal [__FILE__, __LINE__-1], klass.const_source_location(bug)
assert_equal path, klass.const_get(bug)
assert_equal [path, 1], klass.const_source_location(bug)
File.write(path, "C::#{bug} = __FILE__\n")
assert_separately(%W[-I #{tmpdir}], "#{<<-"begin;"}\n#{<<-"end;"}")
begin;
class C; end
C.autoload(:Bug16764, #{path.dump})
assert_equal [__FILE__, __LINE__-1], C.const_source_location(#{bug.dump})
assert_equal #{path.dump}, C.const_get(#{bug.dump})
assert_equal [#{path.dump}, 1], C.const_source_location(#{bug.dump})
end;
end
end