@@ -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
@@ -474,6 +489,63 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
474
489
doctest = DOCTEST ) ) ) ;
475
490
} ) ;
476
491
492
+ test ! ( no_cross_doctests {
493
+ if disabled( ) { return }
494
+
495
+ let p = project( "foo" )
496
+ . file( "Cargo.toml" , r#"
497
+ [project]
498
+ name = "foo"
499
+ authors = []
500
+ version = "0.0.0"
501
+ "# )
502
+ . file( "src/lib.rs" , r#"
503
+ //! ```
504
+ //! extern crate foo;
505
+ //! assert!(true);
506
+ //! ```
507
+ "# ) ;
508
+
509
+ let host_output = format!( "\
510
+ {compiling} foo v0.0.0 ({foo})
511
+ {running} target[..]foo-[..]
512
+
513
+ running 0 tests
514
+
515
+ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
516
+
517
+ {doctest} foo
518
+
519
+ running 1 test
520
+ test _0 ... ok
521
+
522
+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
523
+
524
+ " , compiling = COMPILING , running = RUNNING , foo = p. url( ) , doctest = DOCTEST ) ;
525
+
526
+ assert_that( p. cargo_process( "test" ) ,
527
+ execs( ) . with_status( 0 )
528
+ . with_stdout( & host_output) ) ;
529
+
530
+ let target = host( ) ;
531
+ assert_that( p. cargo_process( "test" ) . arg( "--target" ) . arg( & target) ,
532
+ execs( ) . with_status( 0 )
533
+ . with_stdout( & host_output) ) ;
534
+
535
+ let target = alternate( ) ;
536
+ assert_that( p. cargo_process( "test" ) . arg( "--target" ) . arg( & target) ,
537
+ execs( ) . with_status( 0 )
538
+ . with_stdout( & format!( "\
539
+ {compiling} foo v0.0.0 ({foo})
540
+ {running} target[..]{triple}[..]foo-[..]
541
+
542
+ running 0 tests
543
+
544
+ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
545
+
546
+ " , compiling = COMPILING , running = RUNNING , foo = p. url( ) , triple = target) ) ) ;
547
+ } ) ;
548
+
477
549
test ! ( simple_cargo_run {
478
550
if disabled( ) { return }
479
551
0 commit comments