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,104 @@ 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
+
237
+ "# ] ] )
222
238
. run ( ) ;
223
239
p. cargo ( "run -j2" )
224
240
. env ( "PATH" , path)
225
241
. arg ( "--config" )
226
242
. arg ( config_value)
227
243
. 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
+ "# ] ] )
230
257
. run ( ) ;
231
258
p. cargo ( "test -j2" )
232
259
. 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
+ "# ] ] )
234
280
. run ( ) ;
235
281
p. cargo ( "test -j2" )
236
282
. env ( "PATH" , path)
237
283
. arg ( "--config" )
238
284
. arg ( config_value)
239
285
. 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
+ "# ] ] )
242
316
. run ( ) ;
243
317
}
244
318
@@ -371,13 +445,11 @@ all:
371
445
p. process ( make)
372
446
. env ( "CARGO" , cargo_exe ( ) )
373
447
. 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
+ "# ] ] )
382
454
. run ( ) ;
383
455
}
0 commit comments