Skip to content

Separation of concerns #14

@rogard

Description

@rogard

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions