Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Dec 2, 2023
1 parent 4aa2b18 commit 307e1fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
run: echo CARGO_CONTAINER_TESTS=1 >> $GITHUB_ENV
if: matrix.os == 'ubuntu-latest'

- run: cargo test -p cargo
- run: cargo test -p cargo -- uninstall_running_binary --nocapture
- name: Clear intermediate test output
run: ci/clean-test-output.sh

Expand Down
24 changes: 16 additions & 8 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2522,6 +2522,8 @@ fn assert_tracker_noexistence(key: &str) {

#[cargo_test]
fn uninstall_running_binary() {
use std::io::Write;

Package::new("foo", "0.0.1")
.file(
"Cargo.toml",
Expand All @@ -2534,12 +2536,18 @@ fn uninstall_running_binary() {
.file(
"src/main.rs",
r#"
use std::net::TcpStream;
use std::env::var;
use std::io::Read;
fn main() {
eprintln!(">>>>>>>>>>>>> 1");
std::net::TcpStream::connect(&std::env::var("ADDR").unwrap()[..]).unwrap();
for i in 0..2 {
eprintln!(">>>>>>>>>>>>> {i}");
TcpStream::connect(&var("ADDR").unwrap()[..])
.unwrap()
.read_to_end(&mut Vec::new())
.unwrap();
}
eprintln!(">>>>>>>>>>>>> 2");
std::net::TcpStream::connect(&std::env::var("ADDR").unwrap()[..]).unwrap();
eprintln!(">>>>>>>>>>>>> 3");
}
"#,
)
Expand Down Expand Up @@ -2577,14 +2585,14 @@ fn uninstall_running_binary() {
{
// Ensure foo is running before the first `cargo uninstall` call
eprintln!(">>>>>>>>>>>>> main 1");
l.accept().unwrap();
l.accept().unwrap().0.write_all(&[1]).unwrap();
eprintln!(">>>>>>>>>>>>> main 2");
cargo_process("uninstall foo")
.with_status(101)
.with_stderr_contains("[ERROR] failed to remove file `[CWD]/home/.cargo/bin/foo[EXE]`")
.run();
// Ensure foo is stopped before the second `cargo uninstall` call
l.accept().unwrap();
l.accept().unwrap().0.write_all(&[1]).unwrap();
eprintln!(">>>>>>>>>>>>> main 3");
t.join().unwrap();
eprintln!(">>>>>>>>>>>>> main 4");
Expand All @@ -2597,12 +2605,12 @@ fn uninstall_running_binary() {
{
// Ensure foo is running before the first `cargo uninstall` call
eprintln!(">>>>>>>>>>>>> main 1");
l.accept().unwrap();
l.accept().unwrap().0.write_all(&[1]).unwrap();
eprintln!(">>>>>>>>>>>>> main 2");
cargo_process("uninstall foo")
.with_stderr("[REMOVING] [CWD]/home/.cargo/bin/foo[EXE]")
.run();
l.accept().unwrap();
l.accept().unwrap().0.write_all(&[1]).unwrap();
eprintln!(">>>>>>>>>>>>> main 3");
t.join().unwrap();
eprintln!(">>>>>>>>>>>>> main 4");
Expand Down

0 comments on commit 307e1fd

Please sign in to comment.