DEV: add `--seed` to turbo_rspec, tweak CI output (#21598)

This commit is contained in:
Jarek Radosz 2023-05-17 11:22:31 +02:00 committed by GitHub
parent df2614c0fb
commit bf8939f7ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 14 deletions

View File

@ -10,6 +10,7 @@ requires = []
formatters = []
verbose = false
fail_fast = nil
seed = rand(2**16)
OptionParser
.new do |opts|
@ -35,6 +36,8 @@ OptionParser
end
fail_fast = (n.nil? || n < 1) ? 1 : n
end
opts.on("--seed SEED", "The seed for the random order") { |s| seed = s.to_i }
end
.parse!(ARGV)
@ -52,7 +55,10 @@ else
use_runtime_info = false
end
puts "Running turbo_rspec using files in #{files}"
puts "::group::Run turbo_rspec" if ENV["GITHUB_ACTIONS"]
puts "Running turbo_rspec (seed: #{seed}) using files in: #{files}"
puts "::endgroup::" if ENV["GITHUB_ACTIONS"]
success =
TurboTests::Runner.run(
formatters: formatters,
@ -60,6 +66,7 @@ success =
verbose: verbose,
fail_fast: fail_fast,
use_runtime_info: use_runtime_info,
seed: seed.to_s,
)
if success

View File

@ -43,7 +43,7 @@ module TurboTests
def wrap
@examples += 1
if @examples == LINE_LENGTH
if ENV["GITHUB_ACTIONS"] && @examples == LINE_LENGTH
output.print "\n"
@examples = 0
end

View File

@ -5,12 +5,13 @@ module TurboTests
def self.run(opts = {})
files = opts[:files]
formatters = opts[:formatters]
seed = opts[:seed]
start_time = opts.fetch(:start_time) { Time.now }
verbose = opts.fetch(:verbose, false)
fail_fast = opts.fetch(:fail_fast, nil)
use_runtime_info = opts.fetch(:use_runtime_info, false)
STDERR.puts "VERBOSE" if verbose
STDOUT.puts "VERBOSE" if verbose
reporter = Reporter.from_config(formatters, start_time)
@ -29,6 +30,7 @@ module TurboTests
verbose: verbose,
fail_fast: fail_fast,
use_runtime_info: use_runtime_info,
seed: seed,
).run
end
@ -46,6 +48,7 @@ module TurboTests
@verbose = opts[:verbose]
@fail_fast = opts[:fail_fast]
@use_runtime_info = opts[:use_runtime_info]
@seed = opts[:seed]
@failure_count = 0
@messages = Queue.new
@ -59,12 +62,7 @@ module TurboTests
@num_processes = ParallelTests.determine_number_of_processes(nil)
group_opts = {}
if @use_runtime_info
group_opts[:runtime_log] = "tmp/turbo_rspec_runtime.log"
else
group_opts[:group_by] = :filesize
end
group_opts[:runtime_log] = "tmp/turbo_rspec_runtime.log" if @use_runtime_info
tests_in_groups =
ParallelTests::RSpec::Runner.tests_in_groups(@files, @num_processes, **group_opts)
@ -160,8 +158,8 @@ module TurboTests
"exec",
"rspec",
*extra_args,
"--seed",
rand(2**16).to_s,
"--order",
"random:#{@seed}",
"--format",
"TurboTests::JsonRowsFormatter",
"--out",
@ -175,9 +173,9 @@ module TurboTests
[env.map { |k, v| "#{k}=#{v}" }.join(" "), command.join(" ")].select { |x| x.size > 0 }
.join(" ")
STDERR.puts "::group::[#{process_id}] Run RSpec" if ENV["CI"]
STDERR.puts "Process #{process_id}: #{command_str}"
STDERR.puts "::endgroup::" if ENV["CI"]
STDOUT.puts "::group::[#{process_id}] Run RSpec" if ENV["GITHUB_ACTIONS"]
STDOUT.puts "Process #{process_id}: #{command_str}"
STDOUT.puts "::endgroup::" if ENV["GITHUB_ACTIONS"]
end
stdin, stdout, stderr, wait_thr = Open3.popen3(env, *command)