From e89b87508160868bd431218872d0d5b7b15bc57b Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 15 May 2020 14:27:06 +0900 Subject: [PATCH] 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' --- test/ruby/test_autoload.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index 2e2e79dffd..98d513da87 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -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