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 tests to validate errors-only is working #3945

Merged
merged 4 commits into from
Feb 27, 2023
Merged
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
24 changes: 0 additions & 24 deletions cli/integration_tests/monorepo_one_script_error/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,3 @@ Make sure error isn't cached

ERROR run failed: command exited (1)
[1]

Running with --output-mode=errors-only gives error output only
$ ${TURBO} --output-logs=errors-only error
\xe2\x80\xa2 Packages in scope: my-app (esc)
\xe2\x80\xa2 Running error in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
my-app:error: ERROR: command finished with error: command \(.*/run\.t(-\d+)?/apps/my-app\) npm run error exited \(1\) (re)
my-app:error:
my-app:error: > error
my-app:error: > echo 'intentionally failing' && exit 2
my-app:error:
my-app:error: intentionally failing
my-app:error: npm ERR! Lifecycle script `error` failed with error:
my-app:error: npm ERR! Error: command failed
my-app:error: npm ERR! in workspace: my-app
my-app:error: npm ERR! at location: .*/run\.t(-\d+)?/apps/my-app (re)
command \(.*/run\.t(-\d+)?/apps/my-app\) npm run error exited \(1\) (re)

Tasks: 1 successful, 2 total
Cached: 1 cached, 2 total
Time:\s*[\.0-9]+m?s (re)

ERROR run failed: command exited (1)
[1]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was redundant with the new ones I added. The other tests in this file are about caching the outputs, so I kept those.

81 changes: 81 additions & 0 deletions cli/integration_tests/run_logging/errors-only.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Setup
$ . ${TESTDIR}/../setup.sh
$ . ${TESTDIR}/setup.sh $(pwd) ./monorepo

# [ ] error exit
# [ ] outputMode: errors-only
# [x] --ouptut-logs=errors-only
$ ${TURBO} run build --output-logs=errors-only
\xe2\x80\xa2 Packages in scope: app-a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 1 successful, 1 total
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)


# [ ] error exit
# [x] outputMode: errors-only
# [ ] --ouptut-logs=errors-only
$ ${TURBO} run buildsuccess
\xe2\x80\xa2 Packages in scope: app-a (esc)
\xe2\x80\xa2 Running buildsuccess in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)

Tasks: 1 successful, 1 total
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

# [x] error exit
# [ ] outputMode: errors-only
# [x] --ouptut-logs=errors-only
$ ${TURBO} run builderror --output-logs=errors-only
\xe2\x80\xa2 Packages in scope: app-a (esc)
\xe2\x80\xa2 Running builderror in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
app-a:builderror: ERROR: command finished with error: command .* npm run builderror exited \(1\) (re)
app-a:builderror:
app-a:builderror: > builderror
app-a:builderror: > echo "error builderror app-a!" && exit 1
app-a:builderror:
app-a:builderror: error builderror app-a!
app-a:builderror: npm ERR! Lifecycle script `builderror` failed with error:
app-a:builderror: npm ERR! Error: command failed
app-a:builderror: npm ERR! in workspace: app-a
app-a:builderror: npm ERR! at location: .* (re)
command .* npm run builderror exited \(1\) (re)

Tasks: 0 successful, 1 total
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

ERROR run failed: command exited (1)
[1]

# [x] error exit
# [x] outputMode: errors-only
# [ ] --ouptut-logs=errors-only
$ ${TURBO} run builderror2
\xe2\x80\xa2 Packages in scope: app-a (esc)
\xe2\x80\xa2 Running builderror2 in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
app-a:builderror2: ERROR: command finished with error: command .* npm run builderror2 exited \(1\) (re)
app-a:builderror2:
app-a:builderror2: > builderror2
app-a:builderror2: > echo "error builderror2 app-a!" && exit 1
app-a:builderror2:
app-a:builderror2: error builderror2 app-a!
app-a:builderror2: npm ERR! Lifecycle script `builderror2` failed with error:
app-a:builderror2: npm ERR! Error: command failed
app-a:builderror2: npm ERR! in workspace: app-a
app-a:builderror2: npm ERR! at location: .* (re)
command .* npm run builderror2 exited \(1\) (re)

Tasks: 0 successful, 1 total
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)

ERROR run failed: command exited (1)
[1]

10 changes: 5 additions & 5 deletions cli/integration_tests/run_logging/log_prefix.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Setup
\xe2\x80\xa2 Packages in scope: app-a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
cache miss, executing 74eb1b46ce8b29d3
cache miss, executing af2fdb8283036b97

\> build (re)
\> echo 'build app-a' (re)
Expand All @@ -31,23 +31,23 @@ Setup
\xe2\x80\xa2 Packages in scope: app-a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
cache miss, executing 3df2c74b2bfbc724
cache hit, replaying output af2fdb8283036b97

\> build (re)
\> echo 'build app-a' (re)

build app-a

Tasks: 1 successful, 1 total
Cached: 0 cached, 1 total
Time:\s*[\.0-9]+m?s (re)
Cached: 1 cached, 1 total
Time:\s*[\.0-9]+m?s >>> FULL TURBO (re)

# Running again withuot `--log-prefix` should get a cache hit, but should print prefixes this time
$ ${TURBO} run build
\xe2\x80\xa2 Packages in scope: app-a (esc)
\xe2\x80\xa2 Running build in 1 packages (esc)
\xe2\x80\xa2 Remote caching disabled (esc)
app-a:build: cache hit, replaying output 3df2c74b2bfbc724
app-a:build: cache hit, replaying output af2fdb8283036b97
app-a:build:
app-a:build: > build
app-a:build: > echo 'build app-a'
Expand Down
1 change: 1 addition & 0 deletions cli/integration_tests/run_logging/monorepo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.turbo
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "app-a",
"scripts": {
"build": "echo 'build app-a'"
"build": "echo 'build app-a'",
"builderror": "echo \"error builderror app-a!\" && exit 1",
"builderror2": "echo \"error builderror2 app-a!\" && exit 1",
"buildsuccess": "echo \"buildsuccess app-a!\""
}
}
10 changes: 9 additions & 1 deletion cli/integration_tests/run_logging/monorepo/turbo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"pipeline": {
"build": {}
"build": {},

"builderror": {},
"builderror2": {
"outputMode": "errors-only"
},
"buildsuccess": {
"outputMode": "errors-only"
}
}
}