Skip to content

Commit

Permalink
Restore back options --verbose-process-command and --verbose-rerun-co…
Browse files Browse the repository at this point in the history
…mmand (#952)

* Restore back options --verbose-process-command and --verbose-rerun-command

implements issue #951

* Reference Github PR in Changelog

* Remove :verbose_command option

It's now just an alias to --verbose-process-command and
--verbose-rerun-command combined.
  • Loading branch information
priceline-rosenfeld committed Apr 25, 2024
1 parent 1d93947 commit 4425e06
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,9 @@
# Changelog

## Unreleased
- Restored the `--verbose-process-command` and `--verbose-rerun-command` options, removed in version 4.0.0.
See [#952](https://github.com/grosser/parallel_tests/pull/952).
`--verbose-command` continues to be supported and is equivalent to set the 2 options above.

### Breaking Changes

Expand Down
4 changes: 3 additions & 1 deletion Readme.md
Expand Up @@ -284,7 +284,9 @@ Options are:
--first-is-1 Use "1" as TEST_ENV_NUMBER to not reuse the default test environment
--fail-fast Stop all groups when one group fails (best used with --test-options '--fail-fast' if supported
--verbose Print debug output
--verbose-command Displays the command that will be executed by each process and when there are failures displays the command executed by each process that failed
--verbose-command Combines options --verbose-process-command and --verbose-rerun-command
--verbose-process-command Print the command that will be executed by each process before it begins
--verbose-rerun-command After a process fails, print the command executed by that process
--quiet Print only tests output
-v, --version Show Version
-h, --help Show this.
Expand Down
6 changes: 4 additions & 2 deletions lib/parallel_tests/cli.rb
Expand Up @@ -146,7 +146,7 @@ def report_failure_rerun_commmand(test_results, options)
failing_sets = test_results.reject { |r| r[:exit_status] == 0 }
return if failing_sets.none?

if options[:verbose] || options[:verbose_command]
if options[:verbose] || options[:verbose_rerun_command]
puts "\n\nTests have failed for a parallel_test group. Use the following command to run the group again:\n\n"
failing_sets.each do |failing_set|
command = failing_set[:command]
Expand Down Expand Up @@ -291,7 +291,9 @@ def parse_options!(argv)
opts.on("--first-is-1", "Use \"1\" as TEST_ENV_NUMBER to not reuse the default test environment") { options[:first_is_1] = true }
opts.on("--fail-fast", "Stop all groups when one group fails (best used with --test-options '--fail-fast' if supported") { options[:fail_fast] = true }
opts.on("--verbose", "Print debug output") { options[:verbose] = true }
opts.on("--verbose-command", "Displays the command that will be executed by each process and when there are failures displays the command executed by each process that failed") { options[:verbose_command] = true }
opts.on("--verbose-command", "Combines options --verbose-process-command and --verbose-rerun-command") { options.merge! verbose_process_command: true, verbose_rerun_command: true }
opts.on("--verbose-process-command", "Print the command that will be executed by each process before it begins") { options[:verbose_process_command] = true }
opts.on("--verbose-rerun-command", "After a process fails, print the command executed by that process") { options[:verbose_rerun_command] = true }
opts.on("--quiet", "Print only tests output") { options[:quiet] = true }
opts.on("-v", "--version", "Show Version") do
puts ParallelTests::VERSION
Expand Down
2 changes: 1 addition & 1 deletion lib/parallel_tests/test/runner.rb
Expand Up @@ -293,7 +293,7 @@ def set_unknown_runtime(tests, options)
end

def report_process_command?(options)
options[:verbose] || options[:verbose_command]
options[:verbose] || options[:verbose_process_command]
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions spec/integration_spec.rb
Expand Up @@ -241,6 +241,20 @@ def test_unicode
expect(result).to include "bundle exec rspec spec/xxx2_spec.rb"
end

it "shows only rerun with --verbose-rerun-command" do
write 'spec/xxx_spec.rb', 'describe("it"){it("should"){expect(1).to eq(2)}}'
result = run_tests ["spec", "--verbose-rerun-command"], type: 'rspec', fail: true
expect(result).to match printed_rerun
expect(result).to_not match printed_commands
end

it "shows only process with --verbose-process-command" do
write 'spec/xxx_spec.rb', 'describe("it"){it("should"){expect(1).to eq(2)}}'
result = run_tests ["spec", "--verbose-process-command"], type: 'rspec', fail: true
expect(result).to_not match printed_rerun
expect(result).to match printed_commands
end

it "fails when tests fail" do
write 'spec/xxx_spec.rb', 'describe("it"){it("should"){puts "TEST1"}}'
write 'spec/xxx2_spec.rb', 'describe("it"){it("should"){expect(1).to eq(2)}}'
Expand Down
18 changes: 15 additions & 3 deletions spec/parallel_tests/cli_spec.rb
Expand Up @@ -57,7 +57,19 @@ def call(*args)

it "parses --verbose-command" do
expect(call(['test', '--verbose-command'])).to eq(
defaults.merge(verbose_command: true)
defaults.merge(verbose_process_command: true, verbose_rerun_command: true)
)
end

it "parses --verbose-process-command" do
expect(call(['test', '--verbose-process-command'])).to eq(
defaults.merge(verbose_process_command: true)
)
end

it "parses --verbose-rerun-command" do
expect(call(['test', '--verbose-rerun-command'])).to eq(
defaults.merge(verbose_rerun_command: true)
)
end

Expand Down Expand Up @@ -239,10 +251,10 @@ def self.it_prints_nothing_about_rerun_commands(options)
it_prints_nothing_about_rerun_commands(verbose: false)
end

context "with verbose command" do
context "with verbose rerun command" do
it "prints command if there is a failure" do
expect do
subject.send(:report_failure_rerun_commmand, single_failed_command, verbose_command: true)
subject.send(:report_failure_rerun_commmand, single_failed_command, verbose_rerun_command: true)
end.to output("\n\nTests have failed for a parallel_test group. Use the following command to run the group again:\n\nTEST_ENV_NUMBER= PARALLEL_TEST_GROUPS= foo\n").to_stdout
end
end
Expand Down

0 comments on commit 4425e06

Please sign in to comment.