From ba72497963ae80ae8800d7783952d90cc8d7ba4f Mon Sep 17 00:00:00 2001 From: lethosor Date: Wed, 1 Apr 2020 02:15:27 -0400 Subject: [PATCH] Add some rudimentary test selection support --- test/main.lua | 11 +++++++++++ travis/run-tests.py | 3 +++ 2 files changed, 14 insertions(+) diff --git a/test/main.lua b/test/main.lua index 1f72fd723..143b9cadc 100644 --- a/test/main.lua +++ b/test/main.lua @@ -242,6 +242,17 @@ function main() end print('Filtering tests') + if config.tests then + local orig_length = #tests + for i = #tests, 1, -1 do + for _, pattern in pairs(config.tests) do + if not tests[i].name:match(pattern) then + table.remove(tests, i) + end + end + end + print('Selected tests: ' .. #tests .. '/' .. orig_length) + end local status = load_test_status() or {} for i = #tests, 1, -1 do local test = tests[i] diff --git a/travis/run-tests.py b/travis/run-tests.py index fd15b5d93..70ab6cf20 100644 --- a/travis/run-tests.py +++ b/travis/run-tests.py @@ -17,6 +17,8 @@ parser.add_argument('--no-quit', action='store_true', help='Do not quit DF when done') parser.add_argument('--test-dir', '--test-folder', help='Base test folder (default: df_folder/test)') +parser.add_argument('-t', '--test', dest='tests', nargs='+', + help='Test(s) to run (Lua patterns accepted)') args = parser.parse_args() if (not sys.stdin.isatty() or not sys.stdout.isatty() or not sys.stderr.isatty()) and not args.headless: @@ -77,6 +79,7 @@ test_config_file = 'test_config.json' with open(test_config_file, 'w') as f: json.dump({ 'test_dir': args.test_dir, + 'tests': args.tests, }, f) try: