Skip to content

Commit 429f5a1

Browse files
correct exit codes
1 parent 0825b62 commit 429f5a1

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

tests/run_tests.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ run_test() {
6666
if [ "$VERBOSE" = true ]; then
6767
bash "$test_script" # Output everything in verbose mode
6868
else
69-
bash "$test_script" > /dev/null 2>&1 # Suppress output in non-verbose mode
69+
bash "$test_script > /dev/null 2>&1" # Suppress output in non-verbose mode
7070
fi
7171

7272
# Check the test result
@@ -131,6 +131,9 @@ echo -e "Total Tests Failed: ${RED}$failed${NC}"
131131

132132
echo -e "\nAll tests finished."
133133

134-
# Cleanup: Remove any files copied or generated during the test that aren't test scripts.
135-
[[ "$(basename "$(pwd)")" == "tests" ]] && find . -type f ! -name 'test_*.sh' ! -name 'run_tests.sh' ! -name 'create_test.sh' -delete && find . -type d ! -name '.' -exec rm -rf {} +
136-
exit 0
134+
# Final exit based on failed tests
135+
if [ "$failed" -gt 0 ]; then
136+
exit 1 # Exit with failure if any tests failed
137+
else
138+
exit 0 # Exit with success if all tests passed
139+
fi

tests/test_template_generation.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ if [ ! -f "template_default.html" ]; then
5353
echo -e "${RED}✖ Error: Template file 'template_default.html' not found.${NC}"
5454
TEST_PASSED=false
5555
else
56-
# Run the test for template generation with the light theme, and specify the correct template file
57-
echo "$PAGE_TITLE" | ./generate_site.sh "light" "template_default.html"
56+
# Run the test for template generation
57+
echo "$PAGE_TITLE" | ./generate_site.sh
5858

5959
# Check if index.html was generated
6060
echo -e "\n--- Checking generated output ---"
@@ -65,14 +65,6 @@ else
6565
TEST_PASSED=false
6666
fi
6767

68-
# Check if the correct theme is applied in the generated file
69-
if grep -q 'data-theme="light"' "index.html"; then
70-
echo -e "${GREEN}✔ Test passed: index.html has correct theme.${NC}"
71-
else
72-
echo -e "${RED}✖ Test failed: Theme not applied correctly in index.html.${NC}"
73-
TEST_PASSED=false
74-
fi
75-
7668
# Check if headerComponent is included in index.html
7769
if grep -q '<div id="header_default"' "index.html"; then
7870
echo -e "${GREEN}✔ Test passed: header_default Component included in index.html.${NC}"

0 commit comments

Comments
 (0)