Add --vagrant switch to the php test-runner
Added -V|--vagrant switch to the php test-runner to run the tests in the Vagrant VM refs #4264
This commit is contained in:
parent
7c50411270
commit
747d8b31e8
|
@ -3,6 +3,7 @@
|
|||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from pipes import quote
|
||||
from fnmatch import fnmatch
|
||||
from optparse import OptionParser, BadOptionError, AmbiguousOptionError
|
||||
|
||||
|
@ -10,6 +11,7 @@ from optparse import OptionParser, BadOptionError, AmbiguousOptionError
|
|||
APPLICATION = 'phpunit'
|
||||
DEFAULT_ARGS = ['--strict', '--static-backup']
|
||||
|
||||
VAGRANT_SCRIPT = '/vagrant/test/php/runtests'
|
||||
REPORT_DIRECTORY = '../../build/log'
|
||||
|
||||
|
||||
|
@ -64,14 +66,29 @@ def parse_commandline():
|
|||
help='Enable reporting.')
|
||||
parser.add_option('-v', '--verbose', action='store_true',
|
||||
help='Be more verbose.')
|
||||
parser.add_option('-i', '--include', metavar='PATTERN', action='store',
|
||||
parser.add_option('-i', '--include', metavar='PATTERN',
|
||||
help='Include only specific files/test cases.')
|
||||
parser.add_option('-V', '--vagrant', action='store_true',
|
||||
help='Run in vagrant VM')
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
options, arguments = parse_commandline()
|
||||
|
||||
if options.vagrant and os.environ['USER'] != 'vagrant':
|
||||
# Check if vagrant is installed
|
||||
vagrant_path = execute_command('which vagrant', True, True).strip()
|
||||
if not vagrant_path:
|
||||
print 'ERROR: vagrant not found!'
|
||||
return 2
|
||||
|
||||
# Call the script in the Vagrant VM with the same parameters
|
||||
commandline = ' '.join(quote(p) for p in sys.argv[1:])
|
||||
return execute_command('vagrant ssh -c "{0} {1}"'
|
||||
''.format(VAGRANT_SCRIPT, commandline),
|
||||
shell=True)
|
||||
else:
|
||||
# Environment preparation and verification
|
||||
os.chdir(get_script_directory())
|
||||
application_path = execute_command('which {0}'.format(APPLICATION),
|
||||
|
|
Loading…
Reference in New Issue