-
Notifications
You must be signed in to change notification settings - Fork 5
🧹 Refactor duplicated bash test helper variables and check function #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| PASS=0 | ||||||||||||||||||||||||||||||||||||||
| FAIL=0 | ||||||||||||||||||||||||||||||||||||||
| TOTAL=0 | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| check() { | ||||||||||||||||||||||||||||||||||||||
| TOTAL=$((TOTAL + 1)) | ||||||||||||||||||||||||||||||||||||||
| if eval "$2" >/dev/null 2>&1; then | ||||||||||||||||||||||||||||||||||||||
| PASS=$((PASS + 1)) | ||||||||||||||||||||||||||||||||||||||
| echo " PASS: $1" | ||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||
| FAIL=$((FAIL + 1)) | ||||||||||||||||||||||||||||||||||||||
| echo " FAIL: $1" | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When a test fails, it is extremely helpful to see the actual error output or stdout of the failed command to diagnose the issue immediately. Currently, both stdout and stderr are completely silenced via We can capture the output and print it indented only when the command fails, without cluttering the output of passing tests.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that
test_helper.shis sourced and provides a robustcheckfunction, we can simplifycheck_versionand eliminate the duplicated test-tracking (TOTAL,PASS,FAIL) and reporting logic.You can refactor
check_versionto leverage the sharedcheckhelper:This keeps the test cases clean while fully centralizing the test execution and counter logic.