Skip to content

Commit f01975b

Browse files
committed
Add integration test for HURL_ERROR_FORMAT.
1 parent ae17e68 commit f01975b

File tree

11 files changed

+204
-11
lines changed

11 files changed

+204
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ will follow a redirection only for the second entry.
14901490
|------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
14911491
| <a href="#color" id="color"><code>--color</code></a> | Colorize standard output and standard error.<br><br>By default, Hurl outputs a prettified and colorized response. When redirected through pipes, standard streams are not colorized and color can be forced with this option.<br><br>Environment variables: HURL_COLOR<br><br>This is a cli-only option.<br> |
14921492
| <a href="#curl" id="curl"><code>--curl &lt;FILE&gt;</code></a> | Export each request to a list of curl commands.<br><br>This is a cli-only option.<br> |
1493-
| <a href="#error-format" id="error-format"><code>--error-format &lt;FORMAT&gt;</code></a> | Control the format of error message (short by default or long). When using long,<br>the response body is logged when there are errors.<br><br>This is a cli-only option.<br> |
1493+
| <a href="#error-format" id="error-format"><code>--error-format &lt;FORMAT&gt;</code></a> | Control the format of error message (short by default or long). When using long, the response body is logged when there are errors.<br><br>Environment variables: HURL_ERROR_FORMAT<br><br>This is a cli-only option.<br> |
14941494
| <a href="#include" id="include"><code>-i, --include</code></a> | Include the HTTP headers in the output<br><br>This is a cli-only option.<br> |
14951495
| <a href="#json" id="json"><code>--json</code></a> | Output each Hurl file result to JSON. The format is very closed to HAR format.<br><br>This is a cli-only option.<br> |
14961496
| <a href="#no-color" id="no-color"><code>--no-color</code></a> | Do not colorize standard output nor standard error.<br><br>Environment variables: HURL_NO_COLOR NO_COLOR<br><br>This is a cli-only option.<br> |

docs/manual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ will follow a redirection only for the second entry.
192192
|------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
193193
| <a href="#color" id="color"><code>--color</code></a> | Colorize standard output and standard error.<br><br>By default, Hurl outputs a prettified and colorized response. When redirected through pipes, standard streams are not colorized and color can be forced with this option.<br><br>Environment variables: HURL_COLOR<br><br>This is a cli-only option.<br> |
194194
| <a href="#curl" id="curl"><code>--curl &lt;FILE&gt;</code></a> | Export each request to a list of curl commands.<br><br>This is a cli-only option.<br> |
195-
| <a href="#error-format" id="error-format"><code>--error-format &lt;FORMAT&gt;</code></a> | Control the format of error message (short by default or long). When using long,<br>the response body is logged when there are errors.<br><br>This is a cli-only option.<br> |
195+
| <a href="#error-format" id="error-format"><code>--error-format &lt;FORMAT&gt;</code></a> | Control the format of error message (short by default or long). When using long, the response body is logged when there are errors.<br><br>Environment variables: HURL_ERROR_FORMAT<br><br>This is a cli-only option.<br> |
196196
| <a href="#include" id="include"><code>-i, --include</code></a> | Include the HTTP headers in the output<br><br>This is a cli-only option.<br> |
197197
| <a href="#json" id="json"><code>--json</code></a> | Output each Hurl file result to JSON. The format is very closed to HAR format.<br><br>This is a cli-only option.<br> |
198198
| <a href="#no-color" id="no-color"><code>--no-color</code></a> | Do not colorize standard output nor standard error.<br><br>Environment variables: HURL_NO_COLOR NO_COLOR<br><br>This is a cli-only option.<br> |

docs/manual/hurl.1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH hurl 1 "09 Mar 2026" "hurl 8.0.0-SNAPSHOT" " Hurl Manual"
1+
.TH hurl 1 "13 Mar 2026" "hurl 8.0.0-SNAPSHOT" " Hurl Manual"
22
.SH NAME
33

44
hurl - run and test HTTP requests.
@@ -332,8 +332,9 @@ This is a cli-only option.
332332

333333
.IP "--error-format <FORMAT> "
334334

335-
Control the format of error message (short by default or long). When using long,
336-
the response body is logged when there are errors.
335+
Control the format of error message (short by default or long). When using long, the response body is logged when there are errors.
336+
337+
Environment variables: HURL_ERROR_FORMAT
337338

338339
This is a cli-only option.
339340

docs/manual/hurl.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,9 @@ This is a cli-only option.
350350

351351
#### --error-format <FORMAT> {#error-format}
352352

