From 406e0fa86d97f912b50689d6b080c2aee69eef86 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 18 Apr 2017 11:59:02 +0200 Subject: [PATCH] allow selecting individual tests with runtests.py If arguments are passed on the command line, interpret them as test names and attempt to compose a suite comprising only the tests specified. The behavior remains the same if invoked without argument. --- runtests.py | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 43 insertions(+), 2 deletions(-) diff --git a/runtests.py b/runtests.py index a168d8b..fe2e570 100755 --- a/runtests.py +++ b/runtests.py @@ -32,5 +32,46 @@ from testing.test_deltatar import (DeltaTarTest, DeltaTar2Test, from testing.test_compression_level import suite if __name__ == "__main__": - unittest.TextTestRunner().run(suite()) - unittest.main() + import sys + if len (sys.argv) == 1: + unittest.TextTestRunner().run(suite()) + unittest.main() + else: + suite = unittest.TestSuite () + def add (n): + ret = False + for group in [#testing.test_multivol + MultivolGnuFormatTest, MultivolPaxFormatTest + # testing.test_concat_compress + , ConcatCompressTest + # testing.test_rescue_tar + , RescueTarTest + # testing.test_encryption + , EncryptionTest + # testing.test_deltatar + , DeltaTarTest, DeltaTar2Test + , DeltaTarStreamTest, DeltaTarGzipTest + , DeltaTarGzipStreamTest, DeltaTarGzipConcatTest + , DeltaTarGzipAes128ConcatTest + , DeltaTarGzipAes256ConcatTest + , DeltaTarAes128ConcatTest, DeltaTarAes256ConcatTest + ]: + try: + t = group (n) + except ValueError: # no such test + continue + print ("including “%s”" % n) + suite.addTest(t) + ret = True + return ret + n = 0 + for arg in sys.argv [1:]: + if add (arg) is True: + n += 1 + if n == 0: + print ("ERROR: no valid test name specified, please double-check", + file=sys.stderr) + sys.exit (-1) + runner = unittest.TextTestRunner () + runner.run (suite) + -- 1.7.1