Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --nice flag #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/turbo_tests/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def run
verbose = false
fail_fast = nil
seed = nil
nice = false

OptionParser.new { |opts|
opts.banner = <<~BANNER
Expand Down Expand Up @@ -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) }
Expand All @@ -106,7 +111,8 @@ def run
verbose: verbose,
fail_fast: fail_fast,
count: count,
seed: seed
seed: seed,
nice: nice
)

if success
Expand Down
6 changes: 5 additions & 1 deletion lib/turbo_tests/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand All @@ -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 = []
Expand Down Expand Up @@ -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 = [
Expand Down