Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
options.py
00001 """ 00002 Copyright (c) 2018, Arm Limited 00003 SPDX-License-Identifier: Apache-2.0 00004 00005 Licensed under the Apache License, Version 2.0 (the "License"); 00006 you may not use this file except in compliance with the License. 00007 You may obtain a copy of the License at 00008 00009 http://www.apache.org/licenses/LICENSE-2.0 00010 00011 Unless required by applicable law or agreed to in writing, software 00012 distributed under the License is distributed on an "AS IS" BASIS, 00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 See the License for the specific language governing permissions and 00015 limitations under the License. 00016 00017 00018 UNIT TEST OPTIONS 00019 """ 00020 00021 import argparse 00022 import logging 00023 00024 from .settings import CMAKE_GENERATORS, MAKE_PROGRAMS, COVERAGE_ARGS 00025 from .get_tools import get_make_tool 00026 00027 def get_options_parser (): 00028 """ 00029 Create a unit test options parser. 00030 00031 Returns a parser object 00032 """ 00033 00034 parser = argparse.ArgumentParser() 00035 00036 log_group = parser.add_mutually_exclusive_group() 00037 00038 log_group.add_argument("-v", 00039 "--verbose", 00040 help="Verbose output", 00041 action="store_const", 00042 const=logging.getLevelName(logging.DEBUG), 00043 dest="log_level") 00044 00045 log_group.add_argument("--quiet", 00046 help="Quiet output", 00047 action="store_const", 00048 const=logging.getLevelName(logging.ERROR), 00049 dest="log_level") 00050 00051 parser.add_argument("--compile", 00052 action="store_true", 00053 help="Only compile unit tests", 00054 dest="compile_only") 00055 00056 parser.add_argument("--run", 00057 action="store_true", 00058 help="Only run unit tests", 00059 dest="run_only") 00060 00061 parser.add_argument("-c", 00062 "--clean", 00063 action="store_true", 00064 help="Clean the build directory", 00065 dest="clean") 00066 00067 parser.add_argument("-d", 00068 "--debug", 00069 action="store_true", 00070 help="Enable debug build", 00071 dest="debug_build") 00072 00073 parser.add_argument("--coverage", 00074 choices=COVERAGE_ARGS, 00075 help="Generate code coverage report", 00076 dest="coverage") 00077 00078 parser.add_argument("--include-headers", 00079 action="store_true", 00080 help="Include headers to coverage reports, defaults to false.", 00081 dest="include_headers") 00082 00083 parser.add_argument("-m", 00084 "--make-program", 00085 default=get_make_tool(), 00086 choices=MAKE_PROGRAMS, 00087 help="Which make program to use", 00088 dest="make_program") 00089 00090 parser.add_argument("-g", 00091 "--generator", 00092 choices=CMAKE_GENERATORS, 00093 help="Which CMake generator to use", 00094 dest="cmake_generator") 00095 00096 parser.add_argument("-r", 00097 "--regex", 00098 help="Run tests matching a regular expression", 00099 dest="test_regex") 00100 00101 parser.add_argument("--build", 00102 default="build", 00103 help="Build directory. Default: UNITTESTS/build/", 00104 dest="build") 00105 00106 parser.add_argument("--new", 00107 action="append", 00108 help="Source file from which to generate test files. E.g. rtos/Semaphore.cpp", 00109 metavar="FILEPATH", 00110 dest="new_files") 00111 00112 return parser 00113 00114 def pretty_print_test_options (options=None): 00115 """ 00116 Pretty print test options 00117 00118 Keyword arguments: 00119 options - options 00120 """ 00121 00122 if options is None: 00123 return 00124 00125 # Mode 00126 logging.info(""" 00127 ##################### 00128 Mbed OS unit testing: 00129 ##################### 00130 """) 00131 00132 logging.info("Steps:\n") 00133 00134 logging.info(" [%s] \tPrepare build directory", "AUTO") 00135 logging.info(" \t\t - Clean: %s", options.clean) 00136 logging.info(" \t\t - Directory: %s\n", options.build) 00137 status = "SET" if options.compile_only else "UNSET" 00138 logging.info(" [%s] \tBuild unit tests", status) 00139 logging.info(" \t\t - Debug: %s", options.debug_build) 00140 logging.info(" \t\t - CMake generator: %s", options.cmake_generator) 00141 logging.info(" \t\t - Make program: %s\n", options.make_program) 00142 status = "SET" if options.run_only else "UNSET" 00143 logging.info(" [%s] \tRun unit tests", status) 00144 logging.info(" \t\t - Filter: %s\n", options.test_regex) 00145 if options.coverage: 00146 logging.info(" [%s] \tGenerate coverage reports", "SET") 00147 logging.info(" \t\t - Output: %s", options.coverage) 00148 logging.info(" \t\t - Include headers: %s", options.include_headers)
Generated on Tue Aug 9 2022 00:37:17 by
1.7.2