Parse args in test.py
This commit is contained in:
parent
6b787ae4e0
commit
f67968d244
2 changed files with 19 additions and 7 deletions
|
@ -29,7 +29,7 @@
|
|||
"build": "python ./script/build.py -c D",
|
||||
"clean": "python ./script/clean.py",
|
||||
"clean-build": "python ./script/clean.py --build",
|
||||
"coverage": "npm run instrument-code-coverage && npm test -- --use-instrumented-asar",
|
||||
"coverage": "npm run instrument-code-coverage && npm test -- --use_instrumented_asar",
|
||||
"instrument-code-coverage": "electabul instrument --input-path ./lib --output-path ./out/coverage/electron.asar",
|
||||
"lint": "npm run lint-js && npm run lint-cpp && npm run lint-py && npm run lint-api-docs-js && npm run lint-api-docs",
|
||||
"lint-js": "standard && cd spec && standard",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
@ -17,9 +18,8 @@ PRODUCT_NAME = electron_gyp()['product_name%']
|
|||
def main():
|
||||
os.chdir(SOURCE_ROOT)
|
||||
|
||||
config = 'D'
|
||||
if len(sys.argv) == 2 and sys.argv[1] == '-R':
|
||||
config = 'R'
|
||||
args = parse_args()
|
||||
config = args.configuration
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
electron = os.path.join(SOURCE_ROOT, 'out', config,
|
||||
|
@ -36,10 +36,9 @@ def main():
|
|||
electron = os.path.join(SOURCE_ROOT, 'out', config, PROJECT_NAME)
|
||||
resources_path = os.path.join(SOURCE_ROOT, 'out', config)
|
||||
|
||||
use_instrumented_asar = '--use-instrumented-asar' in sys.argv
|
||||
returncode = 0
|
||||
try:
|
||||
if use_instrumented_asar:
|
||||
if args.use_instrumented_asar:
|
||||
install_instrumented_asar_file(resources_path)
|
||||
subprocess.check_call([electron, 'spec'] + sys.argv[1:])
|
||||
except subprocess.CalledProcessError as e:
|
||||
|
@ -47,7 +46,7 @@ def main():
|
|||
except KeyboardInterrupt:
|
||||
returncode = 0
|
||||
|
||||
if use_instrumented_asar:
|
||||
if args.use_instrumented_asar:
|
||||
restore_uninstrumented_asar_file(resources_path)
|
||||
|
||||
if os.environ.has_key('OUTPUT_TO_FILE'):
|
||||
|
@ -60,6 +59,19 @@ def main():
|
|||
return returncode
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description='Run Electron tests')
|
||||
parser.add_argument('--use_instrumented_asar',
|
||||
help='Run tests with coverage instructed asar file',
|
||||
action='store_true',
|
||||
required=False)
|
||||
parser.add_argument('-c', '--configuration',
|
||||
help='Build configuration to run tests against',
|
||||
default='D',
|
||||
required=False)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def install_instrumented_asar_file(resources_path):
|
||||
asar_path = os.path.join(resources_path, '{0}.asar'.format(PROJECT_NAME))
|
||||
uninstrumented_path = os.path.join(resources_path,
|
||||
|
|
Loading…
Reference in a new issue