Skip to content

Не подгружает файл utils.sh если запуск происходит не из директории с файлом test.sh #1

Description

@4irik
$ 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions