You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: achieve zero dependencies and production-ready
- refactor: span across all script files
- test: remove package.json and git submodules, run Bats and its libraries inside Docker
- test: redesign test suite structure
- ci: remove local git hooks
- ci: change test.yml to test inside Docker. Testing environment closely resembles production environment
- docs: redesign the header structure. Stripped version control out of script files
Copy file name to clipboardExpand all lines: .github/prompts/test.prompt.md
+15-14Lines changed: 15 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
mode: "edit"
3
3
---
4
4
5
-
Your goal is to set up test cases for the Bash script that's also a command-line application (now refers to as "target script")
5
+
Your goal is to set up test cases for the Bash script that's also a command-line application (now referred to as "target script").
6
6
7
7
The chosen testing framework is Bash Automated Testing System or Bats, [bats-core](https://github.com/bats-core/bats-core).
8
8
@@ -13,27 +13,28 @@ The chosen testing auxiliary libraries are:
13
13
14
14
Requirements:
15
15
16
-
-`$BATS_SUITE_TMPDIR` is a temporary directory common to all tests of a suite. You MUST use `$BATS_SUITE_TMPDIR` to create files required by multiple tests.
17
-
-`$BATS_FILE_TMPDIR` is a temporary directory common to all tests of a test file. You MUST use `$BATS_FILE_TMPDIR` to create files required by multiple tests in the same test file.
18
-
-`$BATS_TEST_TMPDIR` is a temporary directory unique for each test. You MUST use `$BATS_TEST_TMPDIR` to create files required only for specific tests.
19
-
- You MUST clone the target script and create all mock dependencies in `$BATS_FILE_TMPDIR`, then you MUST change working directory to `$BATS_TEST_TMPDIR` inside `setup()` function then execute the target script with current working directory set to `$BATS_TEST_TMPDIR`. This is to ensure the state of the project directory remains intact after test execution.
20
-
- You MUST pay attention to not creating duplicate files and directories when provisioning in `$BATS_FILE_TMPDIR`.
21
-
- You MUST place the generated script inside `tests/` directory.
22
-
- You SHOULD NOT source the target script, unless the test case required internal function direct invocation.
23
-
- You MUST NOT use destructive operations (e.g. `mv -f`, `cp -f`, `ln -f`, ...).
24
-
- You MUST ignore backup original working directory at `setup()` function.
25
-
-
26
-
- You MUST leave `teardown()` function blank:
16
+
- If you're generating a new test script, you MUST place the script inside the `tests/` directory.
17
+
- You MUST use `$BATS_SUITE_TMPDIR` - a temporary directory common to all tests of a suite - to create files required by multiple tests.
18
+
- You MUST use `$BATS_FILE_TMPDIR` - a temporary directory common to all tests of a test file - to create files required by multiple tests in the same test file.
19
+
- You MUST use `$BATS_TEST_TMPDIR` - a temporary directory unique for each test - to create files required only for specific tests.
20
+
- You MUST clone the target script and create all mock dependencies in `$BATS_FILE_TMPDIR`. This is to ensure the state of the project directory remains intact after test execution.
21
+
- You MUST pay attention to not creating duplicate files and directories while doing provision to `$BATS_FILE_TMPDIR`.
22
+
- You MUST leave the `teardown()` function blank:
27
23
```bash
28
24
teardown() {
29
25
:
30
26
}
31
27
```
32
-
- You MUST avoid testcase duplication (i.e. 2 test cases testing the same logic) at all cost.
28
+
- You MUST avoid sourcing the target script, unless the testcase requires internal functiondirect invocation.
29
+
- You MUST avoid duplicating testcase (i.e. 2 test cases testing the same logic).
30
+
- You MUST avoid using destructive operations (e.g. `mv -f`, `cp -f`, `ln -f`, ...).
31
+
- You MUST avoid backing up the original working directory in the `setup()` function.
32
+
- You MUST avoid changing current working directory to `$BATS_TEST_TMPDIR`, instead, every file operation (copying, moving, changing owner, changing permissions, executing, etc.) MUST construct its own path using `$BATS_TEST_TMPDIR`.
0 commit comments