From f28e561da6176aa70ca3d7548148b9ffef6dff3a Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Thu, 17 Jul 2014 14:27:05 +0100 Subject: [PATCH] Added new switch -u. Now you can force test suite to shuffle test execution order so your tests are executed in random order --- workspace_tools/singletest.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/workspace_tools/singletest.py b/workspace_tools/singletest.py index 8b03ff2f2d..2149ec5750 100644 --- a/workspace_tools/singletest.py +++ b/workspace_tools/singletest.py @@ -91,6 +91,7 @@ import pprint import re import os from types import ListType +import random from os.path import join, abspath, dirname, exists, basename from shutil import copy @@ -830,6 +831,12 @@ if __name__ == '__main__': dest='firmware_global_name', help='Set global name for all produced projects. E.g. you can call all test binaries firmware.bin') + parser.add_option('-u', '--shuffle-tests', + dest='shuffle_test_order', + default=False, + action="store_true", + help='Shuffles test execution order') + parser.add_option('', '--verbose-skipped', dest='verbose_skipped_tests', default=False, @@ -922,7 +929,13 @@ if __name__ == '__main__': build_dir = join(BUILD_DIR, "test", target, toolchain) - for test_id, test in TEST_MAP.iteritems(): + # Enumerate through all tests + test_map_keys = TEST_MAP.keys() + if opts.shuffle_test_order: + random.shuffle(test_map_keys) + + for test_id in test_map_keys: + test = TEST_MAP[test_id] if opts.test_by_names and test_id not in opts.test_by_names.split(','): continue