Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Side by Side Diff: tools/clang/plugins/tests/test.sh

Issue 1385193002: Bisect clang Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 246985 Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/bin/bash
2 #
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.
6 #
7 # Hacky, primitive testing: This runs the style plugin for a set of input files
8 # and compares the output with golden result files.
9
10 E_BADARGS=65
11 E_FAILEDTEST=1
12
13 failed_any_test=
14
15 THIS_DIR="$(dirname "${0}")"
16
17 # Prints usage information.
18 usage() {
19 echo "Usage: $(basename "${0}")" \
20 "<path to clang>" \
21 "<path to plugin>"
22 echo ""
23 echo " Runs all the libFindBadConstructs unit tests"
24 echo ""
25 }
26
27 # Runs a single test case.
28 do_testcase() {
29 local flags=""
30 if [ -e "${3}" ]; then
31 flags="$(cat "${3}")"
32 fi
33
34 # TODO(thakis): Remove once the tests are standalone, http://crbug.com/486559
35 if [[ "$(uname -s)" == "Darwin" ]]; then
36 flags="${flags} -isysroot $(xcrun --show-sdk-path)"
37 fi
38 if [[ "$(uname -s)" == "Darwin" && "${flags}" != *-target* ]]; then
39 flags="${flags} -stdlib=libstdc++"
40 fi
41
42 flags="${flags} -Xclang -plugin-arg-find-bad-constructs \
43 -Xclang with-ast-visitor"
44
45 local output="$("${CLANG_PATH}" -fsyntax-only -Wno-c++11-extensions \
46 -Wno-inconsistent-missing-override \
47 -isystem ${THIS_DIR}/system \
48 -Xclang -load -Xclang "${PLUGIN_PATH}" \
49 -Xclang -add-plugin -Xclang find-bad-constructs ${flags} ${1} 2>&1)"
50 local diffout="$(echo "${output}" | diff - "${2}")"
51 if [ "${diffout}" = "" ]; then
52 echo "PASS: ${1}"
53 else
54 failed_any_test=yes
55 echo "FAIL: ${1}"
56 echo "Output of compiler:"
57 echo "${output}"
58 cat > ${2}-actual << EOF
59 ${output}
60 EOF
61
62 echo "Expected output:"
63 cat "${2}"
64 echo
65 fi
66 }
67
68 # Validate input to the script.
69 if [[ -z "${1}" ]]; then
70 usage
71 exit ${E_BADARGS}
72 elif [[ -z "${2}" ]]; then
73 usage
74 exit ${E_BADARGS}
75 elif [[ ! -x "${1}" ]]; then
76 echo "${1} is not an executable"
77 usage
78 exit ${E_BADARGS}
79 elif [[ ! -f "${2}" ]]; then
80 echo "${2} could not be found"
81 usage
82 exit ${E_BADARGS}
83 else
84 export CLANG_PATH="${1}"
85 export PLUGIN_PATH="${2}"
86 echo "Using clang ${CLANG_PATH}..."
87 echo "Using plugin ${PLUGIN_PATH}..."
88
89 # The golden files assume that the cwd is this directory. To make the script
90 # work no matter what the cwd is, explicitly cd to there.
91 cd "${THIS_DIR}"
92 fi
93
94 for input in *.cpp; do
95 do_testcase "${input}" "${input%cpp}txt" "${input%cpp}flags"
96 done
97
98 for input in *.c; do
99 do_testcase "${input}" "${input%c}txt" "${input%c}flags"
100 done
101
102 if [[ "${failed_any_test}" ]]; then
103 exit ${E_FAILEDTEST}
104 fi
OLDNEW
« no previous file with comments | « tools/clang/plugins/tests/system/windows.h ('k') | tools/clang/plugins/tests/virtual_base_method_also_final.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698