diff options
author | 2016-10-18 14:28:42 +0000 | |
---|---|---|
committer | 2016-10-19 08:26:02 +0000 | |
commit | fa389066641ac7f92b220ef232f23e757704318d (patch) | |
tree | cfedd733426e8b7b95b87105bd6344a6c0154983 /src/test/shell/integration_test_setup.sh | |
parent | aecf826aa0cd12d25a8f6d69604d721f50d940f0 (diff) |
Create a proper wrapper script for executing "bazel" in the integration tests.
Currently a call to "bazel" in an integration test means calling a (quite
hidden) function in test-setup.sh which actually calls "$bazel" defined
in "shell/bazel/testenv.sh" which is equal to "$(rlocation io_bazel/src/bazel)".
This is extremely confusing and error prone.
The new mechanism is to add a wrapper script to shell/bin called bazel
and export this directory to the PATH.
Moreover, not every test loads the same test environment, for instance consider
how bazel_query_test loads the test environment:
- Load shell/integration/testenv.sh which loads,
- shell/bazel/test-setup.sh which loads,
- shell/bazel/testenv.sh which loads,
- shell/unittest.bash which loads,
- shell/testenv.sh
Again this is error prone and specially hard to understand, in fact
each test writer needs to decide which of these testenv to load.
This change fixes all of this by having only one testenv.sh
and summarizing the test setup in integration_test_setup.sh.
Namely, for any new integration test, the developer
needs to load integration_test_setup to get the environment set up including
the unittest framework (also it helps to attract contributions).
This change also allows to open sourcing client_sigint_test: Since bazel was a
function client_sigint_test was using a wrong process id to interrupt
the build. The problem is that $! returns
bash's id instead of the id of the process running in the background
when using a function instead of an executable.
A few tests needed to be adapted to the new infrastructure.
--
MOS_MIGRATED_REVID=136470360
Diffstat (limited to 'src/test/shell/integration_test_setup.sh')
-rwxr-xr-x | src/test/shell/integration_test_setup.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/shell/integration_test_setup.sh b/src/test/shell/integration_test_setup.sh new file mode 100755 index 0000000000..73f7c925e8 --- /dev/null +++ b/src/test/shell/integration_test_setup.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Copyright 2016 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +function print_message_and_exit() { + echo $1 >&2; exit 1; +} + +CURRENT_SCRIPT=${BASH_SOURCE[0]} +# Go to the directory where the script is running +cd "$(dirname ${CURRENT_SCRIPT})" \ + || print_message_and_exit "Unable to access "$(dirname ${CURRENT_SCRIPT})"" + +DIR=$(pwd) +# Load the unit test framework +source "$DIR/unittest.bash" || print_message_and_exit "unittest.bash not found!" +# Load the test environment +source "$DIR/testenv.sh" || print_message_and_exit "testenv.sh not found!" |