From dbc51de167202fcf0cc1d61b268db9f2e9ac3694 Mon Sep 17 00:00:00 2001 From: jcamiel Date: Wed, 20 Jul 2022 13:11:54 +0200 Subject: [PATCH] Fix broken stdin. --- integration/ad_hoc.sh | 31 +++++++++++++++++-------------- packages/hurl/src/main.rs | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/integration/ad_hoc.sh b/integration/ad_hoc.sh index a047bef8da3..027cccb787b 100755 --- a/integration/ad_hoc.sh +++ b/integration/ad_hoc.sh @@ -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" diff --git a/packages/hurl/src/main.rs b/packages/hurl/src/main.rs index 6cc9c2d0c75..71fa57c49f6 100644 --- a/packages/hurl/src/main.rs +++ b/packages/hurl/src/main.rs @@ -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