3 # Copyright (c) 2011 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}")" \
18 "<Path to the llvm build dir, usually Release+Asserts>"
20 echo " Runs all the libFindBadConstructs unit tests"
24 # Runs a single test case.
27 if [ -e "${3}" ]; then
30 local output="$("${CLANG_DIR}"/bin/clang -c -Wno-c++11-extensions \
31 -Xclang -load -Xclang "${CLANG_DIR}"/lib/libFindBadConstructs.${LIB} \
32 -Xclang -add-plugin -Xclang find-bad-constructs ${flags} ${1} 2>&1)"
33 local diffout="$(echo "${output}" | diff - "${2}")"
34 if [ "${diffout}" = "" ]; then
39 echo "Output of compiler:"
41 echo "Expected output:"
47 # Validate input to the script.
48 if [[ -z "${1}" ]]; then
51 elif [[ ! -d "${1}" ]]; then
52 echo "${1} is not a directory."
56 export CLANG_DIR="${PWD}/${1}"
57 echo "Using clang directory ${CLANG_DIR}..."
59 # The golden files assume that the cwd is this directory. To make the script
60 # work no matter what the cwd is, explicitly cd to there.
61 cd "$(dirname "${0}")"
63 if [ "$(uname -s)" = "Linux" ]; then
65 elif [ "$(uname -s)" = "Darwin" ]; then
70 for input in *.cpp; do
71 do_testcase "${input}" "${input%cpp}txt" "${input%cpp}flags"
74 if [[ "${failed_any_test}" ]]; then