Skip to content

Commit 5a4a6e1

Browse files
committed
Merge branch 'dev' into beta
2 parents 6058297 + a2efb5a commit 5a4a6e1

File tree

6 files changed

+105
-55
lines changed

6 files changed

+105
-55
lines changed

.junie/guidelines.md

Lines changed: 93 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
1-
21
# Repository Guidelines
3-
4-
## General Requirements:
5-
- Don't repeat yourself. Use already implemented code such as:
6-
- `load_repo_main_dotenv.bash`
7-
- `import_dna_lib.bash`
8-
- `load_super_project_config.bash`
9-
- _N2ST_ library
10-
- _NBS_ library
11-
- Path management:
12-
- Case 1 › system wide:
13-
- via symlink `/usr/local/bin/dna``/path/to/dockerized-norlab-project/src/bin/dna`;
14-
- via `~/.bashrc``PATH=${PATH}:${DNA_PATH}:${NBS_PATH}:${N2ST_PATH}`.
15-
- Case 2 › manual load:
16-
- each super project can optionally use the env var `DNA_PATH`, `NBS_PATH` and `N2ST_PATH` define in `.env.dockerized-norlab-project`.
17-
2+
183
## Repository Organization
194
- `src/bin/dna` is the DNA application entrypoint
205
- `src/lib/` contain library files
@@ -25,49 +10,83 @@
2510
- `utilities/tmp/dockerized-norlab-project-mock` is use for cloning a fresh copy of a mock "super project" from https://github.com/norlab-ulaval/dockerized-norlab-project-mock.git on test execution.
2611
`dockerized-norlab-project-mock` is a mock of how a user would install and uses DNA. We refer to this as a "super project" or the "user side".
2712

28-
## Version Control
29-
- Never `git add` or `git commit` changes, all changes require explicit code review and acceptance by the codeowner.
13+
## General Instructions:
3014

31-
## Tests Requirements
32-
- In the context of testing:
33-
- the definition of _pass_ is that a test exit whitout error. Synomym: _green_, _successfull_;
34-
- the definition fo _done_ mean that all tests where executed and all tests passed.
15+
### Planning instructions
16+
- Always put plan ready for review in the `.junie/plans` directory.
17+
18+
### Coding instructions
19+
- Don't repeat yourself:
20+
- Use already implemented code such as:
21+
- `load_repo_main_dotenv.bash`
22+
- `import_dna_lib.bash`
23+
- `load_super_project_config.bash`
24+
- Leverage functionality provided by submodule such as _N2ST_ and _NBS_ library whenever possible.
25+
- Path management:
26+
- Case 1 › system wide:
27+
- via symlink `/usr/local/bin/dna``/path/to/dockerized-norlab-project/src/bin/dna`;
28+
- via `~/.bashrc``PATH=${PATH}:${DNA_PATH}:${NBS_PATH}:${N2ST_PATH}`.
29+
- Case 2 › manual load:
30+
- each super project can optionally use the env var `DNA_PATH`, `DNA_ROOT`, `NBS_PATH`, `N2ST_PATH` and others define in `.env.dockerized-norlab-project`.
31+
32+
### Version Control Instructions
33+
- Never `git add` or `git commit` changes, all changes require explicit code review and acceptance by the code owner.
3534

