tests/run: change to script dir first

Then use `$source_dir` for detecting the build dir: this way you can run
`./run.sh some-test-file.lua` from `./tests/`.
This commit is contained in:
Daniel Hahler 2016-07-17 22:08:01 +02:00
parent e6ddffda38
commit e8dfe36c59
1 changed files with 10 additions and 10 deletions

View File

@ -17,21 +17,21 @@ if [ "$CI" = true ]; then
set -x set -x
fi fi
# Either the build dir is passed in $CMAKE_BINARY_DIR or we guess based on $PWD
build_dir="$CMAKE_BINARY_DIR"
if [ -z "$build_dir" ]; then
if [ -d "$PWD/build" ]; then
build_dir="$PWD/build"
else
build_dir="$PWD"
fi
fi
# Change to file's dir (POSIXly). # Change to file's dir (POSIXly).
cd -P -- "$(dirname -- "$0")" cd -P -- "$(dirname -- "$0")"
this_dir=$PWD this_dir=$PWD
source_dir="$PWD/.." source_dir="$PWD/.."
# Either the build dir is passed in $CMAKE_BINARY_DIR or we guess based on $PWD
build_dir="$CMAKE_BINARY_DIR"
if [ -z "$build_dir" ]; then
if [ -d "$source_dir/build" ]; then
build_dir="$source_dir/build"
else
build_dir="$source_dir"
fi
fi
# Get test files: test*, or the ones provided as args (relative to tests/). # Get test files: test*, or the ones provided as args (relative to tests/).
if [ $# != 0 ]; then if [ $# != 0 ]; then
tests="$@" tests="$@"