Skip to content

Commit

Permalink
. a
Browse files Browse the repository at this point in the history
Co-Authored-By: Jay Bazuzi <jay@bazuzi.com>
  • Loading branch information
nitsanavni and JayBazuzi committed Jan 28, 2025
1 parent dee5119 commit fda9b9b
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions bash/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,36 @@ default_diff_tool="code --diff"
diff_tool=$default_diff_tool

while getopts ":r:t:d:" opt; do
case $opt in
d) diff_tool=$OPTARG;;
r) received_text=$OPTARG;;
t) test_name=$OPTARG;;
\?) echo "Invalid option: -$OPTARG" >&2;;
esac
case $opt in
d) diff_tool=$OPTARG ;;
r) received_text=$OPTARG ;;
t) test_name=$OPTARG ;;
\?) echo "Invalid option: -$OPTARG" >&2 ;;
esac
done

received="$test_name.received"
approved="$test_name.approved"

if [ "$received_text" == "" ];
then
cat - > "$received"
if [ "$received_text" == "" ]; then
cat - >"$received"
else
echo "$received_text" > "$received"
echo "$received_text" >"$received"
fi

touch "$approved"

diff -q "$received" "$approved" > /dev/null \
&& (echo "test passed"; rm "$received") \
|| (echo "test failed";
diff -q "$received" "$approved" >/dev/null &&
(
echo "test passed"
rm "$received"
) ||
(
echo "test failed"
if [ -e /dev/tty ]; then
$diff_tool "$received" "$approved" </dev/tty
else
$diff_tool "$received" "$approved"
fi;
false)
fi
false
)

0 comments on commit fda9b9b

Please sign in to comment.