From 597f0840a36575aec2c074e122cbaa66434d4ce1 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 10 Aug 2023 15:47:51 +0100 Subject: [PATCH] dev-cmd/tests: add `--fail-fast`. This is useful when testing very slow test files with many tests. --- Library/Homebrew/dev-cmd/tests.rb | 3 +++ completions/bash/brew | 1 + completions/fish/brew.fish | 1 + completions/zsh/_brew | 1 + docs/Manpage.md | 2 ++ manpages/brew.1 | 4 ++++ 6 files changed, 12 insertions(+) diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index 41bb42c048906..001779bfb8f36 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -24,6 +24,8 @@ def tests_args description: "Enable debugging using byebug." switch "--changed", description: "Only runs tests on files that were changed from the master branch." + switch "--fail-fast", + description: "Exit early on the first failing test." flag "--only=", description: "Run only `_spec.rb`. Appending `:` will start at a " \ "specific line." @@ -153,6 +155,7 @@ def tests --color --require spec_helper ] + bundle_args << "--fail-fast" if args.fail_fast? # TODO: Refactor and move to extend/os # rubocop:disable Homebrew/MoveToExtendOS diff --git a/completions/bash/brew b/completions/bash/brew index 2c523322057c2..67f88e5e4962c 100644 --- a/completions/bash/brew +++ b/completions/bash/brew @@ -2210,6 +2210,7 @@ _brew_tests() { --changed --coverage --debug + --fail-fast --generic --help --online diff --git a/completions/fish/brew.fish b/completions/fish/brew.fish index 3c0507b3e6b0f..05d2ce33d435f 100644 --- a/completions/fish/brew.fish +++ b/completions/fish/brew.fish @@ -1470,6 +1470,7 @@ __fish_brew_complete_arg 'tests' -l byebug -d 'Enable debugging using byebug' __fish_brew_complete_arg 'tests' -l changed -d 'Only runs tests on files that were changed from the master branch' __fish_brew_complete_arg 'tests' -l coverage -d 'Generate code coverage reports' __fish_brew_complete_arg 'tests' -l debug -d 'Display any debugging information' +__fish_brew_complete_arg 'tests' -l fail-fast -d 'Exit early on the first failing test' __fish_brew_complete_arg 'tests' -l generic -d 'Run only OS-agnostic tests' __fish_brew_complete_arg 'tests' -l help -d 'Show this message' __fish_brew_complete_arg 'tests' -l online -d 'Include tests that use the GitHub API and tests that use any of the taps for official external commands' diff --git a/completions/zsh/_brew b/completions/zsh/_brew index a8164b8dc29b1..a085839f6b116 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -1815,6 +1815,7 @@ _brew_tests() { '(--only)--changed[Only runs tests on files that were changed from the master branch]' \ '--coverage[Generate code coverage reports]' \ '--debug[Display any debugging information]' \ + '--fail-fast[Exit early on the first failing test]' \ '--generic[Run only OS-agnostic tests]' \ '--help[Show this message]' \ '--online[Include tests that use the GitHub API and tests that use any of the taps for official external commands]' \ diff --git a/docs/Manpage.md b/docs/Manpage.md index 3cabca34c7a91..84c7bb0c8e148 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -1579,6 +1579,8 @@ Run Homebrew's unit and integration tests. Enable debugging using byebug. * `--changed`: Only runs tests on files that were changed from the master branch. +* `--fail-fast`: + Exit early on the first failing test. * `--only`: Run only *`test_script`*`_spec.rb`. Appending `:`*`line_number`* will start at a specific line. * `--seed`: diff --git a/manpages/brew.1 b/manpages/brew.1 index da179abc457f9..08c6ec6643169 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -2274,6 +2274,10 @@ Enable debugging using byebug\. Only runs tests on files that were changed from the master branch\. . .TP +\fB\-\-fail\-fast\fR +Exit early on the first failing test\. +. +.TP \fB\-\-only\fR Run only \fItest_script\fR\fB_spec\.rb\fR\. Appending \fB:\fR\fIline_number\fR will start at a specific line\. .