mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 05:44:36 +02:00
Add --vagrant switch to the javascript test-runner
Added -V|--vagrant switch to the javascript test-runner to run the tests in the Vagrant VM refs #4264
This commit is contained in:
parent
a7a8836b5b
commit
d7ebe7fa08
@ -3,12 +3,14 @@
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from pipes import quote
|
||||
from optparse import OptionParser, BadOptionError, AmbiguousOptionError
|
||||
|
||||
|
||||
APPLICATION = 'mocha'
|
||||
DEFAULT_ARGS = ['--recursive', '--require', 'should']
|
||||
|
||||
VAGRANT_SCRIPT = '/vagrant/test/js/runtests'
|
||||
REPORT_DIRECTORY = '../../build/log'
|
||||
|
||||
|
||||
@ -69,12 +71,27 @@ def parse_commandline():
|
||||
parser.add_option('-e', '--exclude', metavar='PATTERN', action='append',
|
||||
help='Exclude specific files/test cases. '
|
||||
'(Can be supplied multiple times.)')
|
||||
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),
|
||||
@ -114,7 +131,8 @@ def main():
|
||||
result_data = execute_command([application_path] + DEFAULT_ARGS +
|
||||
command_options + arguments, True)
|
||||
coverage_data = execute_command([application_path] + DEFAULT_ARGS +
|
||||
more_command_options + arguments, True)
|
||||
more_command_options + arguments,
|
||||
return_output=True)
|
||||
# Result storage
|
||||
report_directory = get_report_directory()
|
||||
result_path = os.path.join(report_directory, 'mocha_results.xml')
|
||||
|
Loading…
x
Reference in New Issue
Block a user