1
1
use cargo:: core:: compiler:: Lto ;
2
2
use cargo_test_support:: registry:: Package ;
3
- use cargo_test_support:: { project, Project } ;
3
+ use cargo_test_support:: { basic_manifest , project, Project } ;
4
4
use std:: process:: Output ;
5
5
6
6
#[ cargo_test]
@@ -514,16 +514,19 @@ fn cdylib_and_rlib() {
514
514
p. cargo ( "test --release -v --manifest-path bar/Cargo.toml" )
515
515
. with_stderr_unordered (
516
516
"\
517
- [FRESH] registry v0.0.1
518
- [FRESH] registry-shared v0.0.1
517
+ [COMPILING] registry v0.0.1
518
+ [COMPILING] registry-shared v0.0.1
519
+ [RUNNING] `rustc --crate-name registry [..]-C embed-bitcode=no[..]
520
+ [RUNNING] `rustc --crate-name registry_shared [..]-C embed-bitcode=no[..]
519
521
[COMPILING] bar [..]
522
+ [RUNNING] `rustc --crate-name bar [..]--crate-type cdylib --crate-type rlib [..]-C embed-bitcode=no[..]
520
523
[RUNNING] `rustc --crate-name bar [..]-C embed-bitcode=no --test[..]
521
524
[RUNNING] `rustc --crate-name b [..]-C embed-bitcode=no --test[..]
522
525
[FINISHED] [..]
523
- [RUNNING] [..]
524
- [RUNNING] [..]
526
+ [RUNNING] [..]target/release/deps/bar-[..]
527
+ [RUNNING] [..]target/release/deps/b-[..]
525
528
[DOCTEST] bar
526
- [RUNNING] `rustdoc --crate-type cdylib --crate-type rlib --test [..]
529
+ [RUNNING] `rustdoc --crate-type cdylib --crate-type rlib --test [..]-C embed-bitcode=no[..]
527
530
" ,
528
531
)
529
532
. run ( ) ;
@@ -627,7 +630,7 @@ fn test_profile() {
627
630
[COMPILING] bar v0.0.1
628
631
[RUNNING] `rustc --crate-name bar [..]crate-type lib[..]
629
632
[COMPILING] foo [..]
630
- [RUNNING] `rustc --crate-name foo [..]--crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no [..]
633
+ [RUNNING] `rustc --crate-name foo [..]--crate-type lib --emit=dep-info,metadata,link -C linker-plugin-lto [..]
631
634
[RUNNING] `rustc --crate-name foo [..]--emit=dep-info,link -C lto=thin [..]--test[..]
632
635
[FINISHED] [..]
633
636
[RUNNING] [..]
@@ -680,7 +683,7 @@ fn dev_profile() {
680
683
[COMPILING] bar v0.0.1
681
684
[RUNNING] `rustc --crate-name bar [..]crate-type lib[..]
682
685
[COMPILING] foo [..]
683
- [RUNNING] `rustc --crate-name foo [..]--crate-type lib --emit=dep-info,metadata,link -C linker-plugin-lto [..]
686
+ [RUNNING] `rustc --crate-name foo [..]--crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no [..]
684
687
[RUNNING] `rustc --crate-name foo [..]--emit=dep-info,link -C embed-bitcode=no [..]--test[..]
685
688
[FINISHED] [..]
686
689
[RUNNING] [..]
@@ -689,3 +692,57 @@ fn dev_profile() {
689
692
" )
690
693
. run ( ) ;
691
694
}
695
+
696
+ #[ cargo_test]
697
+ fn doctest ( ) {
698
+ let p = project ( )
699
+ . file (
700
+ "Cargo.toml" ,
701
+ r#"
702
+ [package]
703
+ name = "foo"
704
+ version = "0.1.0"
705
+ edition = "2018"
706
+
707
+ [profile.release]
708
+ lto = true
709
+
710
+ [dependencies]
711
+ bar = { path = "bar" }
712
+ "# ,
713
+ )
714
+ . file (
715
+ "src/lib.rs" ,
716
+ r#"
717
+ /// Foo!
718
+ ///
719
+ /// ```
720
+ /// foo::foo();
721
+ /// ```
722
+ pub fn foo() { bar::bar(); }
723
+ "# ,
724
+ )
725
+ . file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "0.1.0" ) )
726
+ . file (
727
+ "bar/src/lib.rs" ,
728
+ r#"
729
+ pub fn bar() { println!("hi!"); }
730
+ "# ,
731
+ )
732
+ . build ( ) ;
733
+
734
+ p. cargo ( "test --doc --release -v" )
735
+ . with_stderr_contains ( "[..]`rustc --crate-name bar[..]-C embed-bitcode=no[..]" )
736
+ . with_stderr_contains ( "[..]`rustc --crate-name foo[..]-C embed-bitcode=no[..]" )
737
+ // embed-bitcode should be harmless here
738
+ . with_stderr_contains ( "[..]`rustdoc [..]-C embed-bitcode=no[..]" )
739
+ . run ( ) ;
740
+
741
+ // Try with bench profile.
742
+ p. cargo ( "test --doc --release -v" )
743
+ . env ( "CARGO_PROFILE_BENCH_LTO" , "true" )
744
+ . with_stderr_contains ( "[..]`rustc --crate-name bar[..]-C linker-plugin-lto[..]" )
745
+ . with_stderr_contains ( "[..]`rustc --crate-name foo[..]-C linker-plugin-lto[..]" )
746
+ . with_stderr_contains ( "[..]`rustdoc [..]-C lto[..]" )
747
+ . run ( ) ;
748
+ }
0 commit comments