diff options
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) |