diff options
author | Greg Fitzgerald <gregf@codeaurora.org> | 2014-05-14 22:49:46 +0000 |
---|---|---|
committer | Greg Fitzgerald <gregf@codeaurora.org> | 2014-05-14 22:49:46 +0000 |
commit | e1735de0f7acf4706b4d491d8abdc92444ff5e51 (patch) | |
tree | 55f07a0c57da1ee2313a72820eb58659a164ab05 /lib/sanitizer_common/scripts | |
parent | a6a238a869723f25e00748df8d16045b49860410 (diff) |
add script to ensure lit test contains %run
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208819 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/scripts')
-rwxr-xr-x | lib/sanitizer_common/scripts/check_lint.sh | 5 | ||||
-rwxr-xr-x | lib/sanitizer_common/scripts/litlint.py | 27 |
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/sanitizer_common/scripts/check_lint.sh b/lib/sanitizer_common/scripts/check_lint.sh index e425fe172..0b7aea1ae 100755 --- a/lib/sanitizer_common/scripts/check_lint.sh +++ b/lib/sanitizer_common/scripts/check_lint.sh @@ -7,10 +7,12 @@ if [ "${LLVM_CHECKOUT}" == "" ]; then LLVM_CHECKOUT="${SCRIPT_DIR}/../../../../../" fi -# Cpplint setup +# python tools setup CPPLINT=${SCRIPT_DIR}/cpplint.py +LITLINT=${SCRIPT_DIR}/litlint.py if [ "${PYTHON_EXECUTABLE}" != "" ]; then CPPLINT="${PYTHON_EXECUTABLE} ${CPPLINT}" + LITLINT="${PYTHON_EXECUTABLE} ${LITLINT}" fi # Filters @@ -48,6 +50,7 @@ run_lint() { if [[ "${SILENT}" != "1" ]]; then cat $TASK_LOG fi + ${LITLINT} "$@" 2>>$ERROR_LOG } run_lint ${LLVM_LINT_FILTER} --filter=${LLVM_LINT_FILTER} \ diff --git a/lib/sanitizer_common/scripts/litlint.py b/lib/sanitizer_common/scripts/litlint.py new file mode 100755 index 000000000..15b496ff4 --- /dev/null +++ b/lib/sanitizer_common/scripts/litlint.py @@ -0,0 +1,27 @@ +#!/usr/bin/python +# +# lit-lint +# +# Check that the RUN commands in lit tests can be executed with an emulator. +# + +import argparse +import re +import sys + +parser = argparse.ArgumentParser(description='lint lit tests') +parser.add_argument('filenames', nargs='+') +parser.add_argument('--filter') # ignored +args = parser.parse_args() + +runRegex = re.compile(r'(?<!-o)(?<!%run) %t\s') +errorMsg = "litlint: {}:{}: error: missing %run before %t.\n\t{}" + +def LintFile(p): + with open(p, 'r') as f: + for i, s in enumerate(f.readlines()): + if runRegex.search(s): + sys.stderr.write(errorMsg.format(p, i, s)) + +for p in args.filenames: + LintFile(p) |