@@ -46,6 +46,21 @@ fn alternate_arch() -> &'static str {
46
46
}
47
47
}
48
48
49
+ fn host ( ) -> String {
50
+ let platform = match env:: consts:: OS {
51
+ "linux" => "unknown-linux-gnu" ,
52
+ "macos" => "apple-darwin" ,
53
+ "windows" => "pc-windows-msvc" ,
54
+ _ => unreachable ! ( ) ,
55
+ } ;
56
+ let arch = match env:: consts:: ARCH {
57
+ "x86" => "i686" ,
58
+ "x86_64" => "x86_64" ,
59
+ _ => unreachable ! ( ) ,
60
+ } ;
61
+ format ! ( "{}-{}" , arch, platform)
62
+ }
63
+
49
64
test ! ( simple_cross {
50
65
if disabled( ) { return }
51
66
@@ -464,14 +479,65 @@ test test_foo ... ok
464
479
465
480
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
466
481
482
+ " , compiling = COMPILING , running = RUNNING , foo = p. url( ) , triple = target,
483
+ doctest = DOCTEST ) ) ) ;
484
+ } ) ;
485
+
486
+ test ! ( no_cross_doctests {
487
+ if disabled( ) { return }
488
+
489
+ let p = project( "foo" )
490
+ . file( "Cargo.toml" , r#"
491
+ [project]
492
+ name = "foo"
493
+ authors = []
494
+ version = "0.0.0"
495
+ "# )
496
+ . file( "src/lib.rs" , r#"
497
+ //! ```
498
+ //! extern crate foo;
499
+ //! assert!(true);
500
+ //! ```
501
+ "# ) ;
502
+
503
+ let host_output = format!( "\
504
+ {compiling} foo v0.0.0 ({foo})
505
+ {running} target[..]foo-[..]
506
+
507
+ running 0 tests
508
+
509
+ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
510
+
467
511
{doctest} foo
468
512
513
+ running 1 test
514
+ test _0 ... ok
515
+
516
+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
517
+
518
+ " , compiling = COMPILING , running = RUNNING , foo = p. url( ) , doctest = DOCTEST ) ;
519
+
520
+ assert_that( p. cargo_process( "test" ) ,
521
+ execs( ) . with_status( 0 )
522
+ . with_stdout( & host_output) ) ;
523
+
524
+ let target = host( ) ;
525
+ assert_that( p. cargo_process( "test" ) . arg( "--target" ) . arg( & target) ,
526
+ execs( ) . with_status( 0 )
527
+ . with_stdout( & host_output) ) ;
528
+
529
+ let target = alternate( ) ;
530
+ assert_that( p. cargo_process( "test" ) . arg( "--target" ) . arg( & target) ,
531
+ execs( ) . with_status( 0 )
532
+ . with_stdout( & format!( "\
533
+ {compiling} foo v0.0.0 ({foo})
534
+ {running} target[..]{triple}[..]foo-[..]
535
+
469
536
running 0 tests
470
537
471
538
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
472
539
473
- " , compiling = COMPILING , running = RUNNING , foo = p. url( ) , triple = target,
474
- doctest = DOCTEST ) ) ) ;
540
+ " , compiling = COMPILING , running = RUNNING , foo = p. url( ) , triple = target) ) ) ;
475
541
} ) ;
476
542
477
543
test ! ( simple_cargo_run {
0 commit comments