Skip to content

Commit

Permalink
Strip extra TruffleRuby stacktrace lines from test output
Browse files Browse the repository at this point in the history
This is a workaround to avoid a failure like this:

Integration::MinitestRedisTest
  test_test_data_reporter                                         PASS (20.90s)
  test_junit_reporter                                             FAIL (17.45s)
        --- expected
        +++ actual
        @@ -47,6 +47,9 @@
         Failure:
         test_bar(BTest) [test/dummy_test.rb]:
         TypeError: String can't be coerced into Integer
        +    <internal:core> core/numeric.rb:200:in `math_coerce_error'
        +    <internal:core> core/numeric.rb:182:in `math_coerce'
        +    <internal:core> core/numeric.rb:221:in `redo_coerced'
             test/dummy_test.rb:37:in `+'
             test/dummy_test.rb:37:in `test_bar'
         ]]>
        /Users/rwstauner/src/github.com/Shopify/ci-queue/ruby/test/integration/minitest_redis_test.rb:499:in `test_junit_reporter'
  • Loading branch information
rwstauner committed Apr 11, 2023
1 parent 10d895f commit 6af3fbb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ruby/test/integration/minitest_redis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,12 @@ def test_utf8_tests_and_marshal
private

def normalize_xml(output)
freeze_xml_timing(rewrite_paths(output))
strip_extra_stack_traces(freeze_xml_timing(rewrite_paths(output)))
end

def strip_extra_stack_traces(output)
# TruffleRuby has extra <internal:core> lines before the expected ruby stacktrace.
output.gsub(%r{^(TypeError: String can't be coerced into Integer)(?:\n\s+<internal:core> core/numeric\.rb:\d+:in `\w+')*(\n\s+test/dummy_test\.rb)}, '\1\2')
end
end
end

0 comments on commit 6af3fbb

Please sign in to comment.