-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake_on_files.sh
executable file
·54 lines (41 loc) · 1.11 KB
/
flake_on_files.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
source ./print_frequency_table.sh
# Default values
directory="."
save_outputs=false
# Parse options
while getopts ":d:h" opt; do
case $opt in
h)
echo "Usage: $0 [-d directory] [-h]"
echo " -d: Specify the directory where the jest JSON files reside (default: current directory)"
echo " -h: Display this help message"
exit
;;
d)
directory="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
# Initialize failures array
failures=()
echo "$directory/*.json"
for file in "$directory"/*.json; do
jest_output=$(cat "$file")
if echo "$jest_output" | jq -e '.testResults[].assertionResults[] | select(.status=="failed")' >/dev/null; then
failing_tests=$(echo "$jest_output" | jq -r '.testResults[].assertionResults[] | select(.status=="failed") | .fullName')
readarray -t failing_tests_collection <<<"$failing_tests"
for failure in "${failing_tests_collection[@]}"; do
failures+=("$failure")
done
fi
done
print_frequency_table "${failures[@]}"