mirror of
https://github.com/jlengrand/error-prone-support.git
synced 2026-03-10 08:11:25 +00:00
Make Checkstyle integration test macOS-compatible (#867)
This commit is contained in:
committed by
GitHub
parent
c771d5f6b9
commit
03ba14b229
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
set -e -u -o pipefail
|
set -e -u -o pipefail
|
||||||
|
|
||||||
integration_test_root="$(readlink -f "$(dirname "${0}")")"
|
integration_test_root="$(cd "$(dirname -- "${0}")" && pwd)"
|
||||||
error_prone_support_root="${integration_test_root}/.."
|
error_prone_support_root="${integration_test_root}/.."
|
||||||
repos_root="${integration_test_root}/.repos"
|
repos_root="${integration_test_root}/.repos"
|
||||||
|
|
||||||
@@ -25,6 +25,21 @@ else
|
|||||||
trap 'rm -rf -- "${report_directory}"' INT TERM HUP EXIT
|
trap 'rm -rf -- "${report_directory}"' INT TERM HUP EXIT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
case "$(uname -s)" in
|
||||||
|
Linux*)
|
||||||
|
grep_command=grep
|
||||||
|
sed_command=sed
|
||||||
|
;;
|
||||||
|
Darwin*)
|
||||||
|
grep_command=ggrep
|
||||||
|
sed_command=gsed
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported distribution $(uname -s) for this script."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# XXX: Configure Renovate to manage the AssertJ version declared here.
|
# XXX: Configure Renovate to manage the AssertJ version declared here.
|
||||||
shared_build_flags="
|
shared_build_flags="
|
||||||
-Perror-prone-compile,error-prone-test-compile
|
-Perror-prone-compile,error-prone-test-compile
|
||||||
@@ -50,19 +65,19 @@ error_prone_shared_flags='-XepExcludedPaths:(\Q${project.basedir}${file.separato
|
|||||||
# in a separate Maven module.
|
# in a separate Maven module.
|
||||||
error_prone_patch_flags="${error_prone_shared_flags} -XepPatchLocation:IN_PLACE -XepPatchChecks:$(
|
error_prone_patch_flags="${error_prone_shared_flags} -XepPatchLocation:IN_PLACE -XepPatchChecks:$(
|
||||||
find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \
|
find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \
|
||||||
| xargs -0 grep -hoP '[^.]+$' \
|
| xargs -0 "${grep_command}" -hoP '[^.]+$' \
|
||||||
| grep -v ErrorProneRuntimeClasspath \
|
| "${grep_command}" -v ErrorProneRuntimeClasspath \
|
||||||
| paste -s -d ','
|
| paste -s -d ',' -
|
||||||
)"
|
)"
|
||||||
|
|
||||||
# XXX: Drop the `ErrorProneRuntimeClasspath` exclusion once that check resides
|
# XXX: Drop the `ErrorProneRuntimeClasspath` exclusion once that check resides
|
||||||
# in a separate Maven module.
|
# in a separate Maven module.
|
||||||
error_prone_validation_flags="${error_prone_shared_flags} -XepDisableAllChecks $(
|
error_prone_validation_flags="${error_prone_shared_flags} -XepDisableAllChecks $(
|
||||||
find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \
|
find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \
|
||||||
| xargs -0 grep -hoP '[^.]+$' \
|
| xargs -0 "${grep_command}" -hoP '[^.]+$' \
|
||||||
| sed -r 's,(.*),-Xep:\1:WARN,' \
|
| "${sed_command}" -r 's,(.*),-Xep:\1:WARN,' \
|
||||||
| grep -v ErrorProneRuntimeClasspath \
|
| "${grep_command}" -v ErrorProneRuntimeClasspath \
|
||||||
| paste -s -d ' '
|
| paste -s -d ' ' -
|
||||||
)"
|
)"
|
||||||
|
|
||||||
echo "Shared build flags: ${shared_build_flags}"
|
echo "Shared build flags: ${shared_build_flags}"
|
||||||
@@ -157,12 +172,12 @@ mvn ${shared_build_flags} \
|
|||||||
# Collect the applied changes.
|
# Collect the applied changes.
|
||||||
expected_changes="${integration_test_root}/${test_name}-expected-changes.patch"
|
expected_changes="${integration_test_root}/${test_name}-expected-changes.patch"
|
||||||
actual_changes="${report_directory}/${test_name}-changes.patch"
|
actual_changes="${report_directory}/${test_name}-changes.patch"
|
||||||
(git diff "${diff_base}"..HEAD | grep -vP '^(diff|index)' || true) > "${actual_changes}"
|
(git diff "${diff_base}"..HEAD | "${grep_command}" -vP '^(diff|index)' || true) > "${actual_changes}"
|
||||||
|
|
||||||
# Collect the warnings reported by Error Prone Support checks.
|
# Collect the warnings reported by Error Prone Support checks.
|
||||||
expected_warnings="${integration_test_root}/${test_name}-expected-warnings.txt"
|
expected_warnings="${integration_test_root}/${test_name}-expected-warnings.txt"
|
||||||
actual_warnings="${report_directory}/${test_name}-validation-build-warnings.txt"
|
actual_warnings="${report_directory}/${test_name}-validation-build-warnings.txt"
|
||||||
(grep -oP "(?<=^\\Q[WARNING] ${PWD}/\\E).*" "${validation_build_log}" | grep -P '\] \[' || true) | LC_ALL=C sort > "${actual_warnings}"
|
("${grep_command}" -oP "(?<=^\\Q[WARNING] ${PWD}/\\E).*" "${validation_build_log}" | "${grep_command}" -P '\] \[' || true) | LC_ALL=C sort > "${actual_warnings}"
|
||||||
|
|
||||||
# Persist or validate the applied changes and reported warnings.
|
# Persist or validate the applied changes and reported warnings.
|
||||||
if [ -n "${do_sync}" ]; then
|
if [ -n "${do_sync}" ]; then
|
||||||
@@ -174,12 +189,12 @@ else
|
|||||||
# XXX: This "diff of diffs" also contains vacuous sections, introduced due to
|
# XXX: This "diff of diffs" also contains vacuous sections, introduced due to
|
||||||
# line offset differences. Try to omit those from the final output.
|
# line offset differences. Try to omit those from the final output.
|
||||||
if ! diff -u "${expected_changes}" "${actual_changes}"; then
|
if ! diff -u "${expected_changes}" "${actual_changes}"; then
|
||||||
echo 'There are unexpected changes.'
|
echo 'There are unexpected changes. Inspect the preceding output for details.'
|
||||||
failure=1
|
failure=1
|
||||||
fi
|
fi
|
||||||
echo 'Inspecting emitted warnings...'
|
echo 'Inspecting emitted warnings...'
|
||||||
if ! diff -u "${expected_warnings}" "${actual_warnings}"; then
|
if ! diff -u "${expected_warnings}" "${actual_warnings}"; then
|
||||||
echo 'Diagnostics output changed.'
|
echo 'Diagnostics output changed. Inspect the preceding output for details.'
|
||||||
failure=1
|
failure=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user