hurl/integration/bin/lint.sh

52 lines
1.3 KiB
Bash
Raw Normal View History

2020-08-27 10:07:46 +03:00
#!/bin/bash
2020-11-08 19:52:33 +03:00
# Lint hurl file
#
2020-08-27 10:07:46 +03:00
set -u
EXITCODE_EXPECTED=1
for hurl_file in "$@"; do
set +e
2020-11-08 19:52:33 +03:00
cmd="hurlfmt --check $hurl_file"
echo "$cmd"
$cmd 2>/tmp/test.stderr >/tmp/test.stdout
2020-08-27 10:07:46 +03:00
EXITCODE_ACTUAL=$?
2020-11-08 19:52:33 +03:00
set -eo pipefail
2020-08-27 10:07:46 +03:00
if [ "$EXITCODE_ACTUAL" != "$EXITCODE_EXPECTED" ]; then
echo "ERROR Exit Code"
echo " Expected: $EXITCODE_EXPECTED"
echo " Actual: $EXITCODE_ACTUAL"
exit 1
fi
STDERR_ACTUAL=$(cat /tmp/test.stderr)
2020-09-19 19:09:30 +03:00
STDERR_EXPECTED=$(cat "${hurl_file%%.*}.err")
diff "${hurl_file%%.*}.err" /tmp/test.stderr
2020-08-27 10:07:46 +03:00
if [ "$STDERR_ACTUAL" != "$STDERR_EXPECTED" ]; then
echo "ERROR stderr"
echo " expected:"
echo "$STDERR_EXPECTED" | perl -pe 'chomp;s/.*/ $_\n/'
echo " actual:"
echo "$STDERR_ACTUAL" | perl -pe 'chomp;s/.*/ $_\n/'
exit 1
fi
2020-11-08 19:52:33 +03:00
cmd="hurlfmt $hurl_file"
echo "$cmd"
$cmd 2>/tmp/test.stderr >/tmp/test.stdout
LINT_ACTUAL=$(cat /tmp/test.stdout)
2020-09-19 19:09:30 +03:00
LINT_EXPECTED=$(cat "${hurl_file%%.*}.hurl.lint")
2020-08-27 10:07:46 +03:00
if [ "$LINT_ACTUAL" != "$LINT_EXPECTED" ]; then
echo "ERROR linting"
echo " expected:"
echo "$LINT_EXPECTED" | perl -pe 'chomp;s/.*/ $_\n/'
echo " actual:"
echo "$LINT_ACTUAL" | perl -pe 'chomp;s/.*/ $_\n/'
exit 1
fi
done