Skip to content

Commit

Permalink
can pass a list of files to lint.py
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Oct 16, 2012
1 parent 7db66f2 commit 814807a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ env.AlwaysBuild( "style" )

def doLint( env , target , source ):
import buildscripts.lint
if not buildscripts.lint.run_lint():
if not buildscripts.lint.run_lint( [ "src/mongo/" ] ):
raise Exception( "lint errors" )

env.Alias( "lint" , [] , [ doLint ] )
Expand Down
16 changes: 11 additions & 5 deletions buildscripts/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import utils


def run_lint( prefix="src/mongo", nudgeOn=False ):
def run_lint( paths, nudgeOn=False ):
# errors are as of 10/14
# idea is not to let it any new type of error
# as we knock one out, we should remove line
Expand Down Expand Up @@ -53,9 +53,12 @@ def run_lint( prefix="src/mongo", nudgeOn=False ):
if not nudgeOn:
filters = filters + nudge


sourceFiles = []
for x in paths:
utils.getAllSourceFiles( sourceFiles, x )


sourceFiles = utils.getAllSourceFiles( prefix=prefix )
args = [ "--filter=" + ",".join( filters ) , "--counting=detailed" ] + sourceFiles
filenames = cpplint.ParseArguments( args )

Expand Down Expand Up @@ -84,7 +87,7 @@ def _ourIsTestFilename(fn):


if __name__ == "__main__":
prefix = "src/mongo"
paths = []
nudge = False

for arg in sys.argv[1:]:
Expand All @@ -95,7 +98,10 @@ def _ourIsTestFilename(fn):
else:
print( "unknown arg [%s]" % arg )
sys.exit(-1)
prefix = arg
paths.append( arg )

if not run_lint( prefix, nudge ):
if len(paths) == 0:
paths.append( "src/mongo/" )

if not run_lint( paths, nudge ):
sys.exit(-1)
1 change: 1 addition & 0 deletions buildscripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def getAllSourceFiles( arr=None , prefix="." ):
getAllSourceFiles( arr , full )
else:
if full.endswith( ".cpp" ) or full.endswith( ".h" ) or full.endswith( ".c" ):
full = full.replace( "//" , "/" )
arr.append( full )

return arr
Expand Down

0 comments on commit 814807a

Please sign in to comment.