Skip to content

Commit a05043e

Browse files
committed
[PLUTO-1411] debug
1 parent def4055 commit a05043e

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

run-tool-tests.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ cd "$TOOL_DIR"
3636
# Convert absolute paths to relative paths in the output
3737
if [[ "$OSTYPE" == "darwin"* ]]; then
3838
# macOS
39-
sed -i '' 's|file:///Users/runner/work/codacy-cli-v2/|file:///|g' actual.sarif
39+
sed -i '' 's|file:///Users/runner/work/codacy-cli-v2/codacy-cli-v2/|file:///|g' actual.sarif
4040
elif [[ "$OSTYPE" == "msys"* ]] || [[ "$OSTYPE" == "cygwin"* ]]; then
4141
# Windows (Git Bash or Cygwin)
42-
sed -i 's|file:///D:/a/codacy-cli-v2/|file:///|g' actual.sarif
43-
sed -i 's|file:///C:/Users/runner/work/codacy-cli-v2/|file:///|g' actual.sarif
42+
sed -i 's|file:///D:/a/codacy-cli-v2/codacy-cli-v2/|file:///|g' actual.sarif
43+
sed -i 's|file:///C:/Users/runner/work/codacy-cli-v2/codacy-cli-v2/|file:///|g' actual.sarif
4444
# Convert Windows paths to forward slashes
4545
sed -i 's|\\|/|g' actual.sarif
4646
else
4747
# Linux
48-
sed -i 's|file:///home/runner/work/codacy-cli-v2/|file:///|g' actual.sarif
48+
sed -i 's|file:///home/runner/work/codacy-cli-v2/codacy-cli-v2/|file:///|g' actual.sarif
4949
fi
5050

5151
# Debug information
@@ -54,27 +54,28 @@ echo "Looking for expected.sarif in: $EXPECTED_SARIF"
5454
ls -la "$EXPECTED_SARIF" || echo "File not found or not accessible"
5555

5656
# Sort all fields in both files, handling null rules array
57-
jq --sort-keys 'if .runs[0].tool.driver.rules == null then . else .runs[0].tool.driver.rules |= sort_by(.id) end' "$EXPECTED_SARIF" > expected.sorted.json
58-
jq --sort-keys 'if .runs[0].tool.driver.rules == null then . else .runs[0].tool.driver.rules |= sort_by(.id) end' actual.sarif > actual.sorted.json
57+
echo "📊 Sorting SARIF outputs..."
58+
jq --sort-keys 'if .runs[0].tool.driver.rules == null then . else .runs[0].tool.driver.rules |= sort_by(.id) end' "$EXPECTED_SARIF" > expected.sorted.json || { echo "Failed to sort expected SARIF"; exit 1; }
59+
jq --sort-keys 'if .runs[0].tool.driver.rules == null then . else .runs[0].tool.driver.rules |= sort_by(.id) end' actual.sarif > actual.sorted.json || { echo "Failed to sort actual SARIF"; exit 1; }
5960

6061
# Normalize paths in both files
6162
if [[ "$OSTYPE" == "darwin"* ]]; then
6263
# macOS
63-
sed -i '' 's|"/Users/runner/work/codacy-cli-v2/|"/|g' expected.sorted.json
64-
sed -i '' 's|"/Users/runner/work/codacy-cli-v2/|"/|g' actual.sorted.json
64+
sed -i '' 's|"/Users/runner/work/codacy-cli-v2/codacy-cli-v2/|"/|g' expected.sorted.json
65+
sed -i '' 's|"/Users/runner/work/codacy-cli-v2/codacy-cli-v2/|"/|g' actual.sorted.json
6566
elif [[ "$OSTYPE" == "msys"* ]] || [[ "$OSTYPE" == "cygwin"* ]]; then
6667
# Windows (Git Bash or Cygwin)
67-
sed -i 's|"/D:/a/codacy-cli-v2/|"/|g' expected.sorted.json
68-
sed -i 's|"/C:/Users/runner/work/codacy-cli-v2/|"/|g' expected.sorted.json
69-
sed -i 's|"/D:/a/codacy-cli-v2/|"/|g' actual.sorted.json
70-
sed -i 's|"/C:/Users/runner/work/codacy-cli-v2/|"/|g' actual.sorted.json
68+
sed -i 's|"/D:/a/codacy-cli-v2/codacy-cli-v2/|"/|g' expected.sorted.json
69+
sed -i 's|"/C:/Users/runner/work/codacy-cli-v2/codacy-cli-v2/|"/|g' expected.sorted.json
70+
sed -i 's|"/D:/a/codacy-cli-v2/codacy-cli-v2/|"/|g' actual.sorted.json
71+
sed -i 's|"/C:/Users/runner/work/codacy-cli-v2/codacy-cli-v2/|"/|g' actual.sorted.json
7172
# Convert Windows paths to forward slashes
7273
sed -i 's|\\|/|g' expected.sorted.json
7374
sed -i 's|\\|/|g' actual.sorted.json
7475
else
7576
# Linux
76-
sed -i 's|"/home/runner/work/codacy-cli-v2/|"/|g' expected.sorted.json
77-
sed -i 's|"/home/runner/work/codacy-cli-v2/|"/|g' actual.sorted.json
77+
sed -i 's|"/home/runner/work/codacy-cli-v2/codacy-cli-v2/|"/|g' expected.sorted.json
78+
sed -i 's|"/home/runner/work/codacy-cli-v2/codacy-cli-v2/|"/|g' actual.sorted.json
7879
fi
7980

8081
# Run diff and capture its exit code
@@ -92,4 +93,5 @@ else
9293
fi
9394

9495
# Return to original directory
95-
cd ../../../../..
96+
echo "📂 Returning to original directory..."
97+
cd ../../../../.. || { echo "Failed to return to original directory"; exit 1; }

0 commit comments

Comments
 (0)