Hello,
The following use-case, which is based on the documentation, breaks separation of concern due to the present of source:
$ cat use-case.sh
# shebang
source '/path/to/bach.sh'
test-rm-rf() {
# Write your test case
project_log_path=/tmp/project/logs
rm -rf "$project_log_ptah/" # Typo here!
}
test-rm-rf-assert() {
# Verify your test case
rm -rf / # This is the actual command to run on your host!
# DO NOT PANIC! By using Bach Testing Framework it won't actually run.
}
$ source use-case.sh
I tried this:
# bach.sh:
- # shebang
- trap .bach.on-exit EXIT
+ # trap .bach.on-exit EXIT
+ function bach-run-test() {
+ local test_file
+
+ test_file="${1:?Missing test file argument}"
+
+ source "$test_file"
+
+ .bach.run-tests
+ }
Such that we can now call:
$ source bach.sh
$ back-run-test use-case.sh
It appears to work, except the shell exits, but I haven't found the fix.
Hello,
The following use-case, which is based on the documentation, breaks separation of concern due to the present of
source:I tried this:
Such that we can now call:
It appears to work, except the shell exits, but I haven't found the fix.