Skip to content

Fix silently broken test_version.sh tests #1716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions test_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,26 @@ compilation_should_fail() {
# runs the tests locally
set +e
TEST_ARG=$@
DUMMY=$(bazel $TEST_ARG)
OUTPUT="$(bazel $TEST_ARG 2>&1)"
RESPONSE_CODE=$?
set -e

if [ $RESPONSE_CODE -eq 0 ]; then
echo -e "${RED} \"bazel $TEST_ARG\" should have failed but passed. $NC"
echo "$OUTPUT"
return -1
fi

local expected_error_pattern=(
"ErrorFile\.scala:6:[[:print:][:space:]]*'[)]' expected,? but '[}]' found"
)

if [[ ! "$OUTPUT" =~ $expected_error_pattern ]]; then
echo -e "${RED} \"bazel $*\" failure should have matched:"
echo -e " ${expected_error_pattern}"
echo -e " got:${NC}"
echo "$OUTPUT"
return 1
else
return 0
fi
Expand All @@ -45,12 +60,12 @@ run_in_test_repo() {

if [[ -n "$TWITTER_SCROOGE_VERSION" ]]; then
local version_param="version = \"$TWITTER_SCROOGE_VERSION\""
scrooge_ws="$version_param"
scrooge_ws="$version_param\\n"
fi

sed -e "s%\${twitter_scrooge_repositories}%${scrooge_ws}\n%" \
sed -e "s%\${twitter_scrooge_repositories}%${scrooge_ws}%" \
WORKSPACE.template >> $NEW_TEST_DIR/WORKSPACE
cp ../.bazel{rc,version} $NEW_TEST_DIR/
cp ../.bazel{rc,version} scrooge_repositories.bzl $NEW_TEST_DIR/

cd $NEW_TEST_DIR

Expand Down