Skip to content

Commit

Permalink
SERVER-5057 safely invoke smoke.py from SConscript.smoke
Browse files Browse the repository at this point in the history
this correctly handles arguments with spaces, quotes, etc
  • Loading branch information
Dan Crosta committed Feb 23, 2012
1 parent 51fbd62 commit 51e9b45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion SConscript.smoke
Expand Up @@ -44,7 +44,7 @@ def addSmoketest( name, deps ):
target = name[5].lower() + name[6:]

smokeArgs = smokeFlags + [target]
addTest(name, deps, utils.smoke_command(*smokeArgs))
addTest(name, deps, utils.run_smoke_command(*smokeArgs))

addSmoketest( "smoke", [ add_exe( "test" ), add_exe( "mongod" ), add_exe( "mongo" ) ] )
addSmoketest( "smokePerf", [ add_exe("perftest") ] )
Expand Down
12 changes: 9 additions & 3 deletions buildscripts/utils.py
Expand Up @@ -176,9 +176,15 @@ def find_python(min_version=(2, 5)):
raise Exception('could not find suitable Python (version >= %s)' % '.'.join(min_version))

def smoke_command(*args):
# return a list of arguments that comprises a complete
# invocation of smoke.py
here = os.path.dirname(__file__)
smoke_py = os.path.abspath(os.path.join(here, 'smoke.py'))
return ' '.join(itertools.chain(
(find_python(), smoke_py),
args))
return [find_python(), smoke_py] + list(args)

def run_smoke_command(*args):
# to run a command line script from a scons Alias (or any
# Action), the command sequence must be enclosed in a list,
# otherwise SCons treats it as a list of dependencies.
return [smoke_command(*args)]

0 comments on commit 51e9b45

Please sign in to comment.