diff --git a/lib/turbo_tests/cli.rb b/lib/turbo_tests/cli.rb index ed80ba7..09a8c23 100644 --- a/lib/turbo_tests/cli.rb +++ b/lib/turbo_tests/cli.rb @@ -17,6 +17,7 @@ def run verbose = false fail_fast = nil seed = nil + nice = false OptionParser.new { |opts| opts.banner = <<~BANNER @@ -81,6 +82,10 @@ def run opts.on("--seed SEED", "Seed for rspec") do |s| seed = s end + + opts.on("--nice", "execute test commands with low priority") do + nice = true + end }.parse!(@argv) requires.each { |f| require(f) } @@ -106,7 +111,8 @@ def run verbose: verbose, fail_fast: fail_fast, count: count, - seed: seed + seed: seed, + nice: nice ) if success diff --git a/lib/turbo_tests/runner.rb b/lib/turbo_tests/runner.rb index 1a74b76..e078ade 100644 --- a/lib/turbo_tests/runner.rb +++ b/lib/turbo_tests/runner.rb @@ -22,6 +22,7 @@ def self.run(opts = {}) count = opts.fetch(:count, nil) seed = opts.fetch(:seed) || rand(0xFFFF).to_s seed_used = !opts[:seed].nil? + nice = opts.fetch(:nice, false) if verbose STDERR.puts "VERBOSE" @@ -38,7 +39,8 @@ def self.run(opts = {}) fail_fast: fail_fast, count: count, seed: seed, - seed_used: seed_used + seed_used: seed_used, + nice: nice ).run end @@ -55,6 +57,7 @@ def initialize(opts) @failure_count = 0 @seed = opts[:seed] @seed_used = opts[:seed_used] + @nice = opts[:nice] @messages = Thread::Queue.new @threads = [] @@ -167,6 +170,7 @@ def start_subprocess(env, extra_args, tests, process_id, record_runtime:) *tests ] command.unshift(ENV["BUNDLE_BIN_PATH"], "exec") if ENV["BUNDLE_BIN_PATH"] + command.unshift("nice") if @nice if @verbose command_str = [