Skip to content

Commit 3c17ca0

Browse files
committed
test: Migrate jobserver to snapbox
1 parent eb9c75e commit 3c17ca0

File tree

1 file changed

+91
-20
lines changed

1 file changed

+91
-20
lines changed

tests/testsuite/jobserver.rs

+91-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Tests for the jobserver protocol.
22
3-
#![allow(deprecated)]
4-
53
use cargo_util::is_ci;
64
use std::env;
75
use std::net::TcpListener;
@@ -12,8 +10,7 @@ use cargo_test_support::basic_bin_manifest;
1210
use cargo_test_support::cargo_exe;
1311
use cargo_test_support::install::assert_has_installed_exe;
1412
use cargo_test_support::install::cargo_home;
15-
use cargo_test_support::project;
16-
use cargo_test_support::rustc_host;
13+
use cargo_test_support::{project, rustc_host, str};
1714

1815
const EXE_CONTENT: &str = r#"
1916
use std::env;
@@ -201,7 +198,12 @@ test-runner:
201198
.env("CARGO", cargo_exe())
202199
.arg("run-runner")
203200
.arg("-j2")
204-
.with_stderr_contains("[..]this is a runner[..]")
201+
.with_stderr_data(str![[r#"
202+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
203+
[RUNNING] `runner target/debug/cargo-jobserver-check[EXE]`
204+
this is a runner
205+
206+
"#]])
205207
.run();
206208
p.process(make)
207209
.env("CARGO", cargo_exe())
@@ -213,33 +215,104 @@ test-runner:
213215
.env("CARGO", cargo_exe())
214216
.arg("test-runner")
215217
.arg("-j2")
216-
.with_stderr_contains("[..]this is a runner[..]")
218+
.with_stderr_data(str![[r#"
219+
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
220+
[RUNNING] unittests src/lib.rs (target/debug/deps/cargo_jobserver_check-[HASH][EXE])
221+
this is a runner
222+
223+
"#]])
217224
.run();
218225

219226
// but not from `-j` flag
220227
p.cargo("run -j2")
221228
.with_status(101)
222-
.with_stderr_contains("[..]no jobserver from env[..]")
229+
.with_stderr_data(str![[r#"
230+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
231+
[RUNNING] `target/debug/cargo-jobserver-check[EXE]`
232+
thread 'main' panicked at src/main.rs:5:43:
233+
no jobserver from env: NotPresent
234+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
235+
...
236+
237+
"#]])
223238
.run();
224239
p.cargo("run -j2")
225240
.env("PATH", path)
226241
.arg("--config")
227242
.arg(config_value)
228243
.with_status(101)
229-
.with_stderr_contains("[..]this is a runner[..]")
230-
.with_stderr_contains("[..]no jobserver from env[..]")
244+
.with_stderr_data(str![[r#"
245+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
246+
[RUNNING] `runner target/debug/cargo-jobserver-check[EXE]`
247+
this is a runner
248+
thread 'main' panicked at src/main.rs:5:43:
249+
no jobserver from env: NotPresent
250+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
251+
thread 'main' panicked at src/main.rs:6:17:
252+
assertion failed: status.success()
253+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
254+
...
255+
256+
"#]])
231257
.run();
232258
p.cargo("test -j2")
233259
.with_status(101)
234-
.with_stdout_contains("[..]no jobserver from env[..]")
260+
.with_stdout_data(str![[r#"
261+
262+
running 1 test
263+
test test ... FAILED
264+
265+
failures:
266+
267+
---- test stdout ----
268+
thread 'test' panicked at src/lib.rs:4:42:
269+
no jobserver from env: NotPresent
270+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
271+
272+
273+
failures:
274+
test
275+
276+
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
277+
278+
279+
"#]])
235280
.run();
236281
p.cargo("test -j2")
237282
.env("PATH", path)
238283
.arg("--config")
239284
.arg(config_value)
240285
.with_status(101)
241-
.with_stderr_contains("[..]this is a runner[..]")
242-
.with_stdout_contains("[..]no jobserver from env[..]")
286+
.with_stderr_data(str![[r#"
287+
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
288+
[RUNNING] unittests src/lib.rs (target/debug/deps/cargo_jobserver_check-[HASH][EXE])
289+
this is a runner
290+
thread 'main' panicked at src/main.rs:6:17:
291+
assertion failed: status.success()
292+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
293+
[ERROR] test failed, to rerun pass `--lib`
294+
295+
"#]])
296+
.with_stdout_data(str![[r#"
297+
298+
running 1 test
299+
test test ... FAILED
300+
301+
failures:
302+
303+
---- test stdout ----
304+
thread 'test' panicked at src/lib.rs:4:42:
305+
no jobserver from env: NotPresent
306+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
307+
308+
309+
failures:
310+
test
311+
312+
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
313+
314+
315+
"#]])
243316
.run();
244317
}
245318

@@ -372,13 +445,11 @@ all:
372445
p.process(make)
373446
.env("CARGO", cargo_exe())
374447
.arg("-j2")
375-
.with_stderr(
376-
"\
377-
warning: a `-j` argument was passed to Cargo but Cargo is also configured \
378-
with an external jobserver in its environment, ignoring the `-j` parameter
379-
[COMPILING] [..]
380-
[FINISHED] [..]
381-
",
382-
)
448+
.with_stderr_data(str![[r#"
449+
[WARNING] a `-j` argument was passed to Cargo but Cargo is also configured with an external jobserver in its environment, ignoring the `-j` parameter
450+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
451+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
452+
453+
"#]])
383454
.run();
384455
}

0 commit comments

Comments
 (0)