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;
@@ -156,6 +153,7 @@ fn runner_inherits_jobserver() {
156
153
[package]
157
154
name = "{name}"
158
155
version = "0.0.1"
156
+ edition = "2015"
159
157
"#
160
158
) ,
161
159
)
@@ -200,7 +198,12 @@ test-runner:
200
198
. env ( "CARGO" , cargo_exe ( ) )
201
199
. arg ( "run-runner" )
202
200
. 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
+ "# ] ] )
204
207
. run ( ) ;
205
208
p. process ( make)
206
209
. env ( "CARGO" , cargo_exe ( ) )
@@ -212,33 +215,102 @@ test-runner:
212
215
. env ( "CARGO" , cargo_exe ( ) )
213
216
. arg ( "test-runner" )
214
217
. 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
+ "# ] ] )
216
224
. run ( ) ;
217
225
218
226
// but not from `-j` flag
219
227
p. cargo ( "run -j2" )
220
228
. 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
+ "# ] ] )
222
237
. run ( ) ;
223
238
p. cargo ( "run -j2" )
224
239
. env ( "PATH" , path)
225
240
. arg ( "--config" )
226
241
. arg ( config_value)
227
242
. 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
+ "# ] ] )
230
255
. run ( ) ;
231
256
p. cargo ( "test -j2" )
232
257
. 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
+ "# ] ] )
234
278
. run ( ) ;
235
279
p. cargo ( "test -j2" )
236
280
. env ( "PATH" , path)
237
281
. arg ( "--config" )
238
282
. arg ( config_value)
239
283
. 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
+ "# ] ] )
242
314
. run ( ) ;
243
315
}
244
316
@@ -371,13 +443,11 @@ all:
371
443
p. process ( make)
372
444
. env ( "CARGO" , cargo_exe ( ) )
373
445
. 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
+ "# ] ] )
382
452
. run ( ) ;
383
453
}
0 commit comments