Skip to content

Commit

Permalink
feat: report relative test paths
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Sep 15, 2024
1 parent b9930da commit 6ededd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions report-failure.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"

file=$1
name=$(basename "$file")
relativePath=$(realpath --relative-to="$(pwd)" "$file")

message=$4
if [ -z "$message" ]; then
message="check report"
fi

playground=$("$SCRIPT_PATH"/shorten-report.js "$2" "$3")
echo "❌ FAIL - $name. $message: $playground"
echo "❌ FAIL - $relativePath. $message: $playground"

# git diff non interactive
if [ -f "$1".approved.txt ]; then
Expand Down
13 changes: 9 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

SCRIPT_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
WORKING_DIR="$(pwd)"
FAILED=0

filter=''
Expand Down Expand Up @@ -41,7 +42,7 @@ while [ $# -gt 0 ]; do
shift
done

# check if profile is set
# check if shapesPath is set
if [ -z "$shapesPath" ]; then
printf "*************************************\n"
printf "* Error: --shapes argument missing. *\n"
Expand All @@ -53,13 +54,16 @@ loadFullShape() {
"$SCRIPT_PATH"/load-graph.js "$1" | "$SCRIPT_PATH"/pretty-print.js --prefixes "${prefixes[@]}"
}

echo $WORKING_DIR

# iterate over valid cases, run validation and monitor exit code
for file in $validCases; do
name=$(basename "$file")
relativePath=$(realpath --relative-to="$WORKING_DIR" "$file")

# check if filter is set and skip if not matching
if [ -n "$filter" ] && ! echo "$file" | grep -q "$filter"; then
echo "ℹ️SKIP - $name"
echo "ℹ️SKIP - $relativePath"
continue
fi

Expand All @@ -75,13 +79,14 @@ for file in $validCases; do
"$SCRIPT_PATH"/report-failure.sh "$file" "$(loadFullShape "$shapesPath")" "$(cat "$file")"
FAILED=1
else
echo "✅ PASS - $name"
echo "✅ PASS - $relativePath"
fi
done

# iterate over invalid cases
for file in $invalidCases; do
name=$(basename "$file")
relativePath=$(realpath --relative-to="$WORKING_DIR" "$file")

# skip if file does not exist
if [ ! -f "$file" ]; then
Expand All @@ -90,7 +95,7 @@ for file in $invalidCases; do

# check if pattern is set and skip if not matching
if [ -n "$filter" ] && ! echo "$file" | grep -q "$filter"; then
echo "ℹ️SKIP - $name"
echo "ℹ️SKIP - $relativePath"
continue
fi

Expand Down

0 comments on commit 6ededd6

Please sign in to comment.