Skip to content

Commit de561b5

Browse files
committed
Use different ports
1 parent 036b319 commit de561b5

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration_test.rs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ fn test_basic_kill_no_process() {
3333
fn test_basic_kill_process() {
3434
let tempdir = tempdir().unwrap();
3535
let tempdir_path = tempdir.path();
36-
let mut child = start_listener_process(tempdir_path, 8081);
36+
let mut child = start_listener_process(tempdir_path, 8180);
3737
let mut cmd = Command::cargo_bin("killport").unwrap();
38-
let command = cmd.args(&["8081"]).assert().success();
39-
assert_match(&command.get_output().stdout, "Successfully killed", 8081);
38+
let command = cmd.args(&["8180"]).assert().success();
39+
assert_match(&command.get_output().stdout, "Successfully killed", 8180);
4040
// Clean up
4141
let _ = child.kill();
4242
let _ = child.wait();
@@ -49,10 +49,10 @@ fn test_signal_handling() {
4949
let tempdir_path = tempdir.path();
5050

5151
for signal in ["sighup", "sigint", "sigkill"].iter() {
52-
let mut child = start_listener_process(tempdir_path, 8082);
52+
let mut child = start_listener_process(tempdir_path, 8280);
5353
let mut cmd = Command::cargo_bin("killport").unwrap();
54-
let command = cmd.args(&["8082", "-s", signal]).assert().success();
55-
assert_match(&command.get_output().stdout, "Successfully killed", 8082);
54+
let command = cmd.args(&["8280", "-s", signal]).assert().success();
55+
assert_match(&command.get_output().stdout, "Successfully killed", 8280);
5656
// Clean up
5757
let _ = child.kill();
5858
let _ = child.wait();
@@ -65,45 +65,49 @@ fn test_mode_option() {
6565
let tempdir = tempdir().unwrap();
6666
let tempdir_path = tempdir.path();
6767

68-
for mode in ["auto", "process"].iter() {
69-
let mut child = start_listener_process(tempdir_path, 8083);
68+
for (i, mode) in ["auto", "process"].iter().enumerate() {
69+
let port = 8380 + i as u16;
70+
let mut child = start_listener_process(tempdir_path, port);
7071
let mut cmd = Command::cargo_bin("killport").unwrap();
71-
let command = cmd.args(&["8083", "--mode", mode]).assert().success();
72-
assert_match(&command.get_output().stdout, "Successfully killed", 8083);
72+
let command = cmd
73+
.args(&[&port.to_string(), "--mode", mode])
74+
.assert()
75+
.success();
76+
assert_match(&command.get_output().stdout, "Successfully killed", port);
7377
// Clean up
7478
let _ = child.kill();
7579
let _ = child.wait();
7680
}
7781

7882
let mut cmd = Command::cargo_bin("killport").unwrap();
79-
cmd.args(&["8083", "--mode", "auto"])
83+
cmd.args(&["8383", "--mode", "auto"])
8084
.assert()
8185
.success()
82-
.stdout(format!("No service found using port 8083\n"));
86+
.stdout(format!("No service found using port 8383\n"));
8387

8488
let mut cmd = Command::cargo_bin("killport").unwrap();
85-
cmd.args(&["8083", "--mode", "process"])
89+
cmd.args(&["8383", "--mode", "process"])
8690
.assert()
8791
.success()
88-
.stdout(format!("No process found using port 8083\n"));
92+
.stdout(format!("No process found using port 8383\n"));
8993

9094
let mut cmd = Command::cargo_bin("killport").unwrap();
91-
cmd.args(&["8083", "--mode", "container"])
95+
cmd.args(&["8383", "--mode", "container"])
9296
.assert()
9397
.success()
94-
.stdout(format!("No container found using port 8083\n"));
98+
.stdout(format!("No container found using port 8383\n"));
9599
}
96100

97101
/// Tests the `--dry-run` option to ensure no actual killing of the process.
98102
#[test]
99103
fn test_dry_run_option() {
100104
let tempdir = tempdir().unwrap();
101105
let tempdir_path = tempdir.path();
102-
let mut child = start_listener_process(tempdir_path, 8084);
106+
let mut child = start_listener_process(tempdir_path, 8480);
103107

104108
let mut cmd = Command::cargo_bin("killport").unwrap();
105-
let command = cmd.args(&["8084", "--dry-run"]).assert().success();
106-
assert_match(&command.get_output().stdout, "Would kill", 8084);
109+
let command = cmd.args(&["8480", "--dry-run"]).assert().success();
110+
assert_match(&command.get_output().stdout, "Would kill", 8480);
107111
// Clean up
108112
let _ = child.kill();
109113
let _ = child.wait();

0 commit comments

Comments
 (0)