Skip to content

Commit 64daad5

Browse files
Move || true logic into assert function for cleaner test code
Co-authored-by: HectorCastelli <3715874+HectorCastelli@users.noreply.github.com>
1 parent d2b7619 commit 64daad5

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

scripts/tests.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ run_test_case() {
7373

7474
# Assert function: wrapper for run_test_case for compatibility
7575
# Usage: assert <description> <command>
76+
# Always returns 0 to allow tests to continue even on failure
7677
assert() {
77-
run_test_case "$@"
78+
run_test_case "$@" || true
7879
}
7980

8081
# Run common tests that apply to all profiles
@@ -86,38 +87,38 @@ run_common_tests() {
8687

8788
# Test 1: Check for syntax errors in install script
8889
if [ -f "$profile_dir/install.sh" ]; then
89-
run_test_case "Install script has no syntax errors" \
90-
"sh -n /dotfiles/profiles/$profile_name/install.sh" || true
90+
assert "Install script has no syntax errors" \
91+
"sh -n /dotfiles/profiles/$profile_name/install.sh"
9192
fi
9293

9394
# Test 2: Check for syntax errors in uninstall script
9495
if [ -f "$profile_dir/uninstall.sh" ]; then
95-
run_test_case "Uninstall script has no syntax errors" \
96-
"sh -n /dotfiles/profiles/$profile_name/uninstall.sh" || true
96+
assert "Uninstall script has no syntax errors" \
97+
"sh -n /dotfiles/profiles/$profile_name/uninstall.sh"
9798
fi
9899

99100
# Test 3: Install script exits successfully
100101
if [ -f "$profile_dir/install.sh" ]; then
101-
run_test_case "Install script exits successfully" \
102-
"cd /dotfiles/profiles/$profile_name && sh install.sh" || true
102+
assert "Install script exits successfully" \
103+
"cd /dotfiles/profiles/$profile_name && sh install.sh"
103104
fi
104105

105106
# Test 4: Install script is idempotent (runs twice successfully)
106107
if [ -f "$profile_dir/install.sh" ]; then
107-
run_test_case "Install script exits successfully on second run (idempotent)" \
108-
"cd /dotfiles/profiles/$profile_name && sh install.sh && sh install.sh" || true
108+
assert "Install script exits successfully on second run (idempotent)" \
109+
"cd /dotfiles/profiles/$profile_name && sh install.sh && sh install.sh"
109110
fi
110111

111112
# Test 5: Uninstall script exits successfully
112113
if [ -f "$profile_dir/uninstall.sh" ]; then
113-
run_test_case "Uninstall script exits successfully" \
114-
"cd /dotfiles/profiles/$profile_name && sh uninstall.sh" || true
114+
assert "Uninstall script exits successfully" \
115+
"cd /dotfiles/profiles/$profile_name && sh uninstall.sh"
115116
fi
116117

117118
# Test 6: Install then uninstall works
118119
if [ -f "$profile_dir/install.sh" ] && [ -f "$profile_dir/uninstall.sh" ]; then
119-
run_test_case "Uninstall script exits successfully after an install" \
120-
"cd /dotfiles/profiles/$profile_name && sh install.sh && sh uninstall.sh" || true
120+
assert "Uninstall script exits successfully after an install" \
121+
"cd /dotfiles/profiles/$profile_name && sh install.sh && sh uninstall.sh"
121122
fi
122123
}
123124

@@ -138,7 +139,7 @@ run_profile_tests() {
138139
} | tee -a "$REPORT_FILE"
139140

140141
# Run common tests for all profiles
141-
run_common_tests "$profile_name" || true
142+
run_common_tests "$profile_name"
142143

143144
# Run profile-specific tests if they exist
144145
if [ -f "$profile_dir/tests.sh" ]; then

0 commit comments

Comments
 (0)