runlint.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Software License Agreement (BSD License)
3 #
4 # Copyright (C) 2013, Jack O'Quin
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 #
11 # * Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above
14 # copyright notice, this list of conditions and the following
15 # disclaimer in the documentation and/or other materials provided
16 # with the distribution.
17 # * Neither the name of the author nor of other contributors may be
18 # used to endorse or promote products derived from this software
19 # without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
33 
34 """
35 Run a specified linter in a subprocess, checking its return status.
36 
37 This is a unit test script for roslint.
38 """
39 
40 from __future__ import print_function
41 
42 import sys
43 import subprocess
44 
45 def main(returnstatus, linter, files):
46  """ Main program.
47 
48  :param: returnstatus expected return status
49  :param: linter command string for running the linter with its options.
50  :param: files list of file names to process
51 
52  :returns: 0 if test successful, 1 otherwise.
53  """
54  cmd = linter.split() + files
55  print('lint command: ' + ' '.join(cmd))
56  sub_rc = subprocess.call(cmd)
57  if sub_rc != int(returnstatus):
58  return 1
59  else:
60  return 0
61 
62 
63 if __name__ == '__main__':
64 
65  # for some reason, pylint wants this variable name to be uppercase:
66  #pylint: disable=C0103
67  ret_status = -9 # return status for missing args
68  if len(sys.argv) > 3:
69  ret_status = main(sys.argv[1], sys.argv[2], sys.argv[3:])
70  else:
71  print('usage: runlint returnstatus linter file1 [ file2 ... ]')
72  sys.exit(ret_status)
def main(returnstatus, linter, files)
Definition: runlint.py:45


roslint
Author(s): Mike Purvis, Jack O'Quin
autogenerated on Wed May 1 2019 02:23:59