summaryrefslogtreecommitdiff
path: root/test/ruby/test_autoload.rb
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-05-15 14:27:06 +0900
committerKoichi Sasada <ko1@atdot.net>2020-05-15 14:54:03 +0900
commite89b87508160868bd431218872d0d5b7b15bc57b (patch)
tree618ea26edcbbac7040ecad962ee10f094c266d3e /test/ruby/test_autoload.rb
parent6fa8455ebbf457e5d8752295a8d6380146636c0c (diff)
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'
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3111
Diffstat (limited to 'test/ruby/test_autoload.rb')
-rw-r--r--test/ruby/test_autoload.rb15
1 files 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