forked from ARMmbed/mbed-os
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.py
More file actions
153 lines (121 loc) · 5.11 KB
/
Copy pathoptions.py
File metadata and controls
153 lines (121 loc) · 5.11 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
"""
Copyright (c) 2018, Arm Limited
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
UNIT TEST OPTIONS
"""
import argparse
import logging
from .settings import CMAKE_GENERATORS, MAKE_PROGRAMS, COVERAGE_ARGS
from .get_tools import get_make_tool
def get_options_parser():
"""
Create a unit test options parser.
Returns a parser object
"""
parser = argparse.ArgumentParser()
log_group = parser.add_mutually_exclusive_group()
log_group.add_argument("-v",
"--verbose",
help="Verbose output",
action="store_const",
const=logging.getLevelName(logging.DEBUG),
dest="log_level")
log_group.add_argument("--quiet",
help="Quiet output",
action="store_const",
const=logging.getLevelName(logging.ERROR),
dest="log_level")
parser.add_argument("--compile",
action="store_true",
help="Only compile unit tests",
dest="compile_only")
parser.add_argument("--run",
action="store_true",
help="Only run unit tests",
dest="run_only")
parser.add_argument("-c",
"--clean",
action="store_true",
help="Clean the build directory",
dest="clean")
parser.add_argument("-d",
"--debug",
action="store_true",
help="Enable debug build",
dest="debug_build")
parser.add_argument("--coverage",
choices=COVERAGE_ARGS,
help="Generate code coverage report",
dest="coverage")
parser.add_argument("--include-headers",
action="store_true",
help="Include headers to coverage reports, defaults to false.",
dest="include_headers")
parser.add_argument("-m",
"--make-program",
default=get_make_tool(),
choices=MAKE_PROGRAMS,
help="Which make program to use",
dest="make_program")
parser.add_argument("-g",
"--generator",
choices=CMAKE_GENERATORS,
help="Which CMake generator to use",
dest="cmake_generator")
parser.add_argument("-r",
"--regex",
help="Run tests matching a regular expression",
dest="test_regex")
parser.add_argument("--build",
default="build",
help="Build directory. Default: UNITTESTS/build/",
dest="build")
parser.add_argument("--valgrind",
help="Use Valgrind when running executables",
action="store_true",
dest="valgrind")
parser.add_argument("--new",
action="append",
help="Source file from which to generate test files. E.g. rtos/Semaphore.cpp",
metavar="FILEPATH",
dest="new_files")
return parser
def pretty_print_test_options(options=None):
"""
Pretty print test options
Keyword arguments:
options - options
"""
if options is None:
return
# Mode
logging.info("""
#####################
Mbed OS unit testing:
#####################
""")
logging.info("Steps:\n")
logging.info(" [%s] \tPrepare build directory", "AUTO")
logging.info(" \t\t - Clean: %s", options.clean)
logging.info(" \t\t - Directory: %s\n", options.build)
status = "SET" if options.compile_only else "UNSET"
logging.info(" [%s] \tBuild unit tests", status)
logging.info(" \t\t - Debug: %s", options.debug_build)
logging.info(" \t\t - CMake generator: %s", options.cmake_generator)
logging.info(" \t\t - Make program: %s\n", options.make_program)
status = "SET" if options.run_only else "UNSET"
logging.info(" [%s] \tRun unit tests", status)
logging.info(" \t\t - Filter: %s\n", options.test_regex)
if options.coverage:
logging.info(" [%s] \tGenerate coverage reports", "SET")
logging.info(" \t\t - Output: %s", options.coverage)
logging.info(" \t\t - Include headers: %s", options.include_headers)