3
3
use std:: fs:: { self , OpenOptions } ;
4
4
use std:: io:: prelude:: * ;
5
5
use std:: path:: Path ;
6
+ use std:: thread;
6
7
7
8
use cargo_test_support:: compare;
8
9
use cargo_test_support:: cross_compile;
@@ -11,10 +12,10 @@ use cargo_test_support::registry::{self, registry_path, Package};
11
12
use cargo_test_support:: {
12
13
basic_manifest, cargo_process, no_such_file_err_msg, project, project_in, symlink_supported, t,
13
14
} ;
14
- use cargo_util:: ProcessError ;
15
+ use cargo_util:: { ProcessBuilder , ProcessError } ;
15
16
16
17
use cargo_test_support:: install:: {
17
- assert_has_installed_exe, assert_has_not_installed_exe, cargo_home,
18
+ assert_has_installed_exe, assert_has_not_installed_exe, cargo_home, exe ,
18
19
} ;
19
20
use cargo_test_support:: paths:: { self , CargoPathExt } ;
20
21
use std:: env;
@@ -2508,7 +2509,17 @@ fn install_incompat_msrv() {
2508
2509
. with_status ( 101 ) . run ( ) ;
2509
2510
}
2510
2511
2511
- #[ cfg( windows) ]
2512
+ fn assert_tracker_noexistence ( key : & str ) {
2513
+ let v1_data: toml:: Value =
2514
+ toml:: from_str ( & fs:: read_to_string ( cargo_home ( ) . join ( ".crates.toml" ) ) . unwrap ( ) ) . unwrap ( ) ;
2515
+ let v2_data: serde_json:: Value =
2516
+ serde_json:: from_str ( & fs:: read_to_string ( cargo_home ( ) . join ( ".crates2.json" ) ) . unwrap ( ) )
2517
+ . unwrap ( ) ;
2518
+
2519
+ assert ! ( v1_data[ "v1" ] . get( key) . is_none( ) ) ;
2520
+ assert ! ( v2_data[ "installs" ] [ key] . is_null( ) ) ;
2521
+ }
2522
+
2512
2523
#[ cargo_test]
2513
2524
fn uninstall_running_binary ( ) {
2514
2525
Package :: new ( "foo" , "0.0.1" )
@@ -2553,24 +2564,33 @@ fn uninstall_running_binary() {
2553
2564
. run ( ) ;
2554
2565
assert_has_installed_exe ( cargo_home ( ) , "foo" ) ;
2555
2566
2556
- use cargo_util:: ProcessBuilder ;
2557
- use std:: thread;
2558
- let foo_bin = cargo_test_support:: install:: cargo_home ( )
2559
- . join ( "bin" )
2560
- . join ( cargo_test_support:: install:: exe ( "foo" ) ) ;
2561
-
2567
+ let foo_bin = cargo_home ( ) . join ( "bin" ) . join ( exe ( "foo" ) ) ;
2562
2568
let t = thread:: spawn ( || ProcessBuilder :: new ( foo_bin) . exec ( ) . unwrap ( ) ) ;
2569
+ let key = "foo 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" ;
2563
2570
2564
- cargo_process ( "uninstall foo" )
2565
- . with_status ( 101 )
2566
- . with_stderr_contains ( "[ERROR] failed to remove file `[CWD]/home/.cargo/bin/foo[EXE]`" )
2567
- . run ( ) ;
2568
- assert_has_installed_exe ( cargo_home ( ) , "foo" ) ;
2571
+ #[ cfg( windows) ]
2572
+ {
2573
+ cargo_process ( "uninstall foo" )
2574
+ . with_status ( 101 )
2575
+ . with_stderr_contains ( "[ERROR] failed to remove file `[CWD]/home/.cargo/bin/foo[EXE]`" )
2576
+ . run ( ) ;
2577
+ t. join ( ) . unwrap ( ) ;
2578
+ cargo_process ( "uninstall foo" )
2579
+ . with_stderr ( "[REMOVING] [CWD]/home/.cargo/bin/foo[EXE]" )
2580
+ . run ( ) ;
2581
+ } ;
2582
+
2583
+ #[ cfg( not( windows) ) ]
2584
+ {
2585
+ cargo_process ( "uninstall foo" )
2586
+ . with_stderr ( "[REMOVING] [CWD]/home/.cargo/bin/foo[EXE]" )
2587
+ . run ( ) ;
2588
+ t. join ( ) . unwrap ( ) ;
2589
+ } ;
2590
+
2591
+ assert_has_not_installed_exe ( cargo_home ( ) , "foo" ) ;
2592
+ assert_tracker_noexistence ( key) ;
2569
2593
2570
- t. join ( ) . unwrap ( ) ;
2571
- cargo_process ( "uninstall foo" )
2572
- . with_stderr ( "[REMOVING] [CWD]/home/.cargo/bin/foo[EXE]" )
2573
- . run ( ) ;
2574
2594
cargo_process ( "install foo" )
2575
2595
. with_stderr (
2576
2596
"\
0 commit comments