hurl/integration/bin/format_to_json.sh

20 lines
399 B
Bash
Raw Normal View History

2020-11-05 22:25:14 +03:00
#!/bin/bash
2020-11-08 19:52:33 +03:00
# Export AST to json
2020-11-05 22:25:14 +03:00
set -u
2020-11-08 19:52:33 +03:00
set -eo pipefail
2020-11-05 22:25:14 +03:00
for hurl_file in "$@"; do
json_file="${hurl_file%.*}.json"
2020-11-15 11:51:01 +03:00
cmd="hurlfmt --output json $hurl_file"
2020-11-05 22:25:14 +03:00
echo "$cmd"
2020-11-15 11:51:01 +03:00
$cmd >/tmp/test.stdout
2020-11-05 22:25:14 +03:00
expected=$(cat "$json_file")
actual=$(cat /tmp/test.stdout)
if [ "$actual" != "$expected" ]; then
diff <(echo "$actual" ) <(echo "$expected")
exit 1
fi
done