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",
|
"build": "python ./script/build.py -c D",
|
||||||
"clean": "python ./script/clean.py",
|
"clean": "python ./script/clean.py",
|
||||||
"clean-build": "python ./script/clean.py --build",
|
"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",
|
"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": "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",
|
"lint-js": "standard && cd spec && standard",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import argparse
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -17,9 +18,8 @@ PRODUCT_NAME = electron_gyp()['product_name%']
|
||||||
def main():
|
def main():
|
||||||
os.chdir(SOURCE_ROOT)
|
os.chdir(SOURCE_ROOT)
|
||||||
|
|
||||||
config = 'D'
|
args = parse_args()
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == '-R':
|
config = args.configuration
|
||||||
config = 'R'
|
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
electron = os.path.join(SOURCE_ROOT, 'out', config,
|
electron = os.path.join(SOURCE_ROOT, 'out', config,
|
||||||
|
@ -36,10 +36,9 @@ def main():
|
||||||
electron = os.path.join(SOURCE_ROOT, 'out', config, PROJECT_NAME)
|
electron = os.path.join(SOURCE_ROOT, 'out', config, PROJECT_NAME)
|
||||||
resources_path = os.path.join(SOURCE_ROOT, 'out', config)
|
resources_path = os.path.join(SOURCE_ROOT, 'out', config)
|
||||||
|
|
||||||
use_instrumented_asar = '--use-instrumented-asar' in sys.argv
|
|
||||||
returncode = 0
|
returncode = 0
|
||||||
try:
|
try:
|
||||||
if use_instrumented_asar:
|
if args.use_instrumented_asar:
|
||||||
install_instrumented_asar_file(resources_path)
|
install_instrumented_asar_file(resources_path)
|
||||||
subprocess.check_call([electron, 'spec'] + sys.argv[1:])
|
subprocess.check_call([electron, 'spec'] + sys.argv[1:])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
|
@ -47,7 +46,7 @@ def main():
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
returncode = 0
|
returncode = 0
|
||||||
|
|
||||||
if use_instrumented_asar:
|
if args.use_instrumented_asar:
|
||||||
restore_uninstrumented_asar_file(resources_path)
|
restore_uninstrumented_asar_file(resources_path)
|
||||||
|
|
||||||
if os.environ.has_key('OUTPUT_TO_FILE'):
|
if os.environ.has_key('OUTPUT_TO_FILE'):
|
||||||
|
@ -60,6 +59,19 @@ def main():
|
||||||
return returncode
|
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):
|
def install_instrumented_asar_file(resources_path):
|
||||||
asar_path = os.path.join(resources_path, '{0}.asar'.format(PROJECT_NAME))
|
asar_path = os.path.join(resources_path, '{0}.asar'.format(PROJECT_NAME))
|
||||||
uninstrumented_path = os.path.join(resources_path,
|
uninstrumented_path = os.path.join(resources_path,
|
||||||
|
|
Loading…
Reference in a new issue