From b42592efbba2cf9fc3dfef16b1b3fb4379a7a8a5 Mon Sep 17 00:00:00 2001 From: Viktor Kirilov Date: Tue, 2 Feb 2021 16:19:30 +0200 Subject: [PATCH] officially supporting 'none' as sorting of test cases --- doc/markdown/commandline.md | 2 +- doctest/doctest.h | 5 ++++- doctest/parts/doctest.cpp | 5 ++++- examples/all_features/test_output/help.txt | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/markdown/commandline.md b/doc/markdown/commandline.md index b22db221b..4d9d97faf 100644 --- a/doc/markdown/commandline.md +++ b/doc/markdown/commandline.md @@ -32,7 +32,7 @@ All the options can also be set with code (defaults/overrides) if the user [**su | ```-sce``` ```--subcase-exclude=``` | Same as ```--test-case-exclude=``` but filters based on subcase names | | ```-r``` ```--reporters=``` | List of [**reporters**](reporters.md) to use (default is ```console```) | | ```-o```   ```--out=``` | Output filename | -| ```-ob```   ```--order-by=``` | Test cases will be sorted before being executed either by **the file in which they are** / **the test suite they are in** / **their name** / **random**. The possible values of `````` are ```file```/```suite```/```name```/```rand```. The default is ```file```. **NOTE: the order produced by the ```file```, ```suite``` and ```name``` options is compiler-dependent and might differ depending on the compiler used.** | +| ```-ob```   ```--order-by=``` | Test cases will be sorted before being executed either by **the file in which they are** / **the test suite they are in** / **their name** / **random**. The possible values of `````` are ```file```/```suite```/```name```/```rand```/```none```. The default is ```file```. **NOTE: the order produced by the ```file```, ```suite``` and ```name``` options is compiler-dependent and might differ depending on the compiler used.** | | ```-rs```   ```--rand-seed=``` | The seed for random ordering | | ```-f```     ```--first=``` | The **first** test case to execute which passes the current filters - for range-based execution - see [**the example python script**](../../examples/range_based_execution.py) | | ```-l```     ```--last=``` | The **last** test case to execute which passes the current filters - for range-based execution - see [**the example python script**](../../examples/range_based_execution.py) | diff --git a/doctest/doctest.h b/doctest/doctest.h index 2e7c2a2d7..b60421754 100644 --- a/doctest/doctest.h +++ b/doctest/doctest.h @@ -5606,7 +5606,7 @@ namespace { << Whitespace(sizePrefixDisplay*1) << "output filename\n"; s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ob, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "order-by= " << Whitespace(sizePrefixDisplay*1) << "how the tests should be ordered\n"; - s << Whitespace(sizePrefixDisplay*3) << " - by [file/suite/name/rand]\n"; + s << Whitespace(sizePrefixDisplay*3) << " - [file/suite/name/rand/none]\n"; s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "rs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "rand-seed= " << Whitespace(sizePrefixDisplay*1) << "seed for random ordering\n"; s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "f, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "first= " @@ -6307,6 +6307,9 @@ int Context::run() { first[i] = first[idxToSwap]; first[idxToSwap] = temp; } + } else if(p->order_by.compare("none", true) == 0) { + // means no sorting - beneficial for death tests which call into the executable + // with a specific test case in mind - we don't want to slow down the startup times } } diff --git a/doctest/parts/doctest.cpp b/doctest/parts/doctest.cpp index 5e084a813..a76193bbf 100644 --- a/doctest/parts/doctest.cpp +++ b/doctest/parts/doctest.cpp @@ -2937,7 +2937,7 @@ namespace { << Whitespace(sizePrefixDisplay*1) << "output filename\n"; s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ob, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "order-by= " << Whitespace(sizePrefixDisplay*1) << "how the tests should be ordered\n"; - s << Whitespace(sizePrefixDisplay*3) << " - by [file/suite/name/rand]\n"; + s << Whitespace(sizePrefixDisplay*3) << " - [file/suite/name/rand/none]\n"; s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "rs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "rand-seed= " << Whitespace(sizePrefixDisplay*1) << "seed for random ordering\n"; s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "f, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "first= " @@ -3638,6 +3638,9 @@ int Context::run() { first[i] = first[idxToSwap]; first[idxToSwap] = temp; } + } else if(p->order_by.compare("none", true) == 0) { + // means no sorting - beneficial for death tests which call into the executable + // with a specific test case in mind - we don't want to slow down the startup times } } diff --git a/examples/all_features/test_output/help.txt b/examples/all_features/test_output/help.txt index 00de6f99a..2c4595527 100644 --- a/examples/all_features/test_output/help.txt +++ b/examples/all_features/test_output/help.txt @@ -29,7 +29,7 @@ -r, --reporters= reporters to use (console is default) -o, --out= output filename -ob, --order-by= how the tests should be ordered - - by [file/suite/name/rand] + - [file/suite/name/rand/none] -rs, --rand-seed= seed for random ordering -f, --first= the first test passing the filters to execute - for range-based execution