aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java_tools/junitrunner/javatests/com/google/testing/junit/runner/antxmlresultwriter_integration_test.sh
blob: 609518a6bfe606e8640bcb0f68731256329643f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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"