runlint.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # Software License Agreement (BSD License)
00003 #
00004 # Copyright (C) 2013, Jack O'Quin
00005 # All rights reserved.
00006 #
00007 # Redistribution and use in source and binary forms, with or without
00008 # modification, are permitted provided that the following conditions
00009 # are met:
00010 #
00011 #  * Redistributions of source code must retain the above copyright
00012 #    notice, this list of conditions and the following disclaimer.
00013 #  * Redistributions in binary form must reproduce the above
00014 #    copyright notice, this list of conditions and the following
00015 #    disclaimer in the documentation and/or other materials provided
00016 #    with the distribution.
00017 #  * Neither the name of the author nor of other contributors may be
00018 #    used to endorse or promote products derived from this software
00019 #    without specific prior written permission.
00020 #
00021 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 # POSSIBILITY OF SUCH DAMAGE.
00033 
00034 """
00035 Run a specified linter in a subprocess, checking its return status.
00036 
00037 This is a unit test script for roslint.
00038 """
00039 
00040 from __future__ import print_function
00041 
00042 import sys
00043 import subprocess
00044 
00045 def main(returnstatus, linter, files):
00046     """ Main program.
00047 
00048     :param: returnstatus expected return status
00049     :param: linter command string for running the linter with its options.
00050     :param: files list of file names to process
00051 
00052     :returns: 0 if test successful, 1 otherwise.
00053     """
00054     cmd = linter.split() + files
00055     print('lint command: ' + ' '.join(cmd))
00056     sub_rc = subprocess.call(cmd)
00057     if sub_rc != int(returnstatus):
00058         return 1
00059     else:
00060         return 0
00061 
00062 
00063 if __name__ == '__main__':
00064 
00065     # for some reason, pylint wants this variable name to be uppercase:
00066     #pylint: disable=C0103
00067     ret_status = -9             # return status for missing args
00068     if len(sys.argv) > 3:
00069         ret_status = main(sys.argv[1], sys.argv[2], sys.argv[3:])
00070     else:
00071         print('usage: runlint returnstatus linter file1 [ file2 ... ]')
00072     sys.exit(ret_status)


roslint
Author(s): Mike Purvis, Jack O'Quin
autogenerated on Fri Aug 28 2015 12:41:58