Skip to content

Commit 6c25755

Browse files
committed
scripts: declare ROOT closer to where it's used, and some DRY changes
This also prevents shellcheck from complaining about a possibly undefined variable. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent dba0ef4 commit 6c25755

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

script/test/cri-integration.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
set -o errexit
1718
set -o nounset
1819
set -o pipefail
1920

20-
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
21+
basedir="$(dirname "${BASH_SOURCE[0]}")"
22+
source "${basedir}/utils.sh"
23+
24+
ROOT="$( cd "${basedir}" && pwd )"/../..
2125
cd "${ROOT}"
2226

2327
# FOCUS focuses the test to run.

script/test/utils.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/../..
18-
1917
IS_WINDOWS=0
2018
if [ -v "OS" ] && [ "${OS}" == "Windows_NT" ]; then
2119
IS_WINDOWS=1

test/build-test-images.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ set -o pipefail
2727
basedir="$(dirname "${BASH_SOURCE[0]}")"
2828
source "${basedir}/build-utils.sh"
2929
source "${basedir}/init-buildx.sh"
30+
31+
ROOT="$( cd "$basedir" && pwd )"/..
3032
cd "${ROOT}"
3133

3234
# ignore errors if the image already exists

test/build-utils.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
18-
1917
# PROJECT is the gce project to upload tarball.
20-
PROJECT=${PROJECT:-"k8s-cri-containerd"}
18+
: "${PROJECT:=k8s-cri-containerd}"
2119

2220
# GOOGLE_APPLICATION_CREDENTIALS is the path of service account file.
2321
if [ -z "${GOOGLE_APPLICATION_CREDENTIALS:-""}" ]; then

test/build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ set -o errexit
2222
set -o nounset
2323
set -o pipefail
2424

25-
source "$(dirname "${BASH_SOURCE[0]}")/build-utils.sh"
25+
basedir="$(dirname "${BASH_SOURCE[0]}")"
26+
source "${basedir}/build-utils.sh"
27+
28+
ROOT="$( cd "${basedir}" && pwd )"/..
2629
cd "${ROOT}"
2730

2831
# Make sure output directory is clean.

0 commit comments

Comments
 (0)