353-
Control the format of error message (short by default or long). When using long,
354-
the response body is logged when there are errors.
353+
Control the format of error message (short by default or long). When using long, the response body is logged when there are errors.
354+
355+
Environment variables: HURL_ERROR_FORMAT
355356

356357
This is a cli-only option.
357358

docs/manual/hurlfmt.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH hurl 1 "09 Mar 2026" "hurl 8.0.0-SNAPSHOT" " Hurl Manual"
1+
.TH hurl 1 "13 Mar 2026" "hurl 8.0.0-SNAPSHOT" " Hurl Manual"
22
.SH NAME
33

44
hurlfmt - format Hurl files

docs/spec/options/hurl/error_format.option

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ value_parser: ["short", "long"]
66
help: Control the format of error messages
77
help_heading: Output options
88
cli_only: true
9+
env_var: HURL_ERROR_FORMAT
910
---
10-
Control the format of error message (short by default or long). When using long,
11-
the response body is logged when there are errors.
11+
Control the format of error message (short by default or long). When using long, the response body is logged when there are errors.
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
* Request can be run with the following curl command:
2+
* curl 'http://localhost:8000/error-format-long/html'
3+
4+
HTTP/1.1 200
5+
Content-Length: 45
6+
Content-Type: text/html; charset=utf-8
7+
Date: <<<.*?>>>
8+
Server: Flask Server
9+
Via: waitress
10+
11+
<html><head><title>Test</title></head></html>
12+
13+
error: Assert header value
14+
--> tests_failed/error_format_long/error_format_long.hurl:7:15
15+
|
16+
| GET http://localhost:8000/error-format-long/html
17+
| ...
18+
7 | Content-Type: text/html
19+
| ^^^^^^^^^ actual value is <text/html; charset=utf-8>
20+
|
21+
22+
error: Assert failure
23+
--> tests_failed/error_format_long/error_format_long.hurl:9:0
24+
|
25+
| GET http://localhost:8000/error-format-long/html
26+
| ...
27+
9 | xpath "string(//head/title)" == "Welcome!"
28+
| actual: string <Test>
29+
| expected: string <Welcome!>
30+
|
31+
32+
error: Assert failure
33+
--> tests_failed/error_format_long/error_format_long.hurl:11:0
34+
|
35+
| GET http://localhost:8000/error-format-long/html
36+
| ...
37+
11 | xpath "//title" count == 2
38+
| actual: integer <1>
39+
| expected: integer <2>
40+
|
41+
42+
* Request can be run with the following curl command:
43+
* curl 'http://localhost:8000/error-format-long/json'
44+
45+
HTTP/1.1 200
46+
Content-Length: 115
47+
Content-Type: application/json
48+
Date: <<<.*?>>>
49+
Server: Flask Server
50+
Via: waitress
51+
52+
{"books": [{"name": "Dune", "author": "Franck Herbert"}, {"name": "Les Mis\u00e9rables", "author": "Victor Hugo"}]}
53+
54+
error: Assert failure
55+
--> tests_failed/error_format_long/error_format_long.hurl:18:0
56+
|
57+
| GET http://localhost:8000/error-format-long/json
58+
| ...
59+
18 | jsonpath "$.books" count == 12
60+
| actual: integer <2>
61+
| expected: integer <12>
62+
|
63+
64+
* Request can be run with the following curl command:
65+
* curl 'http://localhost:8000/error-format-long/rfc-7807'
66+
67+
HTTP/1.1 200
68+
Content-Length: 258
69+
Content-Type: application/problem+json
70+
Date: <<<.*?>>>
71+
Server: Flask Server
72+
Via: waitress
73+
74+
{"type": "https://example.com/probs/out-of-credit", "title": "You do not have enough credit.", "detail": "Your current balance is 30, but that costs 50.", "instance": "/account/12345/msgs/abc", "balance": 30, "accounts": ["/account/12345", "/account/67890"]}
75+
76+
error: Assert failure
77+
--> tests_failed/error_format_long/error_format_long.hurl:26:0
78+
|
79+
| GET http://localhost:8000/error-format-long/rfc-7807
80+
| ...
81+
26 | jsonpath "$.title" == "You have enough credit."
82+
| actual: string <You do not have enough credit.>
83+
| expected: string <You have enough credit.>
84+
|
85+
86+
* Request can be run with the following curl command:
87+
* curl 'http://localhost:8000/error-format-long/fhir'
88+
89+
HTTP/1.1 200
90+
Content-Length: 902
91+
Content-Type: application/fhir+json
92+
Date: <<<.*?>>>
93+
Server: Flask Server
94+
Via: waitress
95+
96+
{"resourceType": "Practitioner", "id": "example", "text": {"status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n <p>Dr Adam Careful is a Referring Practitioner for Acme Hospital from 1-Jan 2012 to 31-Mar\n 2012</p>\n </div>"}, "identifier": [{"system": "http://www.acme.org/practitioners", "value": "23"}], "active": true, "name": [{"family": "Careful", "given": ["Adam"], "prefix": ["Dr"]}], "address": [{"use": "home", "line": ["534 Erewhon St"], "city": "PleasantVille", "state": "Vic", "postalCode": "3999"}], "qualification": [{"identifier": [{"system": "http://example.org/UniversityIdentifier", "value": "12345"}], "code": {"coding": [{"system": "http://terminology.hl7.org/CodeSystem/v2-0360/2.7", "code": "BS", "display": "Bachelor of Science"}], "text": "Bachelor of Science"}, "period": {"start": "1995"}, "issuer": {"display": "Example University"}}]}
97+
98+
error: Assert failure
99+
--> tests_failed/error_format_long/error_format_long.hurl:34:0
100+
|
101+
| GET http://localhost:8000/error-format-long/fhir
102+
| ...
103+
34 | jsonpath "$.id" == "foo"
104+
| actual: string <example>
105+
| expected: string <foo>
106+
|
107+
108+
* Request can be run with the following curl command:
109+
* curl 'http://localhost:8000/error-format-long/csv'
110+
111+
HTTP/1.1 200
112+
Content-Length: 726
113+
Content-Type: text/csv; charset=utf-8
114+
Date: <<<.*?>>>
115+
Server: Flask Server
116+
Via: waitress
117+
118+
"Year","Score","Title"
119+
1968,86,"Greetings"
120+
1970,17,"Bloody Mama"
121+
1970,73,"Hi, Mom!"
122+
1971,40,"Born to Win"
123+
1973,98,"Mean Streets"
124+
1973,88,"Bang the Drum Slowly"
125+
1974,97,"The Godfather, Part II"
126+
1976,41,"The Last Tycoon"
127+
1976,99,"Taxi Driver"
128+
1977,47,"1900"
129+
1977,67,"New York, New York"
130+
1978,93,"The Deer Hunter"
131+
1980,97,"Raging Bull"
132+
1981,75,"True Confessions"
133+
1983,90,"The King of Comedy"
134+
1984,89,"Once Upon a Time in America"
135+
1984,60,"Falling in Love"
136+
1985,98,"Brazil"
137+
1986,65,"The Mission"
138+
1987,00,"Dear America: Letters Home From Vietnam"
139+
1987,80,"The Untouchables"
140+
1987,78,"Angel Heart"
141+
1988,96,"Midnight Run"
142+
1989,64,"Jacknife"
143+
1989,47,"We're No Angels"
144+
1990,88,"Awakenings"
145+
1990,29,"Stanley & Iris"
146+
1990,96,"Goodfellas"
147+
148+
149+
error: Assert failure
150+
--> tests_failed/error_format_long/error_format_long.hurl:42:0
151+
|
152+
| GET http://localhost:8000/error-format-long/csv
153+
| ...
154+
42 | body split "\n" nth 9 split "," nth 2 == "\"Taxi\""
155+
| actual: string <"Taxi Driver">
156+
| expected: string <"Taxi">
157+
|
158+
159+
* Request can be run with the following curl command:
160+
* curl 'http://localhost:8000/error-format-long/bytes'
161+
162+
HTTP/1.1 200
163+
Content-Length: 4
164+
Content-Type: application/octet-stream
165+
Date: <<<.*?>>>
166+
Server: Flask Server
167+
Via: waitress
168+
169+
Bytes <deadbeef...>
170+
171+
error: Assert failure
172+
--> tests_failed/error_format_long/error_format_long.hurl:50:0
173+
|
174+
| GET http://localhost:8000/error-format-long/bytes
175+
| ...
176+
50 | bytes == hex,beef;
177+
| actual: bytes <deadbeef>
178+
| expected: bytes <beef>
179+
|
180+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Set-StrictMode -Version latest
2+
$ErrorActionPreference = 'Stop'
3+
4+
$env:HURL_ERROR_FORMAT = 'long'
5+
hurl --continue-on-error tests_failed/error_format_long/error_format_long.hurl
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -Eeuo pipefail
3+
4+
export HURL_ERROR_FORMAT=long
5+
hurl --continue-on-error tests_failed/error_format_long/error_format_long.hurl

0 commit comments

Comments
 (0)