Skip to content

Commit 82477d8

Browse files
committed
test: Migrate jobserver to snapbox
1 parent 3a76b8c commit 82477d8

File tree

1 file changed

+90
-20
lines changed

1 file changed

+90
-20
lines changed

tests/testsuite/jobserver.rs

Lines changed: 90 additions & 20 deletions
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;
@@ -156,6 +153,7 @@ fn runner_inherits_jobserver() {
156153
[package]
157154
name = "{name}"
158155
version = "0.0.1"
156+
edition = "2015"
159157
"#
160158
),
161159
)
@@ -200,7 +198,12 @@ test-runner:
200198
.env("CARGO", cargo_exe())
201199
.arg("run-runner")
202200
.arg("-j2")
203-
.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+
"#]])
204207
.run();
205208
p.process(make)
206209
.env("CARGO", cargo_exe())
@@ -212,33 +215,102 @@ test-runner:
212215
.env("CARGO", cargo_exe())
213216
.arg("test-runner")
214217
.arg("-j2")
215-
.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+
"#]])
216224
.run();
217225

218226
// but not from `-j` flag
219227
p.cargo("run -j2")
220228
.with_status(101)
221-
.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+
"#]])
222237
.run();
223238
p.cargo("run -j2")
224239
.env("PATH", path)
225240
.arg("--config")
226241
.arg(config_value)
227242
.with_status(101)
228-
.with_stderr_contains("[..]this is a runner[..]")
229-
.with_stderr_contains("[..]no jobserver from env[..]")
243+
.with_stderr_data(str![[r#"
244+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
245+
[RUNNING] `runner target/debug/cargo-jobserver-check[EXE]`
246+
this is a runner
247+
thread 'main' panicked at src/main.rs:5:43:
248+
no jobserver from env: NotPresent
249+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
250+
thread 'main' panicked at src/main.rs:6:17:
251+
assertion failed: status.success()
252+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
253+
254+
"#]])
230255
.run();
231256
p.cargo("test -j2")
232257
.with_status(101)
233-
.with_stdout_contains("[..]no jobserver from env[..]")
258+
.with_stdout_data(str![[r#"
259+
260+
running 1 test
261+
test test ... FAILED
262+
263+
failures:
264+
265+
---- test stdout ----
266+
thread 'test' panicked at src/lib.rs:4:42:
267+
no jobserver from env: NotPresent
268+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
269+
270+
271+
failures:
272+
test
273+
274+
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
275+
276+
277+
"#]])
234278
.run();
235279
p.cargo("test -j2")
236280
.env("PATH", path)
237281
.arg("--config")
238282
.arg(config_value)
239283
.with_status(101)
240-
.with_stderr_contains("[..]this is a runner[..]")
241-
.with_stdout_contains("[..]no jobserver from env[..]")
284+
.with_stderr_data(str![[r#"
285+
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
286+
[RUNNING] unittests src/lib.rs (target/debug/deps/cargo_jobserver_check-[HASH][EXE])
287+
this is a runner
288+
thread 'main' panicked at src/main.rs:6:17:
289+
assertion failed: status.success()
290+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
291+
[ERROR] test failed, to rerun pass `--lib`
292+
293+
"#]])
294+
.with_stdout_data(str![[r#"
295+
296+
running 1 test
297+
test test ... FAILED
298+
299+
failures:
300+
301+
---- test stdout ----
302+
thread 'test' panicked at src/lib.rs:4:42:
303+
no jobserver from env: NotPresent
304+
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
305+
306+
307+
failures:
308+
test
309+
310+
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
311+
312+
313+
"#]])
242314
.run();
243315
}
244316

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

0 commit comments

Comments
 (0)