From e8dfe36c59df7d8bfdc484aa10489f839f7c411a Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 17 Jul 2016 22:08:01 +0200 Subject: [PATCH] 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/`. --- tests/run.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index 41b7a387..592354f1 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -17,21 +17,21 @@ if [ "$CI" = true ]; then set -x 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). cd -P -- "$(dirname -- "$0")" this_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/). if [ $# != 0 ]; then tests="$@"