1
1
//! Tests for the jobserver protocol.
2
2
3
- #![ allow( deprecated) ]
4
-
5
3
use cargo_util:: is_ci;
6
4
use std:: env;
7
5
use std:: net:: TcpListener ;
@@ -12,8 +10,7 @@ use cargo_test_support::basic_bin_manifest;
12
10
use cargo_test_support:: cargo_exe;
13
11
use cargo_test_support:: install:: assert_has_installed_exe;
14
12
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} ;
17
14
18
15
const EXE_CONTENT : & str = r#"
19
16
use std::env;
@@ -201,7 +198,12 @@ test-runner:
201
198
. env ( "CARGO" , cargo_exe ( ) )
202
199
. arg ( "run-runner" )
203
200
. 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
+ "# ] ] )
205
207
. run ( ) ;
206
208
p. process ( make)
207
209
. env ( "CARGO" , cargo_exe ( ) )
@@ -213,33 +215,104 @@ test-runner:
213
215
. env ( "CARGO" , cargo_exe ( ) )
214
216
. arg ( "test-runner" )
215
217
. 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
+ "# ] ] )
217
224
. run ( ) ;
218
225
219
226
// but not from `-j` flag
220
227
p. cargo ( "run -j2" )
221
228
. 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
+ "# ] ] )
223
238
. run ( ) ;
224
239
p. cargo ( "run -j2" )
225
240
. env ( "PATH" , path)
226
241
. arg ( "--config" )
227
242
. arg ( config_value)
228
243
. 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
+ "# ] ] )
231
257
. run ( ) ;
232
258
p. cargo ( "test -j2" )
233
259
. 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
+ "# ] ] )
235
280
. run ( ) ;
236
281
p. cargo ( "test -j2" )
237
282
. env ( "PATH" , path)
238
283
. arg ( "--config" )
239
284
. arg ( config_value)
240
285
. 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
+ "# ] ] )
243
316
. run ( ) ;
244
317
}
245
318
@@ -372,13 +445,11 @@ all:
372
445
p. process ( make)
373
446
. env ( "CARGO" , cargo_exe ( ) )
374
447
. 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
+ "# ] ] )
383
454
. run ( ) ;
384
455
}
0 commit comments