Skip to content

Commit

Permalink
CI: test/runner - add -w and z options for test file warnings (#3562
Browse files Browse the repository at this point in the history
)
  • Loading branch information
MSP-Greg authored Nov 23, 2024
1 parent 0e22c0a commit 76bff68
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/runner
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ The file extension is optional.
If arguments are used that take values (eg seed), use the 'no space' version,
like -s33388 or --seed=33388
'-w' is an additional option, it will switch $VERBOSE to true before the
test files are loaded.
'-z' is an additional option, it will switch $VERBOSE to true and cancel the tests.
Finally, to keep the code simple, if you pass an invalid argument for file
filtering it will either error or run minitest with no tests loaded
Expand All @@ -27,6 +32,26 @@ test/runner -v 'test_integration_*.rb'
=end

require 'bundler/setup'
require 'stringio'

if ARGV.delete '-z'
show_warnings = true
no_tests = true
elsif ARGV.delete '-w'
show_warnings = true
elsif ARGV.delete('-wv') || ARGV.delete('-vw')
show_warnings = true
ARGV.unshift '-v'
else
show_warnings = nil
end

if show_warnings
stderr, $stderr = STDERR, StringIO.new
$VERBOSE = true
end

STDOUT.syswrite "\n#{ARGV.join "\n"}\n\n"

if ARGV.empty? || ARGV.last.start_with?('-')
if RUBY_VERSION >= '2.5'
Expand All @@ -50,4 +75,18 @@ else
end
end

if show_warnings
warnings = $stderr.string&.strip
$stderr = stderr
if warnings && !warnings.empty?
warnings = warnings.gsub("#{__dir__}/", '')
.split("\n")
.sort
.join("\n")
STDERR.syswrite "#{warnings}\n\n"
end
end
exit 1 if no_tests

require 'minitest'
STDOUT.syswrite "Minitest version: #{Minitest::VERSION}\n\n"

0 comments on commit 76bff68

Please sign in to comment.