3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Hacky, primitive testing: This runs the style plugin for a set of input files
8 # and compares the output with golden result files.
15 # Prints usage information.
17 echo "Usage: $(basename "${0}")" \
21 echo " Runs all the libBlinkGCPlugin unit tests"
25 # Runs a single test case.
28 if [ -e "${3}" ]; then
31 local output
="$("${CLANG_PATH}" -c -Wno-c++11-extensions \
32 -Wno-inaccessible-base \
33 -Xclang -load -Xclang "${PLUGIN_PATH}" \
34 -Xclang -add-plugin -Xclang blink-gc-plugin ${flags} ${1} 2>&1)"
35 local json
="${input%cpp}graph.json"
36 if [ -f "$json" ]; then
37 output
="$(python ../process-graph.py -c ${json} 2>&1)"
39 local diffout
="$(echo "${output}" | diff - "${2}")"
40 if [ "${diffout}" = "" ]; then
45 echo "Output of compiler:"
47 echo "Expected output:"
53 # Validate input to the script.
54 if [[ -z "${1}" ]]; then
57 elif [[ -z "${2}" ]]; then
60 elif [[ ! -x "${1}" ]]; then
61 echo "${1} is not an executable"
64 elif [[ ! -f "${2}" ]]; then
65 echo "${2} could not be found"
69 export CLANG_PATH
="${1}"
70 export PLUGIN_PATH
="${2}"
71 echo "Using clang ${CLANG_PATH}..."
72 echo "Using plugin ${PLUGIN_PATH}..."
74 # The golden files assume that the cwd is this directory. To make the script
75 # work no matter what the cwd is, explicitly cd to there.
76 cd "$(dirname "${0}")"
79 for input
in *.cpp
; do
80 do_testcase
"${input}" "${input%cpp}txt" "${input%cpp}flags"
83 if [[ "${failed_any_test}" ]]; then