@@ -14,6 +14,8 @@ use cargo_test_support::install::{
1414 assert_has_installed_exe, assert_has_not_installed_exe, cargo_home,
1515} ;
1616use cargo_test_support:: paths;
17+ use std:: env;
18+ use std:: path:: PathBuf ;
1719
1820fn pkg ( name : & str , vers : & str ) {
1921 Package :: new ( name, vers)
@@ -129,6 +131,65 @@ fn multiple_pkgs() {
129131 assert_has_not_installed_exe ( cargo_home ( ) , "bar" ) ;
130132}
131133
134+ fn path ( ) -> Vec < PathBuf > {
135+ env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or_default ( ) ) . collect ( )
136+ }
137+
138+ #[ cargo_test]
139+ fn multiple_pkgs_path_set ( ) {
140+ // confirm partial failure results in 101 status code and does not have the
141+ // '[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries'
142+ // even if CARGO_HOME/bin is in the PATH
143+ pkg ( "foo" , "0.0.1" ) ;
144+ pkg ( "bar" , "0.0.2" ) ;
145+
146+ // add CARGO_HOME/bin to path
147+ let mut path = path ( ) ;
148+ path. push ( cargo_home ( ) . join ( "bin" ) ) ;
149+ let new_path = env:: join_paths ( path) . unwrap ( ) ;
150+ cargo_process ( "install foo bar baz" )
151+ . env ( "PATH" , new_path)
152+ . with_status ( 101 )
153+ . with_stderr (
154+ "\
155+ [UPDATING] `[..]` index
156+ [DOWNLOADING] crates ...
157+ [DOWNLOADED] foo v0.0.1 (registry `[CWD]/registry`)
158+ [INSTALLING] foo v0.0.1
159+ [COMPILING] foo v0.0.1
160+ [FINISHED] release [optimized] target(s) in [..]
161+ [INSTALLING] [CWD]/home/.cargo/bin/foo[EXE]
162+ [INSTALLED] package `foo v0.0.1` (executable `foo[EXE]`)
163+ [DOWNLOADING] crates ...
164+ [DOWNLOADED] bar v0.0.2 (registry `[CWD]/registry`)
165+ [INSTALLING] bar v0.0.2
166+ [COMPILING] bar v0.0.2
167+ [FINISHED] release [optimized] target(s) in [..]
168+ [INSTALLING] [CWD]/home/.cargo/bin/bar[EXE]
169+ [INSTALLED] package `bar v0.0.2` (executable `bar[EXE]`)
170+ [ERROR] could not find `baz` in registry `[..]` with version `*`
171+ [SUMMARY] Successfully installed foo, bar! Failed to install baz (see error(s) above).
172+ [ERROR] some crates failed to install
173+ " ,
174+ )
175+ . run ( ) ;
176+ assert_has_installed_exe ( cargo_home ( ) , "foo" ) ;
177+ assert_has_installed_exe ( cargo_home ( ) , "bar" ) ;
178+
179+ cargo_process ( "uninstall foo bar" )
180+ . with_stderr (
181+ "\
182+ [REMOVING] [CWD]/home/.cargo/bin/foo[EXE]
183+ [REMOVING] [CWD]/home/.cargo/bin/bar[EXE]
184+ [SUMMARY] Successfully uninstalled foo, bar!
185+ " ,
186+ )
187+ . run ( ) ;
188+
189+ assert_has_not_installed_exe ( cargo_home ( ) , "foo" ) ;
190+ assert_has_not_installed_exe ( cargo_home ( ) , "bar" ) ;
191+ }
192+
132193#[ cargo_test]
133194fn pick_max_version ( ) {
134195 pkg ( "foo" , "0.1.0" ) ;
0 commit comments