From 52113c6eade74c2728bad2f31a82c88fc6653e5a Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Mon, 2 Oct 2023 00:43:51 -0500 Subject: [PATCH] Moved the test/bench runner path behind an optional flag So now instead of needing: ./scripts/test.py ./runners/test_runner test_dtree You can just do: ./scripts/test.py test_dtree Or with an explicit path: ./scripts/test.py -R./runners/test_runner test_dtree This makes it easier to run the script manually. And, while there may be some hiccups with the implicit relative path, I think in general this will make the test/bench scripts easier to use. There was already an implicit runner path, though only if the test suite was completely omitted. I'm not sure that would ever have actually been useful... --- Also increased the permutation field size in --list-*, since I noticed it was overflowing. --- Makefile | 8 ++++---- runners/bench_runner.c | 12 ++++++------ runners/test_runner.c | 12 ++++++------ scripts/bench.py | 9 ++++----- scripts/test.py | 9 ++++----- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 86b24677..04c61fec 100644 --- a/Makefile +++ b/Makefile @@ -378,12 +378,12 @@ endif ## Run the tests, -j enables parallel tests .PHONY: test test: test-runner - ./scripts/test.py $(TEST_RUNNER) $(TESTFLAGS) + ./scripts/test.py -R$(TEST_RUNNER) $(TESTFLAGS) ## List the tests .PHONY: test-list test-list: test-runner - ./scripts/test.py $(TEST_RUNNER) $(TESTFLAGS) -l + ./scripts/test.py -R$(TEST_RUNNER) $(TESTFLAGS) -l ## Summarize the testmarks .PHONY: testmarks @@ -430,12 +430,12 @@ endif ## Run the benchmarks, -j enables parallel benchmarks .PHONY: bench bench: bench-runner - ./scripts/bench.py $(BENCH_RUNNER) $(BENCHFLAGS) + ./scripts/bench.py -R$(BENCH_RUNNER) $(BENCHFLAGS) ## List the benchmarks .PHONY: bench-list bench-list: bench-runner - ./scripts/bench.py $(BENCH_RUNNER) $(BENCHFLAGS) -l + ./scripts/bench.py -R$(BENCH_RUNNER) $(BENCHFLAGS) -l ## Summarize the benchmarks .PHONY: benchmarks diff --git a/runners/bench_runner.c b/runners/bench_runner.c index 66d56221..44a3637f 100644 --- a/runners/bench_runner.c +++ b/runners/bench_runner.c @@ -835,7 +835,7 @@ void perm_count( // operations we can do static void summary(void) { - printf("%-23s %7s %7s %7s %11s\n", + printf("%-23s %7s %7s %7s %15s\n", "", "flags", "suites", "cases", "perms"); size_t suites = 0; size_t cases = 0; @@ -877,7 +877,7 @@ static void summary(void) { sprintf(flag_buf, "%s%s", (flags & BENCH_INTERNAL) ? "i" : "", (!flags) ? "-" : ""); - printf("%-23s %7s %7zu %7zu %11s\n", + printf("%-23s %7s %7zu %7zu %15s\n", "TOTAL", flag_buf, suites, @@ -896,7 +896,7 @@ static void list_suites(void) { } name_width = 4*((name_width+1+4-1)/4)-1; - printf("%-*s %7s %7s %11s\n", + printf("%-*s %7s %7s %15s\n", name_width, "suite", "flags", "cases", "perms"); for (size_t t = 0; t < bench_id_count; t++) { for (size_t i = 0; i < bench_suite_count; i++) { @@ -936,7 +936,7 @@ static void list_suites(void) { sprintf(flag_buf, "%s%s", (bench_suites[i]->flags & BENCH_INTERNAL) ? "i" : "", (!bench_suites[i]->flags) ? "-" : ""); - printf("%-*s %7s %7zu %11s\n", + printf("%-*s %7s %7zu %15s\n", name_width, bench_suites[i]->name, flag_buf, @@ -959,7 +959,7 @@ static void list_cases(void) { } name_width = 4*((name_width+1+4-1)/4)-1; - printf("%-*s %7s %11s\n", name_width, "case", "flags", "perms"); + printf("%-*s %7s %15s\n", name_width, "case", "flags", "perms"); for (size_t t = 0; t < bench_id_count; t++) { for (size_t i = 0; i < bench_suite_count; i++) { bench_define_suite(bench_suites[i]); @@ -991,7 +991,7 @@ static void list_cases(void) { ? "i" : "", (!bench_suites[i]->cases[j].flags) ? "-" : ""); - printf("%-*s %7s %11s\n", + printf("%-*s %7s %15s\n", name_width, bench_suites[i]->cases[j].name, flag_buf, diff --git a/runners/test_runner.c b/runners/test_runner.c index 75a1e6cc..4e1eeb7f 100644 --- a/runners/test_runner.c +++ b/runners/test_runner.c @@ -864,7 +864,7 @@ void perm_count( // operations we can do static void summary(void) { - printf("%-23s %7s %7s %7s %11s\n", + printf("%-23s %7s %7s %7s %15s\n", "", "flags", "suites", "cases", "perms"); size_t suites = 0; size_t cases = 0; @@ -909,7 +909,7 @@ static void summary(void) { (flags & TEST_REENTRANT) ? "r" : "", (flags & TEST_INTERNAL) ? "i" : "", (!flags) ? "-" : ""); - printf("%-23s %7s %7zu %7zu %11s\n", + printf("%-23s %7s %7zu %7zu %15s\n", "TOTAL", flag_buf, suites, @@ -928,7 +928,7 @@ static void list_suites(void) { } name_width = 4*((name_width+1+4-1)/4)-1; - printf("%-*s %7s %7s %11s\n", + printf("%-*s %7s %7s %15s\n", name_width, "suite", "flags", "cases", "perms"); for (size_t t = 0; t < test_id_count; t++) { for (size_t i = 0; i < test_suite_count; i++) { @@ -971,7 +971,7 @@ static void list_suites(void) { (test_suites[i]->flags & TEST_REENTRANT) ? "r" : "", (test_suites[i]->flags & TEST_INTERNAL) ? "i" : "", (!test_suites[i]->flags) ? "-" : ""); - printf("%-*s %7s %7zu %11s\n", + printf("%-*s %7s %7zu %15s\n", name_width, test_suites[i]->name, flag_buf, @@ -994,7 +994,7 @@ static void list_cases(void) { } name_width = 4*((name_width+1+4-1)/4)-1; - printf("%-*s %7s %11s\n", name_width, "case", "flags", "perms"); + printf("%-*s %7s %15s\n", name_width, "case", "flags", "perms"); for (size_t t = 0; t < test_id_count; t++) { for (size_t i = 0; i < test_suite_count; i++) { test_define_suite(test_suites[i]); @@ -1030,7 +1030,7 @@ static void list_cases(void) { ? "i" : "", (!test_suites[i]->cases[j].flags) ? "-" : ""); - printf("%-*s %7s %11s\n", + printf("%-*s %7s %15s\n", name_width, test_suites[i]->cases[j].name, flag_buf, diff --git a/scripts/bench.py b/scripts/bench.py index 0df7f5c9..1c32a9b0 100755 --- a/scripts/bench.py +++ b/scripts/bench.py @@ -1429,15 +1429,14 @@ if __name__ == "__main__": # bench flags bench_parser = parser.add_argument_group('bench options') - bench_parser.add_argument( - 'runner', - nargs='?', - type=lambda x: x.split(), - help="Bench runner to use for benching. Defaults to %r." % RUNNER_PATH) bench_parser.add_argument( 'bench_ids', nargs='*', help="Description of benches to run.") + bench_parser.add_argument( + '-R', '--runner', + type=lambda x: x.split(), + help="Bench runner to use for benching. Defaults to %r." % RUNNER_PATH) bench_parser.add_argument( '-Y', '--summary', action='store_true', diff --git a/scripts/test.py b/scripts/test.py index 57b80901..8e8c4d38 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -1457,15 +1457,14 @@ if __name__ == "__main__": # test flags test_parser = parser.add_argument_group('test options') - test_parser.add_argument( - 'runner', - nargs='?', - type=lambda x: x.split(), - help="Test runner to use for testing. Defaults to %r." % RUNNER_PATH) test_parser.add_argument( 'test_ids', nargs='*', help="Description of tests to run.") + test_parser.add_argument( + '-R', '--runner', + type=lambda x: x.split(), + help="Test runner to use for testing. Defaults to %r." % RUNNER_PATH) test_parser.add_argument( '-Y', '--summary', action='store_true',