kumquat-buildroot/support/testing/run-tests
Luca Ceresoli fa3c5cad44 support/testing/run-tests: help: put the one-letter form before the long form
This is what the manpages usually do, and what Python does with the
automatically-added -h/--help parameter:

Before the change:
  $ ./support/testing/run-tests
    [...]
  optional arguments:
    -h, --help            show this help message and exit
    --list, -l            list of available test cases
    --all, -a             execute all test cases

After the change:
  $ ./support/testing/run-tests
    [...]
  optional arguments:
    -h, --help            show this help message and exit
    -l, --list            list of available test cases
    -a, --all             execute all test cases

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2017-05-17 21:56:49 +02:00

84 lines
2.5 KiB
Python
Executable File

#!/usr/bin/env python2
import argparse
import sys
import os
import nose2
from infra.basetest import BRTest
def main():
parser = argparse.ArgumentParser(description='Run Buildroot tests')
parser.add_argument('testname', nargs='*',
help='list of test cases to execute')
parser.add_argument('-l', '--list', action='store_true',
help='list of available test cases')
parser.add_argument('-a', '--all', action='store_true',
help='execute all test cases')
parser.add_argument('-s', '--stdout', action='store_true',
help='log everything to stdout')
parser.add_argument('-o', '--output',
help='output directory')
parser.add_argument('-d', '--download',
help='download directory')
parser.add_argument('-k', '--keep',
help='keep build directories',
action='store_true')
args = parser.parse_args()
script_path = os.path.realpath(__file__)
test_dir = os.path.dirname(script_path)
if args.stdout:
BRTest.logtofile = False
if args.list:
print "List of tests"
nose2.discover(argv=[script_path,
"-s", test_dir,
"-v",
"--collect-only"],
plugins=["nose2.plugins.collect"])
return 0
if args.download is None:
args.download = os.getenv("BR2_DL_DIR")
if args.download is None:
print "Missing download directory, please use -d/--download"
print ""
parser.print_help()
return 1
BRTest.downloaddir = os.path.abspath(args.download)
if args.output is None:
print "Missing output directory, please use -o/--output"
print ""
parser.print_help()
return 1
if not os.path.exists(args.output):
os.mkdir(args.output)
BRTest.outputdir = os.path.abspath(args.output)
if args.all is False and len(args.testname) == 0:
print "No test selected"
print ""
parser.print_help()
return 1
BRTest.keepbuilds = args.keep
nose2_args = ["-v",
"-s", "support/testing",
"-c", "support/testing/conf/unittest.cfg"]
if len(args.testname) != 0:
nose2_args += args.testname
nose2.discover(argv=nose2_args)
if __name__ == "__main__":
sys.exit(main())