#!/bin/bash # # Copyright 2016 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Tests the examples provided in Bazel # # Load the test setup defined in the parent directory CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${CURRENT_DIR}/../integration_test_setup.sh" \ || { echo "integration_test_setup.sh not found!" >&2; exit 1; } function write_hello_library_files() { mkdir -p java/main cat >java/main/BUILD <java/main/Main.java <java/hello_library/BUILD <java/hello_library/HelloLibrary.java < $TEST_log || fail "build failed" } function test_errorprone_error_fails_build_by_default() { write_hello_library_files # Trigger an error-prone error by comparing two arrays via #equals(). cat >java/hello_library/HelloLibrary.java < $TEST_log && fail "build should have failed" || true expect_log "error: \[ArrayEquals\] Reference equality used to compare arrays" } function test_extrachecks_off_disables_errorprone() { write_hello_library_files # Trigger an error-prone error by comparing two arrays via #equals(). cat >java/hello_library/HelloLibrary.java <java/hello_library/BUILD < $TEST_log || fail "build failed" expect_not_log "error: \[ArrayEquals\] Reference equality used to compare arrays" } function test_java_test_main_class() { mkdir -p java/testrunners || fail "mkdir failed" cat > java/testrunners/TestRunner.java < java/testrunners/Tests.java < java/testrunners/BUILD < "$TEST_log" expect_log "Custom test runner was run" expect_log "testTest was run" } run_suite "Java integration tests"