]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/lib/sanitizer_common/scripts/litlint.py
5 # Ensure RUN commands in lit tests are free of common errors.
7 # If any errors are detected, litlint returns a nonzero exit code.
14 # Compile regex once for all files
15 runRegex
= re
.compile(r
'(?<!-o)(?<!%run) %t\s')
21 s: str, the line to validate
24 Returns an error message and a 1-based column number if an error was
25 detected, otherwise (None, None).
28 # Check that RUN command can be executed with an emulator
29 m
= runRegex
.search(s
)
32 return ('missing %run before %t', start
+ 2)
39 """ Check that each RUN command can be executed with an emulator
42 p: str, valid path to a file
45 The number of errors detected.
48 with
open(p
, 'r') as f
:
49 for i
, s
in enumerate(f
.readlines(), start
=1):
50 msg
, col
= LintLine(s
)
53 errorMsg
= 'litlint: {}:{}:{}: error: {}.\n{}{}\n'
54 arrow
= (col
-1) * ' ' + '^'
55 sys
.stderr
.write(errorMsg
.format(p
, i
, col
, msg
, s
, arrow
))
59 if __name__
== "__main__":
61 parser
= optparse
.OptionParser()
62 parser
.add_option('--filter') # ignored
63 (options
, filenames
) = parser
.parse_args()
70 # If errors, return nonzero