Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TAP reports can't be appended if there are failed tests #2095

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions integration/tests_ok/html.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Set-StrictMode -Version latest
$ErrorActionPreference = 'Stop'

# Some tests are failing but we want to continue until the end
$ErrorActionPreference = "Continue"
hurl --test `
--report-html build\tmp\ `
--glob "tests_ok\test.*.hurl"
Expand Down
2 changes: 2 additions & 0 deletions integration/tests_ok/html.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash
set -Eeuo pipefail

# Some tests are failing but we want to continue until the end
set +euo pipefail
hurl --test \
--report-html build/ \
--glob "tests_ok/test.*.hurl"
Expand Down
25 changes: 16 additions & 9 deletions integration/tests_ok/junit.err.pattern
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
tests_ok~test.1.hurl: Running [1/2]
tests_ok~test.1.hurl: Success (1 request(s) in ~~~ ms)
tests_ok~test.2.hurl: Running [2/2]
tests_ok~test.2.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/test.1.hurl: Running [1/2]
tests_ok/test.1.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/test.2.hurl: Running [2/2]
error: Assert body value
--> tests_ok/test.2.hurl:8:1
|
8 | `Goodbye World!`
| ^^^^^^^^^^^^^^^^ actual value is <Hello World!>
|

tests_ok/test.2.hurl: Failure (2 request(s) in ~~~ ms)
--------------------------------------------------------------------------------
Executed files: 2
Succeeded files: 2 (100.0%)
Failed files: 0 (0.0%)
Duration: ~ ms
Succeeded files: 1 (50.0%)
Failed files: 1 (50.0%)
Duration: ~~~ ms

tests_ok~test.3.hurl: Running [1/1]
tests_ok~test.3.hurl: Success (1 request(s) in ~~~ ms)
tests_ok/test.3.hurl: Running [1/1]
tests_ok/test.3.hurl: Success (1 request(s) in ~~~ ms)
--------------------------------------------------------------------------------
Executed files: 1
Succeeded files: 1 (100.0%)
Expand Down
7 changes: 6 additions & 1 deletion integration/tests_ok/junit.out.pattern
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite tests="2" errors="0" failures="0"><testcase id="tests_ok/test.1.hurl" name="tests_ok/test.1.hurl" time="~~~" /><testcase id="tests_ok/test.2.hurl" name="tests_ok/test.2.hurl" time="~~~" /></testsuite><testsuite tests="1" errors="0" failures="0"><testcase id="tests_ok/test.3.hurl" name="tests_ok/test.3.hurl" time="~~~" /></testsuite></testsuites>
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite tests="2" errors="0" failures="1"><testcase id="tests_ok/test.1.hurl" name="tests_ok/test.1.hurl" time="~~~" /><testcase id="tests_ok/test.2.hurl" name="tests_ok/test.2.hurl" time="~~~"><failure>Assert body value
--> tests_ok/test.2.hurl:8:1
|
8 | `Goodbye World!`
| ^^^^^^^^^^^^^^^^ actual value is &lt;Hello World!>
|</failure></testcase></testsuite><testsuite tests="1" errors="0" failures="0"><testcase id="tests_ok/test.3.hurl" name="tests_ok/test.3.hurl" time="~~~" /></testsuite></testsuites>
5 changes: 5 additions & 0 deletions integration/tests_ok/junit.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
set -Eeuo pipefail
rm -f build/result.xml

# test.2.hurl is KO but we want the script to continue until the end
set +eo pipefail
hurl --test --report-junit build/result.xml tests_ok/test.1.hurl tests_ok/test.2.hurl
hurl --test --report-junit build/result.xml tests_ok/test.3.hurl
set -Eeuo pipefail

cat build/result.xml
2 changes: 1 addition & 1 deletion integration/tests_ok/tap.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TAP version 13
1..3
ok 1 - tests_ok/test.1.hurl
ok 2 - tests_ok/test.2.hurl
not ok 2 - tests_ok/test.2.hurl
ok 3 - tests_ok/test.3.hurl
5 changes: 5 additions & 0 deletions integration/tests_ok/tap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ $ErrorActionPreference = 'Stop'
if (Test-Path build/result.tap) {
Remove-Item build/result.tap
}

