aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java_tools/junitrunner
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2017-08-10 15:26:15 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-08-11 12:53:13 +0200
commit53641e5d303e23b89bd4653e5f0a510161bd71a2 (patch)
tree32863c623ab6aeef43e7b500b720626dfd1a6afb /src/java_tools/junitrunner
parent4cc2e579d77602386c4c1e8e8855f00a38db1e2a (diff)
Rewrite junitrunner integration tests
Use $(location) to get the unittest.bash script, which allows this test to also run with a different label prefix. This involves removing the intermediate testenv.sh script, which doesn't seem to add much value. We might want to consider a sh_unit_test rule or macro that has an implicit dependency on the unittest.bash script and doesn't require every test to do this manually. PiperOrigin-RevId: 164846477
Diffstat (limited to 'src/java_tools/junitrunner')
-rw-r--r--src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/BUILD35
-rwxr-xr-xsrc/java_tools/junitrunner/javatests/com/google/testing/junit/runner/antxmlresultwriter_integration_test.sh18
-rwxr-xr-xsrc/java_tools/junitrunner/javatests/com/google/testing/junit/runner/deploy_jar_integration_tests.sh15
-rwxr-xr-xsrc/java_tools/junitrunner/javatests/com/google/testing/junit/runner/junit4_testbridge_integration_tests.sh15
-rwxr-xr-xsrc/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testenv.sh25
-rwxr-xr-xsrc/java_tools/junitrunner/javatests/com/google/testing/junit/runner/utf8_test_log_test.sh15
6 files changed, 59 insertions, 64 deletions
diff --git a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/BUILD b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/BUILD
index 7642858db5..a465b447ac 100644
--- a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/BUILD
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/BUILD
@@ -54,23 +54,20 @@ java_test(
)
# BazelTestRunner integration tests
-sh_library(
- name = "testenv",
- srcs = ["testenv.sh"],
- deps = ["//src/test/shell:bashunit"],
-)
-
sh_test(
name = "junit4_testbridge_integration_test",
size = "medium",
srcs = ["junit4_testbridge_integration_tests.sh"],
args = [
+ "$(location //src/test/shell:unittest.bash)",
"$(location :TestbedBinary)",
"bazel.test_suite",
],
- data = [":TestbedBinary"],
- shard_count = 0,
- deps = [":testenv"],
+ data = [
+ ":TestbedBinary",
+ "//src/test/shell:bashunit",
+ "//src/test/shell:unittest.bash",
+ ],
)
sh_test(
@@ -78,12 +75,15 @@ sh_test(
size = "medium",
srcs = ["utf8_test_log_test.sh"],
args = [
+ "$(location //src/test/shell:unittest.bash)",
"$(location :TestbedBinary)",
"bazel.test_suite",
],
- data = [":TestbedBinary"],
- shard_count = 0,
- deps = [":testenv"],
+ data = [
+ ":TestbedBinary",
+ "//src/test/shell:bashunit",
+ "//src/test/shell:unittest.bash",
+ ],
)
sh_test(
@@ -91,16 +91,16 @@ sh_test(
size = "medium",
srcs = ["antxmlresultwriter_integration_test.sh"],
args = [
+ "$(location //src/test/shell:unittest.bash)",
"$(location :TestbedBinary)",
"$(location //src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed:XmlOutputExercises.ant.xml)",
- "bazel.test_suite",
],
data = [
":TestbedBinary",
"//src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed:XmlOutputExercises.ant.xml",
+ "//src/test/shell:bashunit",
+ "//src/test/shell:unittest.bash",
],
- shard_count = 0,
- deps = [":testenv"],
)
sh_test(
@@ -108,15 +108,16 @@ sh_test(
size = "medium",
srcs = ["deploy_jar_integration_tests.sh"],
args = [
+ "$(location //src/test/shell:unittest.bash)",
"$(JAVABASE)",
"$(location :TestbedBinary_deploy.jar)",
],
data = [
":TestbedBinary_deploy.jar",
+ "//src/test/shell:bashunit",
+ "//src/test/shell:unittest.bash",
"//tools/defaults:jdk",
],
- shard_count = 0,
- deps = [":testenv"],
)
filegroup(
diff --git a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/antxmlresultwriter_integration_test.sh b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/antxmlresultwriter_integration_test.sh
index dc3260e18c..6ff672091b 100755
--- a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/antxmlresultwriter_integration_test.sh
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/antxmlresultwriter_integration_test.sh
@@ -17,17 +17,21 @@
# Integration testing of the AntXmlResultWriter.
#
-DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+[ -z "$TEST_SRCDIR" ] && { echo "TEST_SRCDIR not set!" >&2; exit 1; }
+
+# Load the unit-testing framework
+source "$1" || \
+ { echo "Failed to load unit-testing framework $1" >&2; exit 1; }
-TESTBED="${PWD}/$1"
-XML_GOLDEN_OUTPUT_FILE="${PWD}/$2"
+set +o errexit
+
+DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+TESTBED="${PWD}/$2"
+XML_GOLDEN_OUTPUT_FILE="${PWD}/$3"
XML_OUTPUT_FILE="${TEST_TMPDIR}/test.xml"
-SUITE_PARAMETER="$3"
-SUITE="com.google.testing.junit.runner.testbed.XmlOutputExercises"
-SUITE_FLAG="-D${SUITE_PARAMETER}=${SUITE}"
+SUITE_FLAG="-Dbazel.test_suite=com.google.testing.junit.runner.testbed.XmlOutputExercises"
shift 3
-source ${DIR}/testenv.sh || { echo "testenv.sh not found!" >&2; exit 1; }
function test_XmlOutputExercises() {
cd $TEST_TMPDIR
diff --git a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/deploy_jar_integration_tests.sh b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/deploy_jar_integration_tests.sh
index 0b2d2559e5..d850f45c51 100755
--- a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/deploy_jar_integration_tests.sh
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/deploy_jar_integration_tests.sh
@@ -22,14 +22,19 @@
# and checking the output.
#
-DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+[ -z "$TEST_SRCDIR" ] && { echo "TEST_SRCDIR not set!" >&2; exit 1; }
+
+# Load the unit-testing framework
+source "$1" || \
+ { echo "Failed to load unit-testing framework $1" >&2; exit 1; }
+
+set +o errexit
unset TEST_PREMATURE_EXIT_FILE
-JAVA_HOME="$1"
-TESTBED_JAR="${PWD}/$2"
+JAVA_HOME="$2"
+TESTBED_JAR="${PWD}/$3"
-shift 2
-source ${DIR}/testenv.sh || { echo "testenv.sh not found!" >&2; exit 1; }
+shift 3
#######################
diff --git a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/junit4_testbridge_integration_tests.sh b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/junit4_testbridge_integration_tests.sh
index b44c34783b..4e193c774e 100755
--- a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/junit4_testbridge_integration_tests.sh
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/junit4_testbridge_integration_tests.sh
@@ -21,15 +21,20 @@
# and checking the output.
#
-DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+[ -z "$TEST_SRCDIR" ] && { echo "TEST_SRCDIR not set!" >&2; exit 1; }
-TESTBED="${PWD}/$1"
-SUITE_PARAMETER="$2"
+# Load the unit-testing framework
+source "$1" || \
+ { echo "Failed to load unit-testing framework $1" >&2; exit 1; }
+
+set +o errexit
+
+TESTBED="${PWD}/$2"
+SUITE_PARAMETER="$3"
SUITE_FLAG="-D${SUITE_PARAMETER}=com.google.testing.junit.runner.testbed.JUnit4TestbridgeExercises"
XML_OUTPUT_FILE="${TEST_TMPDIR}/test.xml"
-shift 2
-source ${DIR}/testenv.sh || { echo "testenv.sh not found!" >&2; exit 1; }
+shift 3
#######################
diff --git a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testenv.sh b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testenv.sh
deleted file mode 100755
index 0c3638fa2e..0000000000
--- a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testenv.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-
-# Copyright 2017 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.
-
-# Integration test for the junit test runner, test environment.
-
-[ -z "$TEST_SRCDIR" ] && { echo "TEST_SRCDIR not set!" >&2; exit 1; }
-
-# Load the unit-testing framework
-source "${TEST_SRCDIR}/io_bazel/src/test/shell/unittest.bash" || \
- { echo "Failed to source unittest.bash" >&2; exit 1; }
-
-set +o errexit
diff --git a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/utf8_test_log_test.sh b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/utf8_test_log_test.sh
index 3b2c47c7bb..6ee150de8a 100755
--- a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/utf8_test_log_test.sh
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/utf8_test_log_test.sh
@@ -17,16 +17,21 @@
# Test that JUnit3 logs are written with UTF-8 encoding.
#
-DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+[ -z "$TEST_SRCDIR" ] && { echo "TEST_SRCDIR not set!" >&2; exit 1; }
-TESTBED="${PWD}/$1"
-SUITE_PARAMETER="$2"
+# Load the unit-testing framework
+source "$1" || \
+ { echo "Failed to load unit-testing framework $1" >&2; exit 1; }
+
+set +o errexit
+
+TESTBED="${PWD}/$2"
+SUITE_PARAMETER="$3"
SUITE_FLAG="-D${SUITE_PARAMETER}=com.google.testing.junit.runner.testbed.InternationalCharsTest"
XML_OUTPUT_FILE="${TEST_TMPDIR}/test.xml"
unset TEST_PREMATURE_EXIT_FILE
-shift 2
-source ${DIR}/testenv.sh || { echo "testenv.sh not found!" >&2; exit 1; }
+shift 3
# Usage: expect_log <literal>
function expect_log() {