Skip to content

Commit

Permalink
Fix deprecation test when ran multiple times
Browse files Browse the repository at this point in the history
The deprecation warning is only printed on the first time the test is
ran, so subsequent runs will fail because the error message will not be
printed. This can be seen in the Ruby CI logs such as
http://ci.rvm.jp/results/trunk-repeat50@ruby-sp2-docker/4696313:

    1) Failure:
    TestIRB::RubyLexTest#test_initialising_the_old_top_level_ruby_lex [/tmp/ruby/src/trunk-repeat50/test/irb/test_ruby_lex.rb:210]:
    Expected /warning: constant ::RubyLex is deprecated/ to match "".

It can also be reproduced in the Ruby repo with the following test
command:

    make test/irb/test_ruby_lex.rb TESTOPTS=--repeat-count=2

This commit changes the test to use assert_in_out_err, which spawns a
new Ruby process.
  • Loading branch information
peterzhu2118 committed Aug 26, 2023
1 parent 069b562 commit 8b70841
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions test/irb/test_ruby_lex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,10 @@ def test_assignment_expression_with_local_variable
end

def test_initialising_the_old_top_level_ruby_lex
_, err = capture_output do
assert_in_out_err(["--disable-gems", "-W:deprecated"], <<~RUBY, [], /warning: constant ::RubyLex is deprecated/)
require "irb"
::RubyLex.new(nil)
end

assert_match(/warning: constant ::RubyLex is deprecated/, err)
RUBY
end

private
Expand Down

0 comments on commit 8b70841

Please sign in to comment.