@@ -2787,6 +2787,57 @@ to proceed despite [..]
2787
2787
git_project. cargo ( "package --no-verify" ) . run ( ) ;
2788
2788
}
2789
2789
2790
+ #[ cargo_test]
2791
+ fn default_not_master ( ) {
2792
+ let project = project ( ) ;
2793
+
2794
+ // Create a repository with a `master` branch, but switch the head to a
2795
+ // branch called `main` at the same time.
2796
+ let ( git_project, repo) = git:: new_repo ( "dep1" , |project| {
2797
+ project
2798
+ . file ( "Cargo.toml" , & basic_lib_manifest ( "dep1" ) )
2799
+ . file ( "src/lib.rs" , "pub fn foo() {}" )
2800
+ } ) ;
2801
+ let head_id = repo. head ( ) . unwrap ( ) . target ( ) . unwrap ( ) ;
2802
+ let head = repo. find_commit ( head_id) . unwrap ( ) ;
2803
+ repo. branch ( "main" , & head, false ) . unwrap ( ) ;
2804
+ repo. set_head ( "refs/heads/main" ) . unwrap ( ) ;
2805
+
2806
+ // Then create a commit on the new `main` branch so `master` and `main`
2807
+ // differ.
2808
+ git_project. change_file ( "src/lib.rs" , "pub fn bar() {}" ) ;
2809
+ git:: add ( & repo) ;
2810
+ git:: commit ( & repo) ;
2811
+
2812
+ let project = project
2813
+ . file (
2814
+ "Cargo.toml" ,
2815
+ & format ! (
2816
+ r#"
2817
+ [project]
2818
+ name = "foo"
2819
+ version = "0.5.0"
2820
+ [dependencies]
2821
+ dep1 = {{ git = '{}' }}
2822
+ "# ,
2823
+ git_project. url( )
2824
+ ) ,
2825
+ )
2826
+ . file ( "src/lib.rs" , "pub fn foo() { dep1::bar() }" )
2827
+ . build ( ) ;
2828
+
2829
+ project
2830
+ . cargo ( "build" )
2831
+ . with_stderr (
2832
+ "\
2833
+ [UPDATING] git repository `[..]`
2834
+ [COMPILING] dep1 v0.5.0 ([..])
2835
+ [COMPILING] foo v0.5.0 ([..])
2836
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" ,
2837
+ )
2838
+ . run ( ) ;
2839
+ }
2840
+
2790
2841
#[ cargo_test]
2791
2842
fn historical_lockfile_works ( ) {
2792
2843
let project = project ( ) ;
@@ -2899,6 +2950,67 @@ dependencies = [
2899
2950
project. cargo ( "build" ) . run ( ) ;
2900
2951
}
2901
2952
2953
+ #[ cargo_test]
2954
+ fn two_dep_forms ( ) {
2955
+ let project = project ( ) ;
2956
+
2957
+ let ( git_project, _repo) = git:: new_repo ( "dep1" , |project| {
2958
+ project
2959
+ . file ( "Cargo.toml" , & basic_lib_manifest ( "dep1" ) )
2960
+ . file ( "src/lib.rs" , "" )
2961
+ } ) ;
2962
+
2963
+ let project = project
2964
+ . file (
2965
+ "Cargo.toml" ,
2966
+ & format ! (
2967
+ r#"
2968
+ [project]
2969
+ name = "foo"
2970
+ version = "0.5.0"
2971
+ [dependencies]
2972
+ dep1 = {{ git = '{}', branch = 'master' }}
2973
+ a = {{ path = 'a' }}
2974
+ "# ,
2975
+ git_project. url( )
2976
+ ) ,
2977
+ )
2978
+ . file ( "src/lib.rs" , "" )
2979
+ . file (
2980
+ "a/Cargo.toml" ,
2981
+ & format ! (
2982
+ r#"
2983
+ [project]
2984
+ name = "a"
2985
+ version = "0.5.0"
2986
+ [dependencies]
2987
+ dep1 = {{ git = '{}' }}
2988
+ "# ,
2989
+ git_project. url( )
2990
+ ) ,
2991
+ )
2992
+ . file ( "a/src/lib.rs" , "" )
2993
+ . build ( ) ;
2994
+
2995
+ // This'll download the git repository twice, one with HEAD and once with
2996
+ // the master branch. Then it'll compile 4 crates, the 2 git deps, then
2997
+ // the two local deps.
2998
+ project
2999
+ . cargo ( "build" )
3000
+ . with_stderr (
3001
+ "\
3002
+ [UPDATING] [..]
3003
+ [UPDATING] [..]
3004
+ [COMPILING] [..]
3005
+ [COMPILING] [..]
3006
+ [COMPILING] [..]
3007
+ [COMPILING] [..]
3008
+ [FINISHED] [..]
3009
+ " ,
3010
+ )
3011
+ . run ( ) ;
3012
+ }
3013
+
2902
3014
#[ cargo_test]
2903
3015
fn metadata_master_consistency ( ) {
2904
3016
// SourceId consistency in the `cargo metadata` output when `master` is
0 commit comments