diff --git a/contrib/arcanist/CMakeLists.txt b/contrib/arcanist/CMakeLists.txt --- a/contrib/arcanist/CMakeLists.txt +++ b/contrib/arcanist/CMakeLists.txt @@ -14,7 +14,7 @@ add_custom_target(${TESTNAME} COMMAND "${BASH_EXECUTABLE}" - "${CMAKE_CURRENT_SOURCE_DIR}/${TEST}" + "${CMAKE_CURRENT_SOURCE_DIR}/${TEST}" > "${TESTNAME}.log" ) add_dependencies(check-arcanist ${TESTNAME}) endforeach() diff --git a/contrib/arcanist/test/test-autopatch.sh b/contrib/arcanist/test/test-autopatch.sh --- a/contrib/arcanist/test/test-autopatch.sh +++ b/contrib/arcanist/test/test-autopatch.sh @@ -5,7 +5,7 @@ export LC_ALL=C.UTF-8 -set -euxo pipefail +set -euo pipefail TOPLEVEL=$(git rev-parse --show-toplevel) CURRENT_DIR=$(dirname $(readlink -f "$0")) @@ -15,6 +15,10 @@ REMOTE_AND_BRANCH="${REMOTE}/${MASTER_BRANCH}" LATEST_MASTER=$(git rev-parse "${REMOTE_AND_BRANCH}") +printstderr() { + >&2 echo "$1" +} + test_autopatch() { PATCH_FILE="$1" EXPECTED_EXIT_CODE="$2" @@ -24,9 +28,9 @@ export EDITOR="${CURRENT_DIR}/test-commit-message.sh" # Note: Do not use `-o ${REMOTE}` here because REMOTE may be on the local filesystem. 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}" 2>&1 || EXIT_CODE=$? if [ "${EXIT_CODE}" -ne "${EXPECTED_EXIT_CODE}" ]; then - echo "Error: autopatch exited with '${EXIT_CODE}' when '${EXPECTED_EXIT_CODE}' was expected." + printstderr "Error: autopatch exited with '${EXIT_CODE}' when '${EXPECTED_EXIT_CODE}' was expected." exit 1 fi @@ -37,12 +41,12 @@ # Sanity checks if [ -n "$(git status --porcelain)" ]; then - echo "Error: There should be no uncommitted changes." + printstderr "Error: There should be no uncommitted changes." exit 10 fi if [ "${LATEST_MASTER}" != "$(git rev-parse HEAD~)" ]; then - echo "Error: Failed to patch on latest master." + printstderr "Error: Failed to patch on latest master." exit 11 fi @@ -50,8 +54,8 @@ # to match. DIFF_HEAD_AGAINST_PATCH="$(git diff HEAD~ | grep -v "^index " | diff - "${PATCH_FILE}" || :)" if [ -n "${DIFF_HEAD_AGAINST_PATCH}" ]; then - echo "Error: Rebased changes do not match the given patch. Difference was:" - echo "${DIFF_HEAD_AGAINST_PATCH}" + printstderr "Error: Rebased changes do not match the given patch. Difference was:" + printstderr "${DIFF_HEAD_AGAINST_PATCH}" exit 12 fi } @@ -61,11 +65,10 @@ # Cleanup the temporary test directory rm -rf "$1" - # Nicely print the final test status - set +x - echo - echo "${0}:" - echo "${TEST_STATUS}" + # Print the final test status + printstderr "" + printstderr "${0}:" + printstderr "${TEST_STATUS}" } TEMP_DIR=$(mktemp -d) @@ -73,14 +76,14 @@ cd "${TEMP_DIR}" git init git remote add testorigin "${TOPLEVEL}" -git pull testorigin "${REMOTE_AND_BRANCH}" +git pull testorigin "${REMOTE_AND_BRANCH}" 2>&1 test_cleanup() { # Cleanup current branch so that arcanist doesn't run out of branch names CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) - git checkout "${MASTER_BRANCH}" + git checkout "${MASTER_BRANCH}" 2>&1 git reset --hard HEAD - git branch -D "${CURRENT_BRANCH}" || true + git branch -D "${CURRENT_BRANCH}" 2>&1 || true } ( @@ -92,7 +95,7 @@ test_file_not_present() { if [ -n "$1" ] && [ -f "$1" ]; then - echo "Error: '$1' file was found but not expected!" + printstderr "Error: '$1' file was found but not expected!" exit 51 fi }