Skip to content

Commit ebd2c26

Browse files
authored
Merge pull request #42 from jkfran/v1.1.0
Fix tests and release v1.1.0
2 parents 55d9978 + de561b5 commit ebd2c26

File tree

6 files changed

+32
-26
lines changed

6 files changed

+32
-26
lines changed

.github/workflows/tests.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ on:
1010

1111
jobs:
1212
test:
13-
runs-on: macos-latest
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
1417
steps:
1518
- name: Checkout repository
1619
uses: actions/checkout@v2
@@ -22,4 +25,4 @@ jobs:
2225
override: true
2326

2427
- name: Run tests
25-
run: cargo test --all
28+
run: cargo test --tests -- --test-threads=1

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "killport"
3-
version = "1.0.0"
3+
version = "1.1.0"
44
authors = ["Francisco Jimenez Cabrera <jkfran@gmail.com>"]
55
edition = "2021"
66
license = "MIT"

snapcraft.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: killport
2-
version: "1.0.0"
2+
version: "1.1.0"
33
summary: A CLI tool to kill processes using specified ports
44
description: |
55
Killport is a command-line utility to find and kill processes listening on specified ports.

tests/integration_test.rs

+23-19
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();

tests/killport_unix_tests.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#![cfg(unix)]
22

33
use killport::cli::Mode;
4-
use killport::docker::DockerContainer;
5-
use killport::killport::{Killable, KillableType, KillportOperations};
4+
use killport::killport::{Killable, KillableType};
65
use killport::signal::KillportSignal;
76
use killport::unix::UnixProcess;
87
use mockall::*;

0 commit comments

Comments
 (0)