$ tree ./
./
├── bashunit
│ ├── README.md
│ ├── demo.gif
│ ├── test.sh
│ └── utils.sh
├── countdown.sh
└── tests
└── test_1.sh
2 directories, 6 files
$ pwd
/home/gs/my_doc/tools/countdown
$ ./bashunit/test.sh
bash: line 1: /home/gs/my_doc/tools/countdown/utils.sh: No such file or directory
./test_1.sh: line 1: assert: command not found
./tests/test_1.sh: FAIL
ERRORS:
./tests/test_1.sh:
RESULT:
total tests run: 1
successfully: 0
failure: 1
Если получить путь по которому запускается файл test.sh то можно работать с поддиректориями:
CURR_DIR=$(dirname ${BASH_SOURCE[0]})
$ cd tests
$ pwd
/home/gs/my_doc/tools/countdown/tests
$ ../bashunit/test.sh
./test_1.sh: FAIL
ERRORS:
./test_1.sh:
test failed:
1c1
< 1
---
> 2
RESULT:
total tests run: 1
successfully: 0
failure: 1
но не получится работать из директории уровнем выше:
$ pwd
/home/gs/my_doc/tools/countdown
$ ./bashunit/test.sh
bash: line 1: ./bashunit/utils.sh: No such file or directory
./test_1.sh: line 1: assert: command not found
./tests/test_1.sh: FAIL
ERRORS:
./tests/test_1.sh:
RESULT:
total tests run: 1
successfully: 0
failure: 1
$ tree ./ ./ ├── bashunit │ ├── README.md │ ├── demo.gif │ ├── test.sh │ └── utils.sh ├── countdown.sh └── tests └── test_1.sh 2 directories, 6 files $ pwd /home/gs/my_doc/tools/countdown $ ./bashunit/test.sh bash: line 1: /home/gs/my_doc/tools/countdown/utils.sh: No such file or directory ./test_1.sh: line 1: assert: command not found ./tests/test_1.sh: FAIL ERRORS: ./tests/test_1.sh: RESULT: total tests run: 1 successfully: 0 failure: 1Если получить путь по которому запускается файл
test.shто можно работать с поддиректориями:CURR_DIR=$(dirname ${BASH_SOURCE[0]})но не получится работать из директории уровнем выше: