diff --git a/.githooks/pre-commit b/.githooks/pre-commit index a3acd78d97..04b029dee6 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -92,98 +92,11 @@ then fi fi -# Check that everything builds, but only if there are Java or Bazel changes. -if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] || [ $NUM_BAZEL_FILES_CHANGED -gt 0 ] -then - echo_status "Checking the build..." - bazel --batch build --disk_cache="$BAZEL_CACHE_DIR" //src/... - BUILD_STATUS=$? - if [ $BUILD_STATUS != 0 ] - then - echo_error "Build failed." "Please fix it and try again." - fi -fi - # Check unit tests. if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] || [ $NUM_UNIT_GOLDEN_FILES_CHANGED -gt 0 ] then echo_status "Checking unit tests..." - bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //src/test/... - TEST_STATUS=$? - if [ $TEST_STATUS != 0 ] - then - echo_error "Unit tests failed." "Please fix them and try again." - exit 1 - fi -fi - -# Check integration tests. -if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] \ - || [ $NUM_INTEGRATION_GOLDEN_FILES_CHANGED -gt 0 ] \ - || [ $NUM_INTEGRATION_BAZEL_FILES_CHANGED -gt 0 ] -then - echo_status "Checking integration tests..." - bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //test/integration/... - TEST_STATUS=$? - if [ $TEST_STATUS != 0 ] - then - echo_error "Integration tests failed." "Please fix them and try again." - exit 1 - fi -fi - -# Check integration tests. -if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] \ - || [ $NUM_INTEGRATION_GOLDEN_FILES_CHANGED -gt 0 ] \ - || [ $NUM_INTEGRATION_BAZEL_FILES_CHANGED -gt 0 ] -then - echo_status "Checking integration tests..." - bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //test/integration/... - TEST_STATUS=$? - if [ $TEST_STATUS != 0 ] - then - echo_error "Tests failed." "Please fix them and try again." - exit 1 - fi -fi - -# Check integration tests. -if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] \ - || [ $NUM_INTEGRATION_GOLDEN_FILES_CHANGED -gt 0 ] \ - || [ $NUM_INTEGRATION_BAZEL_FILES_CHANGED -gt 0 ] -then - echo_status "Checking integration tests..." - bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //test/integration/... - TEST_STATUS=$? - if [ $TEST_STATUS != 0 ] - then - echo_error "Tests failed." "Please fix them and try again." - exit 1 - fi -fi - -# Check integration tests. -if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] \ - || [ $NUM_INTEGRATION_GOLDEN_FILES_CHANGED -gt 0 ] \ - || [ $NUM_INTEGRATION_BAZEL_FILES_CHANGED -gt 0 ] -then - echo_status "Checking integration tests..." - bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //test/integration/... - TEST_STATUS=$? - if [ $TEST_STATUS != 0 ] - then - echo_error "Tests failed." "Please fix them and try again." - exit 1 - fi -fi - -# Check integration tests. -if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] \ - || [ $NUM_INTEGRATION_GOLDEN_FILES_CHANGED -gt 0 ] \ - || [ $NUM_INTEGRATION_BAZEL_FILES_CHANGED -gt 0 ] -then - echo_status "Checking integration tests..." - bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //test/integration/... + bazel --batch test $(bazel query "src/test/..." | grep "Test$") --disk_cache="$BAZEL_CACHE_DIR" TEST_STATUS=$? if [ $TEST_STATUS != 0 ] then