@@ -4,6 +4,7 @@ use cargo_test_support::install::{
4
4
assert_has_installed_exe, assert_has_not_installed_exe, cargo_home,
5
5
} ;
6
6
use cargo_test_support:: is_nightly;
7
+ use cargo_test_support:: paths:: CargoPathExt ;
7
8
use cargo_test_support:: project;
8
9
9
10
#[ cargo_test]
@@ -910,7 +911,17 @@ fn dep_feature_in_cmd_line() {
910
911
)
911
912
. file ( "src/main.rs" , "fn main() {}" )
912
913
. file ( "examples/foo.rs" , "fn main() {}" )
913
- . file ( "tests/foo.rs" , "#[test]\n fn test() {}" )
914
+ . file (
915
+ "tests/foo.rs" ,
916
+ r#"
917
+ #[test]
918
+ fn bin_is_built() {
919
+ let s = format!("target/debug/foo{}", std::env::consts::EXE_SUFFIX);
920
+ let p = std::path::Path::new(&s);
921
+ assert!(p.exists(), "foo does not exist");
922
+ }
923
+ "# ,
924
+ )
914
925
. file (
915
926
"benches/foo.rs" ,
916
927
r#"
@@ -936,7 +947,9 @@ fn dep_feature_in_cmd_line() {
936
947
. file ( "bar/src/lib.rs" , "" )
937
948
. build ( ) ;
938
949
939
- p. cargo ( "build" ) . run ( ) ;
950
+ // This is a no-op
951
+ p. cargo ( "build" ) . with_stderr ( "[FINISHED] dev [..]" ) . run ( ) ;
952
+ assert ! ( !p. bin( "foo" ) . is_file( ) ) ;
940
953
941
954
// bin
942
955
p. cargo ( "build --bin=foo" )
@@ -967,19 +980,23 @@ Consider enabling them by passing, e.g., `--features=\"bar/a\"`
967
980
assert ! ( p. bin( "examples/foo" ) . is_file( ) ) ;
968
981
969
982
// test
983
+ // This is a no-op, since no tests are enabled
970
984
p. cargo ( "test" )
971
985
. with_stderr ( "[FINISHED] test [unoptimized + debuginfo] target(s) in [..]" )
972
986
. with_stdout ( "" )
973
987
. run ( ) ;
974
988
989
+ // Delete the target directory so this can check if the main.rs gets built.
990
+ p. build_dir ( ) . rm_rf ( ) ;
975
991
p. cargo ( "test --test=foo --features bar/a" )
976
992
. with_stderr (
977
993
"\
994
+ [COMPILING] bar v0.0.1 ([CWD]/bar)
978
995
[COMPILING] foo v0.0.1 ([CWD])
979
996
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
980
997
[RUNNING] target/debug/deps/foo-[..][EXE]" ,
981
998
)
982
- . with_stdout_contains ( "test test ... ok" )
999
+ . with_stdout_contains ( "test bin_is_built ... ok" )
983
1000
. run ( ) ;
984
1001
985
1002
// bench
0 commit comments