Skip to content

Commit f86ce56

Browse files
committed
Auto merge of #14191 - dieterplex:migrate-jobserver-snapbox, r=epage
test: Migrate jobserver to snapbox Part of #14039.
2 parents 606adee + 58fce87 commit f86ce56

File tree

1 file changed

+92
-20
lines changed

1 file changed

+92
-20
lines changed

tests/testsuite/jobserver.rs

Lines changed: 92 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,104 @@ 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+
237+
"#]])
222238
.run();
223239
p.cargo("run -j2")
224240
.env("PATH", path)
225241
.arg("--config")
226242
.arg(config_value)
227243
.with_status(101)
228-
.with_stderr_contains("[..]this is a runner[..]")
229-
.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+
"#]])
230257
.run();
231258
p.cargo("test -j2")
232259
.with_status(101)
233-
.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+
"#]])
234280
.run();
235281
p.cargo("test -j2")
236282
.env("PATH", path)
237283
.arg("--config")
238284
.arg(config_value)
239285
.with_status(101)
240-
.with_stderr_contains("[..]this is a runner[..]")
241-
.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+
"#]])
242316
.run();
243317
}
244318

@@ -371,13 +445,11 @@ all:
371445
p.process(make)
372446
.env("CARGO", cargo_exe())
373447
.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-
)
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+
"#]])
382454
.run();
383455
}

0 commit comments

Comments
 (0)