Skip to content

Commit

Permalink
Integration tests should work for Mac OS.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusSorealheis committed Oct 21, 2023
1 parent a0792fd commit 9eff777
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion integration_tests/simple_remote_execution_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if [[ $UNDER_TEST_RUNNER -ne 1 ]]; then
echo "This script should be run under run_integration_tests.sh"
exit 1
fi
set -x
set -xo pipefail

rm -rf "$CACHE_DIR/build_events.json"

Expand Down
35 changes: 27 additions & 8 deletions run_integration_tests.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright 2022 The Turbo Cache Authors. All rights reserved.
# Copyright 2023 The Turbo Cache 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.
Expand All @@ -15,6 +15,11 @@

set -euo pipefail

if [[ $EUID -eq 0 ]]; then
echo "This script should not be run as root."
exit 1
fi

TEST_PATTERNS=()

while [[ $# -gt 0 ]]; do
Expand Down Expand Up @@ -60,13 +65,20 @@ sudo rm -rf ~/.cache/turbo-cache
mkdir -p ~/.cache/turbo-cache

# Ensure our docker compose is not running.
docker-compose rm --stop -f
sudo docker-compose rm --stop -f

export TMPDIR=$HOME/.cache/turbo-cache/
mkdir -p "$TMPDIR"
export CACHE_DIR=$(mktemp -d --suffix="-turbo-cache-integration-test")

if [[ "$OSTYPE" == "darwin"* ]]; then
export CACHE_DIR=$(mktemp -d "${TMPDIR}turbo-cache-integration-test")
else
echo "Assumes Linux/WSL"
export CACHE_DIR=$(mktemp -d --tmpdir="$TMPDIR" --suffix="-turbo-cache-integration-test")
fi

export BAZEL_CACHE_DIR="$CACHE_DIR/bazel"
trap "sudo rm -rf $CACHE_DIR; docker-compose rm --stop -f" EXIT
trap "sudo rm -rf $CACHE_DIR; sudo docker-compose rm --stop -f" EXIT

echo "" # New line.

Expand All @@ -78,11 +90,18 @@ mkdir -p "$TURBO_CACHE_DIR"
for pattern in "${TEST_PATTERNS[@]}"; do
find "$SELF_DIR/integration_tests/" -name "$pattern" -type f -print0 | while IFS= read -r -d $'\0' fullpath; do
# Cleanup.
sudo find "$TURBO_CACHE_DIR" -delete
echo "Cleaning up cache directories TURBOC_CACHE_DIR: $TURBO_CACHE_DIR"
echo "Checking for existince of the TURBO_CACHE_DIR"
if [ -d "$TURBO_CACHE_DIR" ]; then
sudo find "$TURBO_CACHE_DIR" -delete
else
echo "Directory $TURBO_CACHE_DIR does not exist."
fi

bazel --output_base="$BAZEL_CACHE_DIR" clean
FILENAME=$(basename $fullpath)
echo "Running test $FILENAME"
docker-compose up -d
sudo docker-compose up -d
set +e
bash -euo pipefail "$fullpath"
EXIT_CODE="$?"
Expand All @@ -91,10 +110,10 @@ for pattern in "${TEST_PATTERNS[@]}"; do
echo "$FILENAME passed"
else
echo "$FILENAME failed with exit code $EXIT_CODE"
docker-compose logs
sudo docker-compose logs
exit $EXIT_CODE
fi
docker-compose rm --stop -f
sudo docker-compose rm --stop -f
echo "" # New line.
done
done
Expand Down

0 comments on commit 9eff777

Please sign in to comment.