Skip to content

Commit

Permalink
Fix broken stdin.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcamiel committed Jul 20, 2022
1 parent da7ad86 commit dbc51de
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions integration/ad_hoc.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
#!/bin/bash
# add more tests
# that can be easily added in tests_ok/ and tests_failed/
# Add ad-hoc tests that can't be easily added in tests_ok/ nor tests_failed/

function assert_equals() {
if [ "$1" != "$2" ]; then
echo "Error differs:"
echo "actual: $1"
echo "expected: $2"
exit 1
fi
}

echo "Check file not found error"
actual=$(hurl does_not_exist.hurl 2>&1)
expected="error: hurl: cannot access 'does_not_exist.hurl': No such file or directory"
if [ "$actual" != "$expected" ]; then
echo "Error differs:"
echo "actual: $actual"
echo "expected: $expected"
exit 1
fi
assert_equals "$actual" "$expected"

echo "Check multiple Hurl files"
actual=$(hurl tests_ok/hello.hurl tests_ok/hello.hurl)
expected="Hello World!Hello World!"
if [ "$actual" != "$expected" ]; then
echo "Error differs:"
echo "actual: $actual"
echo "expected: $expected"
exit 1
fi
assert_equals "$actual" "$expected"

echo "Check stdin"
actual=$(echo 'GET http://localhost:8000/hello' | hurl)
expected="Hello World!"
assert_equals "$actual" "$expected"
2 changes: 1 addition & 1 deletion packages/hurl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ fn main() {
let mut testcases = vec![];

for (current, filename) in filenames.iter().enumerate() {
if !Path::new(filename).exists() {
if filename != "-" && !Path::new(filename).exists() {
let message = format!(
"hurl: cannot access '{}': No such file or directory",
filename
Expand Down

0 comments on commit dbc51de

Please sign in to comment.