Changeset View
Changeset View
Standalone View
Standalone View
contrib/source-control-tools/test/test-autopatch.sh
Show All 18 Lines | test_autopatch() { | ||||
PATCH_FILE="$1" | PATCH_FILE="$1" | ||||
EXPECTED_EXIT_CODE="$2" | EXPECTED_EXIT_CODE="$2" | ||||
PATCH_ARGS="--patch ${PATCH_FILE}" | PATCH_ARGS="--patch ${PATCH_FILE}" | ||||
# Setting the remote to this repo allows us to simulate an upstream without | # Setting the remote to this repo allows us to simulate an upstream without | ||||
# relying on external services for unit tests. | # relying on external services for unit tests. | ||||
export EDITOR="${CURRENT_DIR}/test-commit-message.sh" | export EDITOR="${CURRENT_DIR}/test-commit-message.sh" | ||||
# Note: Do not use `-o ${REMOTE}` here because REMOTE may be on the local filesystem. | # Note: Do not use `-o ${REMOTE}` here because REMOTE may be on the local filesystem. | ||||
EXIT_CODE=0 | EXIT_CODE=0 | ||||
"${CURRENT_DIR}/../autopatch.sh" -o testorigin -b "${MASTER_BRANCH}" --patch-args "${PATCH_ARGS}" || EXIT_CODE=$? | "${CURRENT_DIR}/../autopatch.sh" -o testorigin -b "${MASTER_BRANCH}" --patch-args "${PATCH_ARGS}" > /dev/null || EXIT_CODE=$? | ||||
if [ "${EXIT_CODE}" -ne "${EXPECTED_EXIT_CODE}" ]; then | if [ "${EXIT_CODE}" -ne "${EXPECTED_EXIT_CODE}" ]; then | ||||
echo "Error: autopatch exited with '${EXIT_CODE}' when '${EXPECTED_EXIT_CODE}' was expected." | echo "Error: autopatch exited with '${EXIT_CODE}' when '${EXPECTED_EXIT_CODE}' was expected." | ||||
exit 1 | exit 1 | ||||
fi | fi | ||||
# Autopatch failed as expected, so sanity checks are not necessary | # Autopatch failed as expected, so sanity checks are not necessary | ||||
if [ "${EXPECTED_EXIT_CODE}" -ne 0 ]; then | if [ "${EXPECTED_EXIT_CODE}" -ne 0 ]; then | ||||
exit 0 | exit 0 | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |