Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools: unittest_helper: add a quiet mode

On quiet mode, only report errors.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <27556792ff70e6267ecd19c258149d380db8d423.1774551940.git.mchehab+huawei@kernel.org>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
07f6cb18 ece7e57a

+16 -6
+16 -6
tools/lib/python/unittest_helper.py
··· 141 141 super().addSkip(test, reason) 142 142 self._record_test(test, f"SKIP ({reason})") 143 143 144 - def printResults(self): 144 + def printResults(self, verbose): 145 145 """ 146 146 Print results using colors if tty. 147 147 """ ··· 174 174 175 175 # Print results 176 176 for module_name, classes in self.test_results.items(): 177 - print(f"{module_name}:") 177 + if verbose: 178 + print(f"{module_name}:") 178 179 for class_name, tests in classes.items(): 179 - print(f" {class_name}:") 180 + if verbose: 181 + print(f" {class_name}:") 180 182 for test_name, status in tests: 183 + if not verbose and status in [ "OK", "EXPECTED_FAIL" ]: 184 + continue 185 + 181 186 # Get base status without reason for SKIP 182 187 if status.startswith("SKIP"): 183 188 status_code = status.split()[0] ··· 192 187 print( 193 188 f" {test_name + ':':<{max_length}}{color}{status}{COLORS['reset']}" 194 189 ) 195 - print() 190 + if verbose: 191 + print() 196 192 197 193 # Print summary 198 194 print(f"\nRan {self.testsRun} tests", end="") ··· 236 230 """Returns a parser for command line arguments.""" 237 231 parser = argparse.ArgumentParser(description="Test runner with regex filtering") 238 232 parser.add_argument("-v", "--verbose", action="count", default=1) 233 + parser.add_argument("-q", "--quiet", action="store_true") 239 234 parser.add_argument("-f", "--failfast", action="store_true") 240 235 parser.add_argument("-k", "--keyword", 241 236 help="Regex pattern to filter test methods") ··· 286 279 if not caller_file and not suite: 287 280 raise TypeError("Either caller_file or suite is needed at TestUnits") 288 281 289 - verbose = args.verbose 282 + if args.quiet: 283 + verbose = 0 284 + else: 285 + verbose = args.verbose 290 286 291 287 if not env: 292 288 env = os.environ.copy() ··· 344 334 failfast=args.failfast) 345 335 result = runner.run(suite) 346 336 if resultclass: 347 - result.printResults() 337 + result.printResults(verbose) 348 338 349 339 sys.exit(not result.wasSuccessful()) 350 340