jkfran / killport

A command-line tool to easily kill processes running on a specified port.
MIT License
1.68k stars 37 forks source link

Integration test fails during package build due to stdout mismatch on compiled binary path #39

Closed ilmanzo closed 4 months ago

ilmanzo commented 4 months ago

Describe the bug some integration tests for release 1.0.0 fails due to exact match required. When building killport as a package, the build system runs test with binaries in a $TMP location, which is random.

As a workaround, tests could match the output vs a regular expression or check the exit value for success/failure.

To Reproduce Steps to reproduce the behavior:

  1. Run the command 'cargo test'
  2. See the error
running 5 tests
test test_basic_kill_no_process ... ok
Listening on port 8080
Listening on port 8082
test test_signal_handling ... FAILED
test test_dry_run_option ... FAILED
test test_basic_kill_process ... FAILED
test test_mode_option ... FAILED

failures:

---- test_signal_handling stdout ----
thread 'test_signal_handling' panicked at /home/abuild/rpmbuild/BUILD/rustc-1.78.0-src/library/core/src/ops/function.rs:250:5:
Unexpected stdout, failed diff original var
├── original: Successfully killed process 'mock_process' listening on port 8081
├── diff: 
│   ---     orig
│   +++     var
│   @@ -1 +1 @@
│   -Successfully killed process 'mock_process' listening on port 8081
│   +Successfully killed process '/tmp/.tmpqVZBXU/mock_process' listening on port 8081
└── var as str: Successfully killed process '/tmp/.tmpqVZBXU/mock_process' listening on port 8081

command=`"/home/abuild/rpmbuild/BUILD/killport-1.0.0/target/debug/killport" "8081" "-s" "sighup"`
code=0
stdout="Successfully killed process \'/tmp/.tmpqVZBXU/mock_process\' listening on port 8081\n"
stderr=""

---- test_dry_run_option stdout ----
thread 'test_dry_run_option' panicked at /home/abuild/rpmbuild/BUILD/rustc-1.78.0-src/library/core/src/ops/function.rs:250:5:
Unexpected stdout, failed diff original var
├── original: Would kill process 'mock_process' listening on port 8083
├── diff: 
│   ---     orig
│   +++     var
│   @@ -1 +1 @@
│   -Would kill process 'mock_process' listening on port 8083
│   +Would kill process '/tmp/.tmpa7B36F/mock_process' listening on port 8083
└── var as str: Would kill process '/tmp/.tmpa7B36F/mock_process' listening on port 8083

command=`"/home/abuild/rpmbuild/BUILD/killport-1.0.0/target/debug/killport" "8083" "--dry-run"`
code=0
stdout="Would kill process \'/tmp/.tmpa7B36F/mock_process\' listening on port 8083\n"
stderr=""

---- test_basic_kill_process stdout ----
thread 'test_basic_kill_process' panicked at /home/abuild/rpmbuild/BUILD/rustc-1.78.0-src/library/core/src/ops/function.rs:250:5:
Unexpected stdout, failed diff original var
├── original: Successfully killed process 'mock_process' listening on port 8080
├── diff: 
│   ---     orig
│   +++     var
│   @@ -1 +1 @@
│   -Successfully killed process 'mock_process' listening on port 8080
│   +Successfully killed process '/tmp/.tmpiDoOhp/mock_process' listening on port 8080
└── var as str: Successfully killed process '/tmp/.tmpiDoOhp/mock_process' listening on port 8080

command=`"/home/abuild/rpmbuild/BUILD/killport-1.0.0/target/debug/killport" "8080"`
code=0
stdout="Successfully killed process \'/tmp/.tmpiDoOhp/mock_process\' listening on port 8080\n"
stderr=""

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- test_mode_option stdout ----
thread 'test_mode_option' panicked at /home/abuild/rpmbuild/BUILD/rustc-1.78.0-src/library/core/src/ops/function.rs:250:5:
Unexpected stdout, failed diff original var
├── original: Successfully killed process 'mock_process' listening on port 8082
├── diff: 
│   ---     orig
│   +++     var
│   @@ -1 +1 @@
│   -Successfully killed process 'mock_process' listening on port 8082
│   +Successfully killed process '/tmp/.tmpUuW3bW/mock_process' listening on port 8082
└── var as str: Successfully killed process '/tmp/.tmpUuW3bW/mock_process' listening on port 8082

command=`"/home/abuild/rpmbuild/BUILD/killport-1.0.0/target/debug/killport" "8082" "--mode" "auto"`
code=0
stdout="Successfully killed process \'/tmp/.tmpUuW3bW/mock_process\' listening on port 8082\n"
stderr=""

Expected behavior No error in integration tests.

Environment (please complete the following information):

Additional context The build logs are available at

https://build.opensuse.org/package/live_build_log/home:amanzini:branches:utilities/killport/openSUSE_Factory/x86_64