# test.2.hurl is KO but we want the script to continue until the end
$ErrorActionPreference = 'Continue'
hurl --test --report-tap build/result.tap tests_ok/test.1.hurl tests_ok/test.2.hurl
hurl --test --report-tap build/result.tap tests_ok/test.3.hurl
$ErrorActionPreference = 'Stop'

Write-Host (Get-Content build/result.tap -Raw) -NoNewLine
5 changes: 5 additions & 0 deletions integration/tests_ok/tap.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/bash
set -Eeuo pipefail
rm -f build/result.tap

# test.2.hurl is KO but we want the script to continue until the end
set +eo pipefail
hurl --test --report-tap build/result.tap tests_ok/test.1.hurl tests_ok/test.2.hurl
hurl --test --report-tap build/result.tap tests_ok/test.3.hurl
set -Eeuo pipefail

cat build/result.tap
8 changes: 6 additions & 2 deletions integration/tests_ok/test.2.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/hello</span></span>
</span><span class="response"><span class="line"></span>
<span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
<span class="line"><span class="string">`Hello World!`</span></span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/hello</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
<span class="line"><span class="string">`Goodbye World!`</span></span>
</span></span></code></pre>
6 changes: 5 additions & 1 deletion integration/tests_ok/test.2.hurl
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
GET http://localhost:8000/hello

HTTP 200
`Hello World!`


GET http://localhost:8000/hello
HTTP 200
`Goodbye World!`
2 changes: 1 addition & 1 deletion integration/tests_ok/test.2.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}}]}
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"text","value":"Hello World!"}}},{"request":{"method":"GET","url":"http://localhost:8000/hello"},"response":{"status":200,"body":{"type":"text","value":"Goodbye World!"}}}]}
13 changes: 10 additions & 3 deletions integration/tests_ok/test.err.pattern
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
tests_ok~test.1.hurl: Running [1/3]
tests_ok~test.1.hurl: Success (1 request(s) in ~~~ ms)
tests_ok~test.2.hurl: Running [2/3]
tests_ok~test.2.hurl: Success (1 request(s) in ~~~ ms)
error: Assert body value
--> tests_ok~test.2.hurl:8:1
|
8 | `Goodbye World!`
| ^^^^^^^^^^^^^^^^ actual value is <Hello World!>~
|

tests_ok~test.2.hurl: Failure (2 request(s) in ~~~ ms)
tests_ok~test.3.hurl: Running [3/3]
tests_ok~test.3.hurl: Success (1 request(s) in ~~~ ms)
--------------------------------------------------------------------------------
Executed files: 3
Succeeded files: 3 (100.0%)
Failed files: 0 (0.0%)
Succeeded files: 2 (66.7%)
Failed files: 1 (33.3%)
Duration: ~~~ ms

1 change: 1 addition & 0 deletions integration/tests_ok/test.exit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
8 changes: 4 additions & 4 deletions packages/hurl/src/report/tap/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ fn write_tap_file(filename: &str, testcases: &[&Testcase]) -> Result<(), Error>
s.push_str(format!("{start}..{end}\n").as_str());

for (i, testcase) in testcases.iter().enumerate() {
let success = if testcase.success { "" } else { "not " };
let state = if testcase.success { "ok" } else { "not ok" };
let number = i + 1;
let description = &testcase.description;
s.push_str(format!("{success}ok {number} - {description}\n").as_str());
s.push_str(format!("{state} {number} - {description}\n").as_str());
}
match file.write_all(s.as_bytes()) {
Ok(_) => Ok(()),
Expand Down Expand Up @@ -149,7 +149,7 @@ mod tests {
let s = r#"1..3
ok 1 - tests_ok/test.1.hurl
ok 2 -tests_ok/test.2.hurl
nok 3 - tests_ok/test.3.hurl
not ok 3 - tests_ok/test.3.hurl

"#;
assert_eq!(
Expand Down Expand Up @@ -177,7 +177,7 @@ nok 3 - tests_ok/test.3.hurl
1..3
ok 1 - tests_ok/test.1.hurl
ok 2 -tests_ok/test.2.hurl
nok 3 - tests_ok/test.3.hurl
not ok 3 - tests_ok/test.3.hurl

"#;
assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions packages/hurl/src/report/tap/testcase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ impl Testcase {
let success = if line.starts_with("ok") {
line = &line[2..];
true
} else if line.starts_with("nok") {
line = &line[3..];
} else if line.starts_with("not ok") {
line = &line[6..];
false
} else {
return Err(Error {
Expand Down
Loading