Skip to content

Commit 20bf735

Browse files
committed
Fixed tests, cleaned up error messages
1 parent 51fe37a commit 20bf735

24 files changed

+61
-83
lines changed

.github/workflows/test-turbopack-rust-bench-test.yml

+15
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ jobs:
3333
with:
3434
save-cache: true
3535

36+
- name: Set Up Protoc
37+
id: set-up-protoc
38+
continue-on-error: true
39+
uses: arduino/[email protected]
40+
with:
41+
version: "3.x"
42+
repo-token: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Set Up Protoc (second try)
45+
if: steps.set-up-protoc.outcome == 'failure'
46+
uses: arduino/[email protected]
47+
with:
48+
version: "3.x"
49+
repo-token: ${{ secrets.GITHUB_TOKEN }}
50+
3651
- name: Setup Node.js
3752
uses: ./.github/actions/setup-node
3853
with:

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ rustc-ice-*.txt
4545
# CI
4646
sweep.timestamp
4747

48-
crates/turborepo-ffi/bindings.h
49-
crates/turborepo-ffi/ffi/proto/*
50-
cli/internal/ffi/libturborepo_ffi*.a
5148

5249
# Prysk test error files
5350
*.t.err

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ turborepo-cache = { path = "crates/turborepo-cache" }
154154
turborepo-ci = { path = "crates/turborepo-ci" }
155155
turborepo-env = { path = "crates/turborepo-env" }
156156
turborepo-errors = { path = "crates/turborepo-errors" }
157-
turborepo-ffi = { path = "crates/turborepo-ffi" }
158157
turborepo-fs = { path = "crates/turborepo-fs" }
159158
turborepo-lib = { path = "crates/turborepo-lib", default-features = false }
160159
turborepo-lockfiles = { path = "crates/turborepo-lockfiles" }

cli/Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ build-lib-turbo-cross:
8181
goreleaser release --rm-dist -f cross-lib.yml
8282

8383
.PHONY: stage-release
84-
stage-release: cmd/turbo/version.go
84+
stage-release:
8585
echo "Version: $(TURBO_VERSION)"
8686
echo "Tag: $(TURBO_TAG)"
8787
cat $(CLI_DIR)/../version.txt
@@ -91,7 +91,6 @@ stage-release: cmd/turbo/version.go
9191

9292
# Stop if versions are not updated.
9393
@test "" != "`git diff -- $(CLI_DIR)/../version.txt`" || (echo "Refusing to publish with unupdated version.txt" && false)
94-
@test "" != "`git diff -- $(CLI_DIR)/cmd/turbo/version.go`" || (echo "Refusing to publish with unupdated version.go" && false)
9594

9695
# Prepare the packages.
9796
cd $(CLI_DIR)/../packages/turbo && pnpm version "$(TURBO_VERSION)" --allow-same-version

crates/turborepo-lib/src/lib.rs

+36-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ mod tracing;
3333
mod turbo_json;
3434
mod unescape;
3535

36+
use miette::Report;
37+
3638
pub use crate::{
3739
child::spawn_child,
3840
cli::Args,
@@ -41,7 +43,7 @@ pub use crate::{
4143
execution_state::ExecutionState,
4244
run::package_discovery::DaemonPackageDiscovery,
4345
};
44-
use crate::{commands::CommandBase, engine::BuilderError};
46+
use crate::{engine::BuilderError, shim::Error};
4547

4648
pub fn get_version() -> &'static str {
4749
include_str!("../../../version.txt")
@@ -53,5 +55,37 @@ pub fn get_version() -> &'static str {
5355
}
5456

5557
pub fn main() -> Result<i32, shim::Error> {
56-
shim::run()
58+
match shim::run() {
59+
Ok(code) => Ok(code),
60+
// We only print using miette for some errors because we want to keep
61+
// compatibility with Go. When we've deleted the Go code we can
62+
// move all errors to miette since it provides slightly nicer
63+
// printing out of the box.
64+
Err(
65+
err @ (Error::MultipleCwd(..)
66+
| Error::EmptyCwd { .. }
67+
| Error::Cli(cli::Error::Run(run::Error::Builder(engine::BuilderError::Config(
68+
config::Error::InvalidEnvPrefix { .. },
69+
))))
70+
| Error::Cli(cli::Error::Run(run::Error::Config(
71+
config::Error::TurboJsonParseError(_),
72+
)))
73+
| Error::Cli(cli::Error::Run(run::Error::Builder(BuilderError::Config(
74+
config::Error::TurboJsonParseError(_),
75+
))))),
76+
) => {
77+
println!("{:?}", Report::new(err));
78+
79+
Ok(1)
80+
}
81+
// We don't need to print "Turbo error" for Run errors
82+
Err(err @ shim::Error::Cli(cli::Error::Run(_))) => Err(err),
83+
Err(err) => {
84+
// This raw print matches the Go behavior, once we no longer care
85+
// about matching formatting we should remove this.
86+
println!("Turbo error: {err}");
87+
88+
Err(err)
89+
}
90+
}
5791
}

crates/turborepo/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ license = "MPL-2.0"
99
# This is for the convenience of running daily dev workflows, i.e running
1010
# `cargo xxx` without explicitly specifying features, not that we want to
1111
# promote this as default backend.
12-
default = ["rustls-tls", "go-binary"]
12+
default = ["rustls-tls"]
1313
native-tls = ["turborepo-lib/native-tls"]
1414
rustls-tls = ["turborepo-lib/rustls-tls"]
1515
http = ["turborepo-lib/http"]
1616
go-daemon = ["turborepo-lib/go-daemon"]
17-
go-binary = []
1817
pprof = ["turborepo-lib/pprof"]
1918

2019
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

crates/turborepo/src/main.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ mod panic_handler;
66
use std::process;
77

88
use anyhow::Result;
9-
use miette::Report;
109

1110
use crate::panic_handler::panic_handler;
1211

@@ -15,13 +14,7 @@ use crate::panic_handler::panic_handler;
1514
fn main() -> Result<()> {
1615
std::panic::set_hook(Box::new(panic_handler));
1716

18-
let exit_code = match turborepo_lib::main() {
19-
Ok(code) => code,
20-
Err(err) => {
21-
println!("{:?}", Report::new(err));
22-
1
23-
}
24-
};
17+
let exit_code = turborepo_lib::main().unwrap_or(1);
2518

2619
process::exit(exit_code)
2720
}

turborepo-tests/integration/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"scripts": {
44
"test": "cross-env ./node_modules/.bin/prysk tests",
55
"test:interactive": "cross-env PRYSK_INTERACTIVE=true ./node_modules/.bin/prysk tests",
6+
"test:go-fallback": "cross-env EXPERIMENTAL_RUST_CODEPATH=false ./node_modules/.bin/prysk tests",
67
"test:parallel": ".cram_env/bin/pytest -n auto tests --prysk-shell=`which bash`",
78
"pretest:parallel": ".cram_env/bin/pip3 install --quiet pytest \"prysk[pytest-plugin]\" pytest-xdist"
89
},

turborepo-tests/integration/tests/command-version.t

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ Test version matches that of version.txt
88

99
TODO: resolve ambiguity
1010
$ ${TURBO} -v
11-
x No command specified
12-
11+
Turbo error: No command specified
1312
[1]

turborepo-tests/integration/tests/dry-json/monorepo.t

-2
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,4 @@ Run again with NODE_ENV set and see the value in the summary. --filter=util work
180180
Tasks that don't exist throw an error
181181
$ ${TURBO} run doesnotexist --dry=json
182182
ERROR run failed:( error preparing engine:)? Could not find the following tasks in project: doesnotexist (re)
183-
x Could not find the following tasks in project: doesnotexist
184-
185183
[1]

turborepo-tests/integration/tests/no-args.t

+1-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ Make sure exit code is 2 when no args are passed
101101
[1]
102102

103103
$ ${TURBO} run
104-
x at least one task must be specified
105-
104+
Turbo error: at least one task must be specified
106105
[1]
107106

108107
Run again with an environment variable that corresponds to a run argument and assert that

turborepo-tests/integration/tests/persistent-dependencies/1-topological.t

-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@
1515
$ ${TURBO} run dev
1616
ERROR run failed: error preparing engine: Invalid persistent task configuration:
1717
"pkg-a#dev" is a persistent task, "app-a#dev" cannot depend on it
18-
x error preparing engine: Invalid persistent task configuration:
19-
| "pkg-a#dev" is a persistent task, "app-a#dev" cannot depend on it
20-
2118
[1]

turborepo-tests/integration/tests/persistent-dependencies/10-too-many.t

-8
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,11 @@
44
$ ${TURBO} run build --concurrency=1
55
ERROR run failed: error preparing engine: Invalid persistent task configuration:
66
You have 2 persistent tasks but `turbo` is configured for concurrency of 1. Set --concurrency to at least 3
7-
x error preparing engine: Invalid persistent task configuration:
8-
| You have 2 persistent tasks but `turbo` is configured for concurrency of
9-
| 1. Set --concurrency to at least 3
10-
117
[1]
128

139
$ ${TURBO} run build --concurrency=2
1410
ERROR run failed: error preparing engine: Invalid persistent task configuration:
1511
You have 2 persistent tasks but `turbo` is configured for concurrency of 2. Set --concurrency to at least 3
16-
x error preparing engine: Invalid persistent task configuration:
17-
| You have 2 persistent tasks but `turbo` is configured for concurrency of
18-
| 2. Set --concurrency to at least 3
19-
2012
[1]
2113

2214
$ ${TURBO} run build --concurrency=3 > tmp.log 2>&1

turborepo-tests/integration/tests/persistent-dependencies/2-same-workspace.t

-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@
1515
$ ${TURBO} run build
1616
ERROR run failed: error preparing engine: Invalid persistent task configuration:
1717
"app-a#dev" is a persistent task, "app-a#build" cannot depend on it
18-
x error preparing engine: Invalid persistent task configuration:
19-
| "app-a#dev" is a persistent task, "app-a#build" cannot depend on it
20-
2118
[1]

turborepo-tests/integration/tests/persistent-dependencies/3-workspace-specific.t

-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,4 @@
2020
ERROR run failed: error preparing engine: Invalid persistent task configuration:
2121
"pkg-a#dev" is a persistent task, "app-a#build" cannot depend on it
2222
"pkg-a#dev" is a persistent task, "pkg-a#build" cannot depend on it
23-
x error preparing engine: Invalid persistent task configuration:
24-
| "pkg-a#dev" is a persistent task, "app-a#build" cannot depend on it
25-
| "pkg-a#dev" is a persistent task, "pkg-a#build" cannot depend on it
26-
2723
[1]

turborepo-tests/integration/tests/persistent-dependencies/4-cross-workspace.t

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@
99
$ ${TURBO} run dev
1010
ERROR run failed: error preparing engine: Invalid persistent task configuration:
1111
"pkg-a#dev" is a persistent task, "app-a#dev" cannot depend on it
12-
x error preparing engine: Invalid persistent task configuration:
13-
| "pkg-a#dev" is a persistent task, "app-a#dev" cannot depend on it
14-
1512
[1]

turborepo-tests/integration/tests/persistent-dependencies/5-root-workspace.t

-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@
1515
$ ${TURBO} run build
1616
ERROR run failed: error preparing engine: Invalid persistent task configuration:
1717
"//#dev" is a persistent task, "app-a#build" cannot depend on it
18-
x error preparing engine: Invalid persistent task configuration:
19-
| "//#dev" is a persistent task, "app-a#build" cannot depend on it
20-
2118
[1]

turborepo-tests/integration/tests/persistent-dependencies/7-topological-nested.t

-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,4 @@
2222
$ ${TURBO} run dev
2323
ERROR run failed: error preparing engine: Invalid persistent task configuration:
2424
"pkg-b#dev" is a persistent task, "pkg-a#dev" cannot depend on it
25-
x error preparing engine: Invalid persistent task configuration:
26-
| "pkg-b#dev" is a persistent task, "pkg-a#dev" cannot depend on it
27-
2825
[1]

turborepo-tests/integration/tests/persistent-dependencies/8-topological-with-extra.t

-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,4 @@
2121
$ ${TURBO} run build
2222
ERROR run failed: error preparing engine: Invalid persistent task configuration:
2323
"pkg-z#dev" is a persistent task, "pkg-b#build" cannot depend on it
24-
x error preparing engine: Invalid persistent task configuration:
25-
| "pkg-z#dev" is a persistent task, "pkg-b#build" cannot depend on it
26-
2724
[1]

turborepo-tests/integration/tests/persistent-dependencies/9-cross-workspace-nested.t

-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,4 @@
1414
$ ${TURBO} run build
1515
ERROR run failed: error preparing engine: Invalid persistent task configuration:
1616
"app-z#dev" is a persistent task, "app-c#build" cannot depend on it
17-
x error preparing engine: Invalid persistent task configuration:
18-
| "app-z#dev" is a persistent task, "app-c#build" cannot depend on it
19-
2017
[1]

turborepo-tests/integration/tests/run/missing-tasks.t

-6
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,16 @@ Setup
44
# Running non-existent tasks errors
55
$ ${TURBO} run doesnotexist
66
ERROR run failed:( error preparing engine:)? Could not find the following tasks in project: doesnotexist (re)
7-
x Could not find the following tasks in project: doesnotexist
8-
97
[1]
108

119
# Multiple non-existent tasks also error
1210
$ ${TURBO} run doesnotexist alsono
1311
ERROR run failed:( error preparing engine:)? Could not find the following tasks in project: alsono, doesnotexist (re)
14-
x Could not find the following tasks in project: alsono, doesnotexist
15-
1612
[1]
1713

1814
# One good and one bad task does not error
1915
$ ${TURBO} run build doesnotexist
2016
ERROR run failed:( error preparing engine:)? Could not find the following tasks in project: doesnotexist (re)
21-
x Could not find the following tasks in project: doesnotexist
22-
2317
[1]
2418

2519
# Bad command

turborepo-tests/integration/tests/workspace-configs/invalid-config.t

-8
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,21 @@ Errors are shown if we run a task that is misconfigured (invalid-config#build)
88
[1]
99
$ cat tmp.log | grep --only-matching "Invalid turbo.json"
1010
Invalid turbo.json
11-
Invalid turbo.json
1211
$ cat tmp.log | grep "invalid-config#build"
1312
- "invalid-config#build". Use "build" instead
14-
| - "invalid-config#build". Use "build" instead
1513
$ cat tmp.log | grep "//#some-root-task"
1614
- "//#some-root-task". Use "some-root-task" instead
17-
| - "//#some-root-task". Use "some-root-task" instead
1815
$ cat tmp.log | grep "extends"
1916
- No "extends" key found
20-
| - No "extends" key found
2117

2218
Same error even if you're running a valid task in the package.
2319
$ ${TURBO} run valid-task --filter=invalid-config > tmp.log 2>&1
2420
[1]
2521
$ cat tmp.log | grep --only-matching "Invalid turbo.json"
2622
Invalid turbo.json
27-
Invalid turbo.json
2823
$ cat tmp.log | grep "invalid-config#build"
2924
- "invalid-config#build". Use "build" instead
30-
| - "invalid-config#build". Use "build" instead
3125
$ cat tmp.log | grep "//#some-root-task"
3226
- "//#some-root-task". Use "some-root-task" instead
33-
| - "//#some-root-task". Use "some-root-task" instead
3427
$ cat tmp.log | grep "extends"
3528
- No "extends" key found
36-
| - No "extends" key found

turborepo-tests/integration/tests/workspace-configs/persistent.t

-12
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ This test covers:
1212
$ ${TURBO} run persistent-task-1-parent --filter=persistent
1313
ERROR run failed: error preparing engine: Invalid persistent task configuration:
1414
"persistent#persistent-task-1" is a persistent task, "persistent#persistent-task-1-parent" cannot depend on it
15-
x error preparing engine: Invalid persistent task configuration:
16-
| "persistent#persistent-task-1" is a persistent task,
17-
| "persistent#persistent-task-1-parent" cannot depend on it
18-
1915
[1]
2016

2117
# persistent-task-2-parent dependsOn persistent-task-2
@@ -47,19 +43,11 @@ This test covers:
4743
$ ${TURBO} run persistent-task-3-parent --filter=persistent
4844
ERROR run failed: error preparing engine: Invalid persistent task configuration:
4945
"persistent#persistent-task-3" is a persistent task, "persistent#persistent-task-3-parent" cannot depend on it
50-
x error preparing engine: Invalid persistent task configuration:
51-
| "persistent#persistent-task-3" is a persistent task,
52-
| "persistent#persistent-task-3-parent" cannot depend on it
53-
5446
[1]
5547

5648
# persistent-task-4-parent dependsOn persistent-task-4
5749
# persistent-task-4 has no config in the root workspace, and is set to true in the workspace
5850
$ ${TURBO} run persistent-task-4-parent --filter=persistent
5951
ERROR run failed: error preparing engine: Invalid persistent task configuration:
6052
"persistent#persistent-task-4" is a persistent task, "persistent#persistent-task-4-parent" cannot depend on it
61-
x error preparing engine: Invalid persistent task configuration:
62-
| "persistent#persistent-task-4" is a persistent task,
63-
| "persistent#persistent-task-4-parent" cannot depend on it
64-
6553
[1]

turborepo-tests/integration/turbo.json

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
"test": {
1010
"dependsOn": ["cli#build", "topo", "^build"],
1111
"passThroughEnv": ["CI"]
12+
},
13+
"test:go-fallback": {
14+
"dependsOn": ["cli#build", "topo", "^build"],
15+
"passThroughEnv": ["CI"]
1216
}
1317
}
1418
}

0 commit comments

Comments
 (0)