summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/scripts/litlint.py
blob: b82eec2904953927e71c32b984ecef17a6190fe0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/python
#
# lit-lint
#
# Check that the RUN commands in lit tests can be executed with an emulator.
#

import optparse
import re
import sys

parser = optparse.OptionParser()
parser.add_option('--filter')  # ignored
(options, filenames) = 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 filenames:
    LintFile(p)
OpenPOWER on IntegriCloud