Skip to content

Commit c4dd4ca

Browse files
cpudjc
authored andcommitted
chore: improve server integration test output.
This commit adds a few quality of life improvements to the server integration test: 1. The `--silent` curl arg is removed so that we can get diagnostic info from curl on stderr in the event of a failure. Our test only asserts on stdout content, which remains unaffected by this change. 2. If the `curl` command invocation status isn't success, we print the stderr content enabled by not using `--silent`. This will provide more diagnostic context to investigate the failure. 3. The `assert_eq` is changed to assert on a string value created from stdout instead of raw bytes. This is easier for humans to diff in the test output compared to a slice of byte values. Combined these changes should make it easier to diagnose future test failures without needing to iterate in CI.
1 parent 520be45 commit c4dd4ca

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/tests.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,17 @@ fn server() {
5555
let output = Command::new("curl")
5656
.arg("--insecure")
5757
.arg("--http1.0")
58-
.arg("--silent")
5958
.arg(format!("https://{}", addr))
6059
.output()
6160
.expect("cannot run curl");
6261

6362
srv.kill().unwrap();
6463

65-
println!("client output: {:?}", output.stdout);
66-
assert_eq!(output.stdout, b"Try POST /echo\n");
64+
if !output.status.success() {
65+
println!("curl stderr:\n{}", String::from_utf8_lossy(&output.stderr));
66+
}
67+
68+
assert_eq!(String::from_utf8_lossy(&*output.stdout), "Try POST /echo\n");
6769
}
6870

6971
#[test]

0 commit comments

Comments
 (0)