36-
### Testing Strategy
35+
## Testing Strategy Instructions
36+
- In the context of testing:
37+
- the definition of _pass_ is that a test exit without error. Synonym: _green_, _successful_;
38+
- the definition fo _done_ mean that all tests where executed and all required tests passed, i.e. tests are _green_.
3739
- Inspect the tested script/functions for business logic related error or implementation error. Propose correction before going forward if any.
38-
- Write tests who chalenge the intended functionality or behavior.
39-
- Write **Unit-tests** and/or **Integration tests**:
40-
- All new scripts or functionalities need to have (either or both):
41-
- **Unit-tests**:
42-
- Those are tests that check if the core expected behaviors are satisfy. It test a piece of code in a stand alone fashion.
43-
- Use [N2ST](https://github.com/norlab-ulaval/norlab-shell-script-tools) bats tests tools for unit-test (See `tests/run_bats_core_test_in_n2st.bash` script) and a corresponding bats unit-test `.bats` file in the `tests/tests_bats/` directory. N2ST Bats tests are running in a docker container in complete isolation with a copy of the source code.
44-
- **Integration tests**:
45-
- Those are test case where there is multiple script interacting whith each other or we want to assess execution from begining to end;
46-
- Those tests are devided in two categories:
47-
- Dryrun: either make use of a `--dry-run` flag implemented in the script or make use of the docker `--dry-run` flag;
48-
- Test: all other integration test case that are not dryrun.
49-
- Use [NBS](https://github.com/norlab-ulaval/norlab-build-system) tests tools for integration-test (See `tests/run_all_dryrun_and_tests_script.bash` script) and a corresponding `test_*` or `dryrun_*` script in the `tests/tests_dryrun_and_tests_scripts/` directory.
50-
- New integration test script must go in the `tests/tests_dryrun_and_tests_scripts/` directory.
51-
- Their should be at least one test file (`.bats` and/or `.bash`) per coresponding source code script.
5240
- Identify relevant test cases e.g., behavior validation, error handling, desired user feedback, ...
41+
- If the tested script implements helper functions (i.e., support function meant to be used by the main function), test those functions first.
42+
- Always execute all unit-tests and all integration tests before submitting and only submit when _done_.
43+
44+
## General Testing Instructions
45+
- Write tests who challenge the intended functionality or behavior.
5346
- Divide test file by test cases: one test function per test case.
54-
- If the tested script implement helper functions (i.e., support function meant to be used by the main function), test those functions first.
5547
- Provide a summary explanation of the test case:
5648
- What does it test for;
5749
- What's the test expected outcome (i.e, should it pass or fail);
5850
- If you do mock something, justify why.
59-
- All tests in the `tests/` directory must pass.
60-
- Always execute all unit-tests and all integration tests before submiting.
51+
- Their should be at least one test file per corresponding source code file.
52+
- Write **Unit-tests** and/or **Integration tests**:
53+
- All new scripts or functionalities need to have (either or both):
54+
- **Unit-tests**:
55+
- Those are tests that check if the core expected behaviors are satisfy. It test a piece of code in a stand alone fashion.
56+
- **Integration tests**:
57+
- Those are test case where there is multiple script interacting whith each other or we want to assess execution from beginning to end;
6158

59+
### General Mocking Instructions
60+
- Never mock the logic that is actually tested.
61+
- Copying the source code in a test instead of using the real one fall into the mocking category, don't do that.
62+
63+
### General Instructions On Tests Execution
64+
- Always run unit-tests before integration tests.
65+
- Never run integration tests if any unit-tests fail.
6266

63-
### Instruction On Mocking
67+
## Shell Script specific Testing Instructions
68+
All instructions in sections _General Testing Instructions_ plus the following:
69+
- All new scripts or functionalities need to have (either or both):
70+
- **Unit-tests**:
71+
- Use [N2ST](https://github.com/norlab-ulaval/norlab-shell-script-tools) bats tests tools for unit-test (See `tests/run_bats_core_test_in_n2st.bash` script) and a corresponding bats unit-test `.bats` file in the `tests/tests_bats/` directory. N2ST Bats tests are running in a docker container in complete isolation with a copy of the source code.
72+
- **Integration tests**:
73+
- Those tests are divided in two categories:
74+
- Dryrun: either make use of a `--dry-run` flag implemented in the script when available or make use of the docker `--dry-run` flag;
75+
- Test: all other integration test case that are not dryrun.
76+
- Use [NBS](https://github.com/norlab-ulaval/norlab-build-system) tests tools for integration-test (See `tests/run_all_dryrun_and_tests_script.bash` script) and a corresponding `test_*` or `dryrun_*` script in the `tests/tests_dryrun_and_tests_scripts/` directory.
77+
- New integration test script must go in the `tests/tests_dryrun_and_tests_scripts/` directory.
78+
- Their should be at least one test file (`.bats` and/or `.bash`) per corresponding source code file.
79+
80+
81+
### Shell Script specific Mocking Instructions
82+
All instructions in sections _General Mocking Instruction_ plus the following:
6483
- You can mock shell core command an docker command.
6584
- You can mock `docker [OPTIONS|COMMAND]` commands and `git [OPTIONS|COMMAND]` commands.
66-
- Don't mock the functions that are tested in the tested script.
6785
- Avoid mocking N2ST functions, at the exception of those in `${N2ST_PATH}/src/function_library/prompt_utilities.bash`. For example, instead of re-implementing `n2st::seek_and_modify_string_in_file`, just load the real one and test that the content of the file at `file_path` has been updated? You can find the real one in `${N2ST_PATH}/src/function_library/general_utilities.bash`.
6886
- Avoid mocking the `read` command. Instead use `echo 'y'` or `echo 'N'` for piping a keyboard input to the function who use the `read` command which in turn expect a single character, example: `run bash -c "echo 'y' | <the-tested-function>"`. Alternatively, use the `yes [n]` shell command which optionaly send [y|Y|yes] n time, example: `run bash -c "yes 2 | <the-tested-function>"`.
87+
- Use `timeouts 10 ` in integration tests that execute real scripts with mocked dependencies to prevent test hangs.
6988

70-
### Instruction On Bats Tests
89+
### Instructions On Bats Tests
7190
- Use bats framework `bats-file` helper library provide tools for temporary directory management, such as the `temp_make` and `temp_del` functions.
7291
Reference https://github.com/bats-core/bats-file?tab=readme-ov-file#working-with-temporary-directories
7392
- Use bats test function `assert_file_executable` and `assert_file_not_executable` to test executable.
@@ -80,8 +99,35 @@ Bats helper library documentation:
8099
- https://github.com/bats-core/bats-file
81100
- https://github.com/bats-core/bats-support
82101

83-
### Instruction On Tests Execution
102+
### Shell Script specific Instructions On Tests Execution
103+
All instructions in sections _General Instruction On Tests Execution_ plus the following:
84104
- Don't directly execute `.bats` files, instead execute from the repository root `bash ./tests/run_bats_core_test_in_n2st.bash tests/tests_bats/<bats-file-name>.bats`.
85-
- Don't set tests script in executable mode instead execute them with `bash <the-script-name>.bash`.
86-
- Always run unit-tests before integration tests.
87-
- Never run integration tests if any unit-tests fail.
105+
- Don't set tests script in executable mode, instead execute them with `bash <the-script-name>.bash`.
106+
107+
## Python Specific Testing Instructions
108+
All instructions in sections _General Testing Instructions_ plus the following:
109+
1. Place new tests in the appropriate subdirectory based on what you're testing
110+
2. Follow the existing naming conventions (`tests_*` for package, `test_*.py` for files, `test_*` for functions)
111+
3. Use pytest fixtures from conftest.py for common setup/teardown if exist in directory or parent directory
112+
4. Use parametrization for testing multiple scenarios
113+
5. Regroup test function that tests different case of same function or class under a test class following the pytest test discovery naming convention like in the following example:
114+
115+
### Python Specific Instructions On Tests Execution
116+
To run tests, use the pytest command from the project root or tests directory:
117+
118+
```bash
119+
# Run all tests
120+
python -m pytest
121+
122+
# Run tests with verbose output
123+
python -m pytest -v
124+
125+
# Run tests in a specific directory
126+
python -m pytest tests/tests_tools
127+
128+
# Run a specific test file
129+
python -m pytest tests/tests_tools/tests_console_tools/test_terminal_splash.py
130+
131+
# Run a specific test function
132+
python -m pytest tests/tests_tools/tests_console_tools/test_terminal_splash.py::test_norlab_splash
133+
```

.junie/plans/documentation_updates_proposal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ newgrp docker
276276
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
277277
278278
# Install tools
279-
brew install git tree
279+
brew update && brew install git tree
280280
```
281281

282282
#### NVIDIA Jetson (L4T)

.junie/recipes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Execute all unit-tests and all integration tests before submiting.
88
Add/refactor/improve TODO
99
Check if it introduce any breaking change in the code base by runnning both unit-tests and integration tests.
1010
Propose source code change if relevant.
11-
Update Markdown documention accordingly.
11+
Update Markdown documentation accordingly.
1212

1313
Inspire yourself with `TODO`.
1414

@@ -21,7 +21,7 @@ Create at least one test case per command argument and/or options.
2121
Test relevant option and arguments combinaison.
2222
You can mock their corresponding functions as the intended purposes of this test file is for unit-testing the CLI functionalities.
2323
Propose source code change if relevant.
24-
Update Markdown documention accordingly.
24+
Update Markdown documentation accordingly.
2525
Execute all unit-tests and all integration tests before submiting.
2626

2727
## Improve/refactor source code
@@ -34,7 +34,7 @@ Create at least one test case per new command argument and/or options, update cu
3434
Test relevant option and arguments combinaison.
3535
Check if it introduce any breaking change in the code base by runnning both unit-tests and integration tests.
3636
Propose source code change if relevant.
37-
Update Markdown documention accordingly.
37+
Update Markdown documentation accordingly.
3838
Execute all unit-tests and all integration tests before submiting.
3939

4040
## Modify proposed tests solutions
@@ -43,7 +43,7 @@ In `TODO.bats`, instead of mocking `find`, `grep`, `cut`, `cd`, `pwd`, `command`
4343

4444
---
4545

46-
Integration tests `TODO` and `TODO` are all failling.
46+
Integration tests `TODO` and `TODO` are all failing.
4747
Please investigate and make the required changes.
4848
Always follow guidelines at `.junie/guidelines.md`.
4949

.releaserc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
{
44
"name": "beta",
55
"prerelease": true
6+
},
7+
{
8+
"name": "alpha",
9+
"prerelease": true
610
}
711
],
812
"debug": "true",

documentation/offline_installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ See https://docs.docker.com/desktop/mac/install/
4747
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
4848

4949
# Install tools
50-
brew install git tree
50+
brew update && brew install git tree
5151
```
5252

5353
#### NVIDIA Jetson (L4T)

src/lib/core/utils/setup_host_dna_requirements.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ function dna::install_dna_software_requirements() {
139139
if [[ $(uname) == "Darwin" ]]; then
140140
if command -v brew >/dev/null 2>&1; then
141141
n2st::print_msg "Using Homebrew for package management"
142-
brew install git || return 1
143-
brew install tree || return 1
142+
brew update && brew install git || return 1
143+
brew update && brew install tree || return 1
144144
elif command -v port >/dev/null 2>&1; then
145145
n2st::print_msg "Using MacPorts for package management"
146146
sudo port install git || exit 1

0 commit comments

Comments
 (0)