forked from google/timesketch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
executable file
·64 lines (50 loc) · 1.68 KB
/
run_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
"""Main entry point for running tests and linters."""
from __future__ import print_function
from __future__ import unicode_literals
import subprocess
import argparse
def run_python_tests(coverage=False):
try:
if coverage:
subprocess.check_call((
'nosetests --with-coverage'
' --cover-package=timesketch_api_client,'
'timesketch_import_client,timesketch'
' api_client/python/ timesketch/'
' cli_client/python/'), shell=True)
else:
subprocess.check_call(
['nosetests', '-x', 'timesketch/', 'api_client/python/',
'importer_client/python', 'cli_client/python/'])
finally:
subprocess.check_call(['rm', '-f', '.coverage'])
def run_python(args):
if not args.no_tests:
run_python_tests(coverage=args.coverage)
def parse_cli_args(args=None):
"""Parse command-line arguments to this script.
Args:
args: List of cli arguments not including program name
Returns:
Instance of argparse.Namespace with the following boolean attributes:
py, js, selenium, full, no_tests, coverage
Raises:
SystemExit if arguments are invalid or --help is present.
"""
p = argparse.ArgumentParser(
description="Run Python unit tests and linters."
)
p.add_argument(
'--no-tests', action='store_true',
help='Skip tests, run only linters.'
)
p.add_argument(
'--coverage', action='store_true',
help='Print code coverage report.'
)
return p.parse_args(args)
def main():
args = parse_cli_args()
run_python(args)
main()