summaryrefslogtreecommitdiffhomepage
path: root/scripts/common.sh
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-02-12 16:26:08 -0800
committergVisor bot <gvisor-bot@google.com>2020-02-12 16:27:07 -0800
commitcf1e50a80976fae95eef4ab05d961200b04e2346 (patch)
tree3c2fbcbdc3dde2127c49e04dafbcab04844d2273 /scripts/common.sh
parent46a36b64d5164d1ac887aa528d23bb2f2c74489e (diff)
Minor runtime test fixes.
* Allow scripts/common.sh to be sourced from outside the scripts/ directory * Fix passing empty args to Bazel, which causes the tool to exit with a failure even if the command succeeds. PiperOrigin-RevId: 294785456
Diffstat (limited to 'scripts/common.sh')
-rwxr-xr-xscripts/common.sh12
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/common.sh b/scripts/common.sh
index cd91b9f8e..3ca699e4a 100755
--- a/scripts/common.sh
+++ b/scripts/common.sh
@@ -16,7 +16,17 @@
set -xeou pipefail
-source $(dirname $0)/common_build.sh
+# Get the path to the directory this script lives in.
+# If this script is being called with `source`, $0 will be the path of the
+# *sourcing* script, so we can't use `dirname $0` to find scripts in this
+# directory.
+if [[ -v BASH_SOURCE && "$0" != "$BASH_SOURCE" ]]; then
+ declare -r script_dir="$(dirname "$BASH_SOURCE")"
+else
+ declare -r script_dir="$(dirname "$0")"
+fi
+
+source "${script_dir}/common_build.sh"
# Ensure it attempts to collect logs in all cases.
trap collect_logs EXIT