@@ -2734,3 +2734,162 @@ fn uninstall_running_binary() {
2734
2734
2735
2735
"# ] ] ) . run ( ) ;
2736
2736
}
2737
+
2738
+ #[ cargo_test]
2739
+ fn dry_run ( ) {
2740
+ pkg ( "foo" , "0.0.1" ) ;
2741
+
2742
+ cargo_process ( "install foo" )
2743
+ . with_stderr_data ( str![ [ r#"
2744
+ [UPDATING] `dummy-registry` index
2745
+ [DOWNLOADING] crates ...
2746
+ [DOWNLOADED] foo v0.0.1 (registry `dummy-registry`)
2747
+ [INSTALLING] foo v0.0.1
2748
+ [COMPILING] foo v0.0.1
2749
+ [FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
2750
+ [INSTALLING] [ROOT]/home/.cargo/bin/foo[EXE]
2751
+ [INSTALLED] package `foo v0.0.1` (executable `foo[EXE]`)
2752
+ [WARNING] be sure to add `[ROOT]/home/.cargo/bin` to your PATH to be able to run the installed binaries
2753
+
2754
+ "# ] ] )
2755
+ . run ( ) ;
2756
+ assert_has_installed_exe ( paths:: cargo_home ( ) , "foo" ) ;
2757
+ }
2758
+
2759
+ #[ cargo_test]
2760
+ fn dry_run_incompatible_package ( ) {
2761
+ Package :: new ( "some-package-from-the-distant-future" , "0.0.1" )
2762
+ . rust_version ( "1.2345.0" )
2763
+ . file ( "src/main.rs" , "fn main() {}" )
2764
+ . publish ( ) ;
2765
+
2766
+ cargo_process ( "install some-package-from-the-distant-future" )
2767
+ . with_status ( 101 )
2768
+ . with_stderr_data ( str![ [ r#"
2769
+ [UPDATING] `dummy-registry` index
2770
+ [ERROR] cannot install package `some-package-from-the-distant-future 0.0.1`, it requires rustc 1.2345.0 or newer, while the currently active rustc version is [..]
2771
+
2772
+ "# ] ] )
2773
+ . run ( ) ;
2774
+ assert_has_not_installed_exe ( paths:: cargo_home ( ) , "some-package-from-the-distant-future" ) ;
2775
+ }
2776
+
2777
+ #[ cargo_test]
2778
+ fn dry_run_incompatible_package_dependecy ( ) {
2779
+ let p = project ( )
2780
+ . file (
2781
+ "Cargo.toml" ,
2782
+ r#"
2783
+ [package]
2784
+ name = "foo"
2785
+ version = "0.1.0"
2786
+ authors = []
2787
+
2788
+ [dependencies]
2789
+ some-package-from-the-distant-future = { path = "a" }
2790
+ "# ,
2791
+ )
2792
+ . file ( "src/main.rs" , "fn main() {}" )
2793
+ . file (
2794
+ "a/Cargo.toml" ,
2795
+ r#"
2796
+ [package]
2797
+ name = "some-package-from-the-distant-future"
2798
+ version = "0.1.0"
2799
+ authors = []
2800
+ rust-version = "1.2345.0"
2801
+ "# ,
2802
+ )
2803
+ . file ( "a/src/lib.rs" , "" )
2804
+ . build ( ) ;
2805
+
2806
+ cargo_process ( "install --path" )
2807
+ . arg ( p. root ( ) )
2808
+ . arg ( "foo" )
2809
+ . with_status ( 101 )
2810
+ . with_stderr_data ( str![ [ r#"
2811
+ [INSTALLING] foo v0.1.0 ([ROOT]/foo)
2812
+ [LOCKING] 1 package to latest compatible version
2813
+ [ERROR] failed to compile `foo v0.1.0 ([ROOT]/foo)`, intermediate artifacts can be found at `[ROOT]/foo/target`.
2814
+ To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
2815
+
2816
+ Caused by:
2817
+ rustc [..] is not supported by the following package:
2818
+ some-package-from-the-distant-future@0.1.0 requires rustc 1.2345.0
2819
+
2820
+ "# ] ] )
2821
+ . run ( ) ;
2822
+ assert_has_not_installed_exe ( paths:: cargo_home ( ) , "foo" ) ;
2823
+ }
2824
+
2825
+ #[ cargo_test]
2826
+ fn dry_run_upgrade ( ) {
2827
+ pkg ( "foo" , "0.0.1" ) ;
2828
+ cargo_process ( "install foo" ) . run ( ) ;
2829
+ assert_has_installed_exe ( paths:: cargo_home ( ) , "foo" ) ;
2830
+
2831
+ pkg ( "foo" , "0.0.2" ) ;
2832
+ cargo_process ( "install foo" )
2833
+ . with_stderr_data ( str![ [ r#"
2834
+ [UPDATING] `dummy-registry` index
2835
+ [DOWNLOADING] crates ...
2836
+ [DOWNLOADED] foo v0.0.2 (registry `dummy-registry`)
2837
+ [INSTALLING] foo v0.0.2
2838
+ [COMPILING] foo v0.0.2
2839
+ [FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
2840
+ [REPLACING] [ROOT]/home/.cargo/bin/foo[EXE]
2841
+ [REPLACED] package `foo v0.0.1` with `foo v0.0.2` (executable `foo[EXE]`)
2842
+ [WARNING] be sure to add `[ROOT]/home/.cargo/bin` to your PATH to be able to run the installed binaries
2843
+
2844
+ "# ] ] )
2845
+ . run ( ) ;
2846
+ assert_has_installed_exe ( paths:: cargo_home ( ) , "foo" ) ;
2847
+ }
2848
+
2849
+ #[ cargo_test]
2850
+ fn dry_run_remove_orphan ( ) {
2851
+ Package :: new ( "bar" , "1.0.0" )
2852
+ . file ( "src/bin/client.rs" , "fn main() {}" )
2853
+ . file ( "src/bin/server.rs" , "fn main() {}" )
2854
+ . publish ( ) ;
2855
+
2856
+ cargo_process ( "install bar" )
2857
+ . with_stderr_data ( str![ [ r#"
2858
+ [UPDATING] `dummy-registry` index
2859
+ [DOWNLOADING] crates ...
2860
+ [DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
2861
+ [INSTALLING] bar v1.0.0
2862
+ [COMPILING] bar v1.0.0
2863
+ [FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
2864
+ [INSTALLING] [ROOT]/home/.cargo/bin/client[EXE]
2865
+ [INSTALLING] [ROOT]/home/.cargo/bin/server[EXE]
2866
+ [INSTALLED] package `bar v1.0.0` (executables `client[EXE]`, `server[EXE]`)
2867
+ [WARNING] be sure to add `[ROOT]/home/.cargo/bin` to your PATH to be able to run the installed binaries
2868
+
2869
+ "# ] ] )
2870
+ . run ( ) ;
2871
+ assert_has_installed_exe ( paths:: cargo_home ( ) , "client" ) ;
2872
+ assert_has_installed_exe ( paths:: cargo_home ( ) , "server" ) ;
2873
+
2874
+ Package :: new ( "bar" , "2.0.0" )
2875
+ . file ( "src/bin/client.rs" , "fn main() {}" )
2876
+ . publish ( ) ;
2877
+
2878
+ cargo_process ( "install bar" )
2879
+ . with_stderr_data ( str![ [ r#"
2880
+ [UPDATING] `dummy-registry` index
2881
+ [DOWNLOADING] crates ...
2882
+ [DOWNLOADED] bar v2.0.0 (registry `dummy-registry`)
2883
+ [INSTALLING] bar v2.0.0
2884
+ [COMPILING] bar v2.0.0
2885
+ [FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s
2886
+ [REPLACING] [ROOT]/home/.cargo/bin/client[EXE]
2887
+ [REMOVING] executable `[ROOT]/home/.cargo/bin/server[EXE]` from previous version bar v1.0.0
2888
+ [REPLACED] package `bar v1.0.0` with `bar v2.0.0` (executable `client[EXE]`)
2889
+ [WARNING] be sure to add `[ROOT]/home/.cargo/bin` to your PATH to be able to run the installed binaries
2890
+
2891
+ "# ] ] )
2892
+ . run ( ) ;
2893
+ assert_has_installed_exe ( paths:: cargo_home ( ) , "client" ) ;
2894
+ assert_has_not_installed_exe ( paths:: cargo_home ( ) , "server" ) ;
2895
+ }
0 commit comments