Skip to content

Commit

Permalink
refactor: update chrome step
Browse files Browse the repository at this point in the history
- enhance 'analyze-headless-tests-results' script
- call 'analyze-headless-tests-results' script in chrome step
  • Loading branch information
dlachaume committed Jan 30, 2024
1 parent 56aaaa4 commit 61a12e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
15 changes: 1 addition & 14 deletions .github/workflows/test-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,7 @@ jobs:
shell: bash
run: |
/usr/bin/google-chrome --headless --virtual-time-budget=120000 --dump-dom http://localhost:8080 > chrome-results.html
# Handle tests results
if grep -q 'title="FAILED"' chrome-results.html; then
failed_info=$(grep -oE '<div id="[^"]+" title="FAILED">([^<]+)' chrome-results.html | awk 'NR==1 {print substr($0, index($0,$4))}')
echo $failed_info
exit 1
elif grep -q 'title="OK"' chrome-results.html; then
grep -oE '<div id="[^"]+" title="OK">([^<]+)' chrome-results.html | awk '{print substr($0, index($0,$4))}'
echo "Success: all tests passed."
else
cat chrome-results.html
echo "No test results found. Check chrome-results.html output."
exit 1
fi
./analyze-headless-tests-results.sh chrome-results.html
- name: Run Firefox headless
working-directory: mithril-client-wasm
Expand Down
13 changes: 10 additions & 3 deletions mithril-client-wasm/analyze-headless-tests-results.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
FILENAME=$1

if [ ! -e "$FILENAME" ]; then
echo "Error: File '$FILENAME' not found."
exit 1
fi

echo "Analyzing headless test results from file: '$FILENAME'"
if grep -q 'title="FAILED"' "$FILENAME"; then
failed_info=$(grep -oE '<div id="[^"]+" title="FAILED">([^<]+)' "$FILENAME" | awk 'NR==1 {print substr($0, index($0,$4))}')
echo $failed_info
FAILED_INFO=$(grep -oE '<div id="[^"]+" title="FAILED">([^<]+)' "$FILENAME" | awk 'NR==1 {print substr($0, index($0,$4))}')
echo "$FAILED_INFO"
exit 1
elif grep -q 'title="OK"' "$FILENAME"; then
grep -oE '<div id="[^"]+" title="OK">([^<]+)' "$FILENAME" | awk '{print substr($0, index($0,$4))}'
echo "Success: all tests passed."
else
cat "$FILENAME"
echo "No test results found. Check $FILENAME output."
echo "No test results found. Check '$FILENAME' output."
exit 1
fi

0 comments on commit 61a12e2

Please sign in to comment.