1
1
//! Tests for proc-macros.
2
2
3
- #![ allow( deprecated) ]
4
-
3
+ use cargo_test_support:: prelude:: * ;
5
4
use cargo_test_support:: project;
5
+ use cargo_test_support:: str;
6
6
7
7
#[ cargo_test]
8
8
fn probe_cfg_before_crate_type_discovery ( ) {
@@ -207,7 +207,12 @@ fn impl_and_derive() {
207
207
. build ( ) ;
208
208
209
209
p. cargo ( "build" ) . run ( ) ;
210
- p. cargo ( "run" ) . with_stdout ( "X { success: true }" ) . run ( ) ;
210
+ p. cargo ( "run" )
211
+ . with_stdout_data ( str![ [ r#"
212
+ X { success: true }
213
+
214
+ "# ] ] )
215
+ . run ( ) ;
211
216
}
212
217
213
218
#[ cargo_test]
@@ -251,8 +256,21 @@ fn proc_macro_doctest() {
251
256
. build ( ) ;
252
257
253
258
foo. cargo ( "test" )
254
- . with_stdout_contains ( "test a ... ok" )
255
- . with_stdout_contains_n ( "test [..] ... ok" , 2 )
259
+ . with_stdout_data ( str![ [ r#"
260
+
261
+ running 1 test
262
+ test a ... ok
263
+
264
+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
265
+
266
+
267
+ running 1 test
268
+ test src/lib.rs - derive (line 8) ... ok
269
+
270
+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
271
+
272
+
273
+ "# ] ] )
256
274
. run ( ) ;
257
275
}
258
276
@@ -319,8 +337,21 @@ fn proc_macro_crate_type() {
319
337
. build ( ) ;
320
338
321
339
foo. cargo ( "test" )
322
- . with_stdout_contains ( "test tests::it_works ... ok" )
323
- . with_stdout_contains_n ( "test [..] ... ok" , 2 )
340
+ . with_stdout_data ( str![ [ r#"
341
+
342
+ running 1 test
343
+ test tests::it_works ... ok
344
+
345
+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
346
+
347
+
348
+ running 1 test
349
+ test src/lib.rs - (line 2) ... ok
350
+
351
+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
352
+
353
+
354
+ "# ] ] )
324
355
. run ( ) ;
325
356
}
326
357
@@ -342,8 +373,12 @@ fn proc_macro_crate_type_warning() {
342
373
. build ( ) ;
343
374
344
375
foo. cargo ( "check" )
345
- . with_stderr_contains (
346
- "[WARNING] library `foo` should only specify `proc-macro = true` instead of setting `crate-type`" )
376
+ . with_stderr_data ( str![ [ r#"
377
+ [WARNING] library `foo` should only specify `proc-macro = true` instead of setting `crate-type`
378
+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
379
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
380
+
381
+ "# ] ] )
347
382
. run ( ) ;
348
383
}
349
384
@@ -365,7 +400,12 @@ fn lib_plugin_unused_key_warning() {
365
400
. build ( ) ;
366
401
367
402
foo. cargo ( "check" )
368
- . with_stderr_contains ( "[WARNING] unused manifest key: lib.plugin" )
403
+ . with_stderr_data ( str![ [ r#"
404
+ [WARNING] unused manifest key: lib.plugin
405
+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
406
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
407
+
408
+ "# ] ] )
369
409
. run ( ) ;
370
410
}
371
411
@@ -387,9 +427,13 @@ fn proc_macro_crate_type_warning_plugin() {
387
427
. build ( ) ;
388
428
389
429
foo. cargo ( "check" )
390
- . with_stderr_contains (
391
- "[WARNING] library `foo` should only specify `proc-macro = true` instead of setting `crate-type`" )
392
- . run ( ) ;
430
+ . with_stderr_data ( str![ [ r#"
431
+ [WARNING] library `foo` should only specify `proc-macro = true` instead of setting `crate-type`
432
+ [CHECKING] foo v0.1.0 ([ROOT]/foo)
433
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
434
+
435
+ "# ] ] )
436
+ . run ( ) ;
393
437
}
394
438
395
439
#[ cargo_test]
@@ -410,14 +454,13 @@ fn proc_macro_crate_type_multiple() {
410
454
. build ( ) ;
411
455
412
456
foo. cargo ( "check" )
413
- . with_stderr (
414
- "\
415
- [ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
457
+ . with_stderr_data ( str![ [ r#"
458
+ [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
416
459
417
460
Caused by:
418
461
cannot mix `proc-macro` crate type with others
419
- " ,
420
- )
462
+
463
+ "# ] ] )
421
464
. with_status ( 101 )
422
465
. run ( ) ;
423
466
}
@@ -508,19 +551,21 @@ fn proc_macro_built_once() {
508
551
. file ( "the-macro/src/lib.rs" , "" )
509
552
. build ( ) ;
510
553
p. cargo ( "build --verbose" )
511
- . with_stderr_unordered (
512
- " \
554
+ . with_stderr_data (
555
+ str! [ [ r#"
513
556
[LOCKING] 3 packages to latest compatible versions
514
- [COMPILING] the-macro [..]
557
+ [COMPILING] the-macro v0.1.0 ([ROOT]/foo/the-macro)
515
558
[RUNNING] `rustc --crate-name the_macro [..]`
516
- [COMPILING] b [..]
559
+ [COMPILING] b v0.1.0 ([ROOT]/foo/b)
517
560
[RUNNING] `rustc --crate-name b [..]`
518
- [COMPILING] a [..]
561
+ [COMPILING] a v0.1.0 ([ROOT]/foo/a)
519
562
[RUNNING] `rustc --crate-name build_script_build [..]`
520
- [RUNNING] `[..] build[..] script[..] build[..] `
563
+ [RUNNING] `[ROOT]/foo/target/debug/ build/a-[HASH]/build- script- build`
521
564
[RUNNING] `rustc --crate-name a [..]`
522
- [FINISHED] [..]
523
- " ,
565
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
566
+
567
+ "# ] ]
568
+ . unordered ( ) ,
524
569
)
525
570
. run ( ) ;
526
571
}
0 commit comments