aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java_tools/junitrunner
diff options
context:
space:
mode:
authorGravatar Kush Chakraborty <kush@google.com>2017-02-16 19:39:08 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2017-02-17 14:52:57 +0000
commit9822151a2ab0574b3d7a884f623b6b260258cd6b (patch)
treecc046b918bacd520930bad7261e7554e0cfca830 /src/java_tools/junitrunner
parentb6e2bf13478454ee88dd1de1ca31007d23a7a0d6 (diff)
Automated [] rollback of commit 53b10eabb02480111510281b776db524df490a29.
*** Reason for rollback *** Rolling forward after fixing Mac tests, and adding coverage to Kokoro. *** Original change description *** Automated [] rollback of commit d8eec343d238129ce8b5146c4177d207a6b3683b. *** Reason for rollback *** These tests break on Mac: http://ci.bazel.io/job/bazel-tests/BAZEL_VERSION=HEAD,PLATFORM_NAME=darwin-x86_64/561/console E.g.: ERROR: /Users/ci/workspace/bazel-tests/BAZEL_VERSION/HEAD/PLATFORM_NAME/darwin-x86_64/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/BUILD:64:1: Couldn't build file src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/junit4_testbridge_integration_test.runfi... *** ROLLBACK_OF=147587929 -- PiperOrigin-RevId: 147746587 MOS_MIGRATED_REVID=147746587
Diffstat (limited to 'src/java_tools/junitrunner')
-rw-r--r--src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/BUILD83
-rwxr-xr-xsrc/java_tools/junitrunner/javatests/com/google/testing/junit/runner/antxmlresultwriter_integration_test.sh50
-rwxr-xr-xsrc/java_tools/junitrunner/javatests/com/google/testing/junit/runner/deploy_jar_integration_tests.sh46
-rwxr-xr-xsrc/java_tools/junitrunner/javatests/com/google/testing/junit/runner/junit4_testbridge_integration_tests.sh76
-rwxr-xr-xsrc/java_tools/junitrunner/javatests/com/google/testing/junit/runner/stack_trace_integration_tests.sh152
-rw-r--r--src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed/BUILD9
-rw-r--r--src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed/XmlOutputExercises.ant.xml39
-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.sh41
9 files changed, 520 insertions, 1 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 0dd82ccb6c..95327df8ab 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
@@ -34,6 +34,16 @@ java_library(
],
)
+java_binary(
+ name = "TestbedBinary",
+ testonly = 1,
+ main_class = "com.google.testing.junit.runner.BazelTestRunner",
+ runtime_deps = [
+ "//src/java_tools/junitrunner/java/com/google/testing/junit/runner:test_runner",
+ "//src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed",
+ ],
+)
+
# Tests
# =========================================================
java_test(
@@ -44,8 +54,81 @@ java_test(
runtime_deps = [":tests"],
)
+# 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 :TestbedBinary)",
+ "bazel.test_suite",
+ ],
+ data = [":TestbedBinary"],
+ shard_count = 0,
+ deps = [":testenv"],
+)
+
+sh_test(
+ name = "utf8_test_log_test",
+ size = "medium",
+ srcs = ["utf8_test_log_test.sh"],
+ args = [
+ "$(location :TestbedBinary)",
+ "bazel.test_suite",
+ ],
+ data = [":TestbedBinary"],
+ shard_count = 0,
+ deps = [":testenv"],
+)
+
+sh_test(
+ name = "antxmlresultwriter_integration_test",
+ size = "medium",
+ srcs = ["antxmlresultwriter_integration_test.sh"],
+ args = [
+ "$(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",
+ ],
+ shard_count = 0,
+ deps = [":testenv"],
+)
+
+sh_test(
+ name = "deploy_jar_integration_test",
+ size = "medium",
+ srcs = ["deploy_jar_integration_tests.sh"],
+ args = [
+ "$(JAVABASE)",
+ "$(location :TestbedBinary_deploy.jar)",
+ ],
+ data = [
+ ":TestbedBinary_deploy.jar",
+ "//tools/defaults:jdk",
+ ],
+ shard_count = 0,
+ deps = [":testenv"],
+)
+
filegroup(
name = "srcs",
srcs = glob(["**"]),
visibility = ["//src:__pkg__"],
)
+
+exports_files([
+ "stack_trace_integration_tests.sh",
+ "junit4_testbridge_integration_tests.sh",
+ "utf8_test_log_test.sh",
+ "deploy_jar_integration_tests.sh",
+])
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
new file mode 100755
index 0000000000..609518a6bf
--- /dev/null
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/antxmlresultwriter_integration_test.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+#
+# Copyright 2015 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 testing of the AntXmlResultWriter.
+#
+
+DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+
+TESTBED="${PWD}/$1"
+XML_GOLDEN_OUTPUT_FILE="${PWD}/$2"
+XML_OUTPUT_FILE="${TEST_TMPDIR}/test.xml"
+SUITE_PARAMETER="$3"
+SUITE="com.google.testing.junit.runner.testbed.XmlOutputExercises"
+SUITE_FLAG="-D${SUITE_PARAMETER}=${SUITE}"
+
+shift 3
+source ${DIR}/testenv.sh || { echo "testenv.sh not found!" >&2; exit 1; }
+
+function test_XmlOutputExercises() {
+ cd $TEST_TMPDIR
+
+ $TESTBED --jvm_flag=${SUITE_FLAG} || true # Test failures
+
+ # Remove timestamps and test runtime from the XML files as they will always differ and cause a
+ # mismatch.
+ sed -i.bak -E "s/(time[^=]*)='[^']*/\1='/g" $XML_OUTPUT_FILE \
+ || fail "sed to remove timestamps failed"
+
+ # Removes the stacktrace from the XML files, it can vary between JDK versions.
+ sed -i.bak -E '/\w*at [a-zA-Z0-9\$\.]+\([a-zA-Z0-9 \.]*(:[0-9]+)?\)$/d' \
+ "${XML_OUTPUT_FILE}" || fail "sed to remove stacktraces failed"
+
+ diff -wu $XML_GOLDEN_OUTPUT_FILE $XML_OUTPUT_FILE \
+ || fail "Did not expect a diff between the golden file and the generated XML output."
+}
+
+run_suite "antxmlresultwriter"
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
new file mode 100755
index 0000000000..0b2d2559e5
--- /dev/null
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/deploy_jar_integration_tests.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+#
+# Copyright 2012 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 testing of _deploy.jar behavior. Not using the runfiles wrapper
+# can create a few puzzling hazards. This verifies that we warn the user for
+# the most obvious ones.
+#
+# These tests operate by executing test methods in a testbed deploy.jar program
+# and checking the output.
+#
+
+DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+
+unset TEST_PREMATURE_EXIT_FILE
+JAVA_HOME="$1"
+TESTBED_JAR="${PWD}/$2"
+
+shift 2
+source ${DIR}/testenv.sh || { echo "testenv.sh not found!" >&2; exit 1; }
+
+#######################
+
+# Test that we see a warning about missing the test suite Java system property
+function test_Warning() {
+ test_pid=""
+ ${JAVA_HOME}/bin/java -jar $TESTBED_JAR >& $TEST_log && test_pid=$!
+
+ expect_log "The test suite Java system property .* is required but missing"
+
+ wait $test_pid || fail "Expected process to finish successfully"
+}
+
+run_suite "deploy_jar"
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
new file mode 100755
index 0000000000..1af426408d
--- /dev/null
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/junit4_testbridge_integration_tests.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+#
+# Copyright 2015 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 testing of the test bridge protocol for JUnit4 tests.
+# This is a test filter passed by "bazel test --test_filter".
+#
+# These tests operate by executing test methods in a testbed program
+# and checking the output.
+#
+
+DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+
+TESTBED="${PWD}/$1"
+SUITE_PARAMETER="$2"
+SUITE_FLAG="-D${SUITE_PARAMETER}=com.google.testing.junit.runner.testbed.JUnit4TestbridgeExercises"
+
+shift 2
+source ${DIR}/testenv.sh || { echo "testenv.sh not found!" >&2; exit 1; }
+
+#######################
+
+function set_up() {
+ # By default, the environment flag is unset.
+ declare +x TESTBRIDGE_TEST_ONLY
+}
+
+# Test that we respond to TESTBRIDGE_TEST_ONLY in JUnit4 tests.
+function test_Junit4() {
+ cd $TEST_TMPDIR
+
+ # Run the test without environment flag; it should fail.
+ declare +x TESTBRIDGE_TEST_ONLY
+ $TESTBED --jvm_flag=${SUITE_FLAG} >& $TEST_log && fail "Expected failure"
+ expect_log 'Failures: 1'
+
+ # Run the test with environment flag.
+ declare -x TESTBRIDGE_TEST_ONLY="doRun"
+ $TESTBED --jvm_flag=${SUITE_FLAG} >& $TEST_log || fail "Expected success"
+ expect_log 'OK.*1 test'
+
+ # Finally, run the test once again without environment flag; it should fail.
+ declare +x TESTBRIDGE_TEST_ONLY
+ $TESTBED --jvm_flag=${SUITE_FLAG} >& $TEST_log && fail "Expected failure again"
+ expect_log 'Failures: 1'
+}
+
+# Test that TESTBRIDGE_TEST_ONLY is overridden by a direct flag.
+function test_Junit4FlagOverridesEnv() {
+ cd $TEST_TMPDIR
+
+ # Run the test with both environment and command line flags.
+ declare -x TESTBRIDGE_TEST_ONLY="doNotRun"
+ $TESTBED --jvm_flag=${SUITE_FLAG} --test_filter doRun >& $TEST_log || \
+ fail "Expected success"
+ expect_log 'OK.*1 test'
+
+ declare -x TESTBRIDGE_TEST_ONLY="doRun"
+ $TESTBED --jvm_flag=${SUITE_FLAG} --test_filter doNotRun >& $TEST_log && \
+ fail "Expected failure"
+ expect_log 'Failures: 1'
+}
+
+run_suite "testbridge_test_only"
diff --git a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/stack_trace_integration_tests.sh b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/stack_trace_integration_tests.sh
new file mode 100755
index 0000000000..0ff0933dbf
--- /dev/null
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/stack_trace_integration_tests.sh
@@ -0,0 +1,152 @@
+#!/bin/bash
+#
+# Copyright 2010 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 testing of stack traces printed to the console during JUnit
+# tests. Test runners send a SIGTERM to the test process upon timeout (and
+# typically SIGKILL after a grace period).
+#
+# These tests operate by executing test methods in a testbed program
+# and checking the output.
+#
+
+DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+unset TEST_PREMATURE_EXIT_FILE
+
+TESTBED="${PWD}/$1"
+SUITE_PARAMETER="$2"
+JUNIT_VERSION="$3"
+SUITE="com.google.testing.junit.runner.testbed.StackTraceExercises"
+SUITE_FLAG="-D${SUITE_PARAMETER}=${SUITE}"
+SLOW_CREATION_SUITE_FLAG="-D${SUITE_PARAMETER}=com.google.testing.junit.runner.testbed.SuiteMethodTakesForever"
+
+shift 3
+source ${DIR}/testenv.sh || { echo "testenv.sh not found!" >&2; exit 1; }
+
+# Usage: COUNT=count_in_log <regex>
+function count_in_log() {
+ echo $(grep -c "$1" $TEST_log)
+}
+
+function check_ge() {
+ (( $1 >= $2 )) || fail "$3"
+}
+
+function check_le() {
+ (( $1 <= $2 )) || fail "$3"
+}
+
+function check_eq() {
+ (( $1 == $2 )) || fail "$3"
+}
+
+# Usage: expect_thread_dumps_in_log <max_number_of_expected_thread_dumps>
+function expect_thread_dumps_in_log() {
+ local thread_dump_starts=$(count_in_log "Starting full thread dump")
+ local thread_dump_ends=$(count_in_log "Done full thread dump")
+ check_ge "$thread_dump_starts" 1 "Thread dump generated at least once"
+ check_le "$thread_dump_starts" "$1" "Thread dump generated at most $1 times"
+ check_eq "$thread_dump_starts" "$thread_dump_ends" \
+ "Thread dumps ended successfully"
+}
+
+#######################
+
+# Test that we see a stack trace even on shutdown hook slowness.
+function test_ShutdownHook() {
+ cd $TEST_TMPDIR
+ local fifo="${PWD}/tmp/fifo_for_shutdown_hook"
+ mkdir -p tmp
+ mkfifo $fifo || fail "Couldn't create ${fifo}"
+
+ # Run the test in the background. The test process will report success,
+ # but hang in the shutdown hook.
+ if [ "$JUNIT_VERSION" = "3" ]; then
+ TEST_FILTER_FLAG="${SUITE}#testSneakyShutdownHook"
+ else
+ TEST_FILTER_FLAG="--test_filter=testSneakyShutdownHook"
+ fi
+
+ $TESTBED --jvm_flag=${SUITE_FLAG} --jvm_flag=-Dtest.fifo=${fifo} $TEST_FILTER_FLAG \
+ >& $TEST_log & test_pid=$!
+
+ echo "Synchronize to the shutdown hook" > $fifo
+ expect_log 'OK.*1 test'
+ expect_log "Entered shutdown"
+
+ # Send the SIGTERM and wait 3s (generous) for it to be processed:
+ kill -TERM $test_pid
+ sleep 3
+
+ expect_log 'INTERRUPTED TEST: SIGTERM'
+ expect_log 'Shutdown\.runHooks'
+ expect_log 'StackTraceExercises\.handleHook'
+ expect_log 'Thread\.sleep'
+
+ # expect threads to be dumped at most 2 times
+ expect_thread_dumps_in_log 2
+
+ wait $test_pid || fail "Expected process to finish successfully"
+}
+
+# Test that we see a stack trace when the test is interrupted during the test
+# suite creation phase.
+function test_SlowSuite() {
+ cd $TEST_TMPDIR
+ local fifo="${PWD}/tmp/fifo_for_slow_suite"
+ mkdir -p tmp
+ mkfifo $fifo || fail "Couldn't create ${fifo}"
+
+ # Run the test in the background. The test process will hang in the suite
+ # creation phase.
+ $TESTBED --jvm_flag=${SLOW_CREATION_SUITE_FLAG} --jvm_flag=-Dtest.fifo=${fifo} \
+ >& $TEST_log & test_pid=$!
+ echo "Synchronize to the suite creation" > $fifo
+ expect_log 'Entered suite creation'
+
+ # Send the SIGTERM and wait 3s (generous) for it to be processed:
+ kill -TERM $test_pid
+ sleep 3
+
+ expect_log "Execution interrupted while running 'TestSuite creation'"
+
+ # expect threads to be dumped exactly once
+ expect_thread_dumps_in_log 1
+}
+
+# If a test calls System.exit(), make sure it leaves the
+# TEST_PREMATURE_EXIT_FILE around.
+function test_PrematureExit() {
+ cd $TEST_TMPDIR
+ mkdir foo
+ local no_exit="${PWD}/foo/premature_exit_file"
+
+ [ ! -a "$no_exit" ] || fail "${no_exit} should not exist yet"
+
+ if [ "$JUNIT_VERSION" = "3" ]; then
+ TEST_FILTER_FLAG="${SUITE}#testNotSoFastBuddy"
+ else
+ TEST_FILTER_FLAG="--test_filter=testNotSoFastBuddy"
+ fi
+
+ echo "Redirecting output to $TEST_log"
+ TEST_PREMATURE_EXIT_FILE=${no_exit} $TESTBED --jvm_flag=${SUITE_FLAG} $TEST_FILTER_FLAG \
+ >& $TEST_log || fail "Expected spurious success"
+
+ expect_log 'Hey, not so fast there'
+ [ -r "$no_exit" ] || fail "$no_exit is not readable"
+}
+
+run_suite "stacktrace"
diff --git a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed/BUILD b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed/BUILD
index 2bb65e1643..3061e6da64 100644
--- a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed/BUILD
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed/BUILD
@@ -17,8 +17,15 @@ java_library(
],
)
+exports_files([
+ "XmlOutputExercises.ant.xml",
+])
+
filegroup(
name = "srcs",
- srcs = glob(["*.java"]) + ["BUILD"],
+ srcs = glob(["*.java"]) + [
+ "XmlOutputExercises.ant.xml",
+ "BUILD",
+ ],
visibility = ["//src:__pkg__"],
)
diff --git a/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed/XmlOutputExercises.ant.xml b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed/XmlOutputExercises.ant.xml
new file mode 100644
index 0000000000..beb241992b
--- /dev/null
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testbed/XmlOutputExercises.ant.xml
@@ -0,0 +1,39 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<testsuites>
+ <testsuite name='com.google.testing.junit.runner.testbed.XmlOutputExercises' timestamp='' hostname='localhost' tests='7' failures='1' errors='0' time='' package='' id='0'>
+ <properties />
+ <system-out />
+ <system-err />
+ </testsuite>
+ <testsuite name='com.google.testing.junit.runner.testbed.XmlOutputExercises$FailureTest' timestamp='' hostname='localhost' tests='1' failures='1' errors='0' time='' package='' id='1'>
+ <properties />
+ <testcase name='testFail' classname='com.google.testing.junit.runner.testbed.XmlOutputExercises$FailureTest' time=''>
+ <failure message='This is an expected error. The test is supposed to fail.' type='java.lang.AssertionError'>java.lang.AssertionError: This is an expected error. The test is supposed to fail.
+
+ </failure>
+ </testcase>
+ <system-out />
+ <system-err />
+ </testsuite>
+ <testsuite name='com.google.testing.junit.runner.testbed.XmlOutputExercises$OtherTests' timestamp='' hostname='localhost' tests='1' failures='0' errors='0' time='' package='' id='2'>
+ <properties />
+ <testcase name='testToString' classname='com.google.testing.junit.runner.testbed.XmlOutputExercises$OtherTests' time='' />
+ <system-out />
+ <system-err />
+ </testsuite>
+ <testsuite name='com.google.testing.junit.runner.testbed.XmlOutputExercises$EqualsHashCodeTest' timestamp='' hostname='localhost' tests='2' failures='0' errors='0' time='' package='' id='3'>
+ <properties />
+ <testcase name='testHashCode' classname='com.google.testing.junit.runner.testbed.XmlOutputExercises$EqualsHashCodeTest' time='' />
+ <testcase name='testEquals' classname='com.google.testing.junit.runner.testbed.XmlOutputExercises$EqualsHashCodeTest' time='' />
+ <system-out />
+ <system-err />
+ </testsuite>
+ <testsuite name='com.google.testing.junit.runner.testbed.XmlOutputExercises$ComparabilityTest' timestamp='' hostname='localhost' tests='3' failures='0' errors='0' time='' package='' id='4'>
+ <properties />
+ <testcase name='compareToEqualInstance' classname='com.google.testing.junit.runner.testbed.XmlOutputExercises$ComparabilityTest' time='' />
+ <testcase name='compareToGreaterInstance' classname='com.google.testing.junit.runner.testbed.XmlOutputExercises$ComparabilityTest' time='' />
+ <testcase name='compareToLessInstance' classname='com.google.testing.junit.runner.testbed.XmlOutputExercises$ComparabilityTest' time='' />
+ <system-out />
+ <system-err />
+ </testsuite>
+</testsuites>
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
new file mode 100755
index 0000000000..0c3638fa2e
--- /dev/null
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/testenv.sh
@@ -0,0 +1,25 @@
+#!/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
new file mode 100755
index 0000000000..b03df4e37f
--- /dev/null
+++ b/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/utf8_test_log_test.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+#
+# Copyright 2015 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.
+#
+# Test that JUnit3 logs are written with UTF-8 encoding.
+#
+
+DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
+
+TESTBED="${PWD}/$1"
+SUITE_PARAMETER="$2"
+SUITE_FLAG="-D${SUITE_PARAMETER}=com.google.testing.junit.runner.testbed.InternationalCharsTest"
+unset TEST_PREMATURE_EXIT_FILE
+
+shift 2
+source ${DIR}/testenv.sh || { echo "testenv.sh not found!" >&2; exit 1; }
+
+# Usage: expect_log <literal>
+function expect_log() {
+ grep -q -F "$1" $TEST_log ||
+ fail "Could not find \"$1\" in \"$(cat $TEST_log)\""
+}
+
+function test_utf8_log() {
+ $TESTBED --jvm_flag=${SUITE_FLAG} > $TEST_log && fail "Expected failure"
+ expect_log 'expected:<Test [Japan].> but was:<Test [日本].>'
+}
+
+run_suite "utf8_test_log"