-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added assertion macros and a way to parse unit test results and deter…
…mine failure/success
- Loading branch information
1 parent
d2910e2
commit 0a1d3a9
Showing
5 changed files
with
101 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
# File that contains the output log | ||
log_file="dev_os_output.log" | ||
|
||
# Initialize arrays to store test results | ||
passed_tests=() | ||
failed_tests=() | ||
|
||
# Check if log file exists | ||
if [[ ! -f "$log_file" ]]; then | ||
echo "Error: $log_file not found." | ||
exit 1 | ||
fi | ||
|
||
# Read the log file line by line | ||
while IFS= read -r line; do | ||
# Look for passed tests | ||
if [[ "$line" == *"Test"* && "$line" == *"passed"* ]]; then | ||
# Extract test name inside the quotes | ||
test_name=$(echo "$line" | sed -n 's/.*Test "\(.*\)" passed.*/\1/p') | ||
passed_tests+=("$test_name") | ||
|
||
# Look for failed tests | ||
elif [[ "$line" == *"Test"* && "$line" == *"failed"* ]]; then | ||
# Extract test name inside the quotes | ||
test_name=$(echo "$line" | sed -n 's/.*Test "\(.*\)" failed.*/\1/p') | ||
failed_tests+=("$test_name") | ||
fi | ||
done < "$log_file" | ||
|
||
# Print the results | ||
echo "Test Results:" | ||
echo "=============" | ||
|
||
# Print passed tests | ||
if [ ${#passed_tests[@]} -gt 0 ]; then | ||
echo -e "\nPassed Tests:" | ||
for test in "${passed_tests[@]}"; do | ||
echo " - $test" | ||
done | ||
else | ||
echo "No tests passed." | ||
fi | ||
|
||
# Print failed tests | ||
if [ ${#failed_tests[@]} -gt 0 ]; then | ||
echo -e "\nFailed Tests:" | ||
for test in "${failed_tests[@]}"; do | ||
echo " - $test" | ||
done | ||
else | ||
echo "No tests failed." | ||
fi | ||
|
||
# Exit with code 1 if any test failed, otherwise 0 | ||
if [ ${#failed_tests[@]} -gt 0 ]; then | ||
echo -e "\n[FAIL] Some tests failed." | ||
exit 1 | ||
else | ||
echo -e "\n[OK] All tests passed successfully." | ||
exit 0 | ||
fi |