mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
LibTest: Change #define-d constants into constexpr and a runtime flag
MAX_GENERATED_VALUES_PER_TEST is now the --randomized_runs flag: $ ./Build/lagom/bin/TestGenerator --randomized_runs 1000 It's sometimes useful to try larger numbers for it instead of the default of 100. MAX_GEN_ATTEMPTS_PER_VALUE is now a constexpr. It's not usually needed to tweak this value; we can recompile with a different value on the rare occasion.
This commit is contained in:
parent
ed60a032a8
commit
4fc1daa69f
4 changed files with 23 additions and 18 deletions
|
@ -5,10 +5,9 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibTest/Macros.h> // intentionally first -- we redefine VERIFY and friends in here
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibTest/Macros.h>
|
||||
#include <LibTest/TestResult.h>
|
||||
#include <LibTest/TestSuite.h>
|
||||
#include <math.h>
|
||||
|
@ -64,6 +63,12 @@ Randomized::RandomnessSource& randomness_source()
|
|||
return TestSuite::the().randomness_source();
|
||||
}
|
||||
|
||||
// Declared in Macros.h
|
||||
u64 randomized_runs()
|
||||
{
|
||||
return TestSuite::the().randomized_runs();
|
||||
}
|
||||
|
||||
// Declared in TestCase.h
|
||||
void add_test_case_to_suite(NonnullRefPtr<TestCase> const& test_case)
|
||||
{
|
||||
|
@ -126,6 +131,7 @@ int TestSuite::main(DeprecatedString const& suite_name, Span<StringView> argumen
|
|||
args_parser.add_option(do_tests_only, "Only run tests.", "tests", 0);
|
||||
args_parser.add_option(do_benchmarks_only, "Only run benchmarks.", "bench", 0);
|
||||
args_parser.add_option(m_benchmark_repetitions, "Number of times to repeat each benchmark (default 1)", "benchmark_repetitions", 0, "N");
|
||||
args_parser.add_option(m_randomized_runs, "Number of times to run each RANDOMIZED_TEST_CASE (default 100)", "randomized_runs", 0, "RUNS");
|
||||
args_parser.add_option(do_list_cases, "List available test cases.", "list", 0);
|
||||
args_parser.add_positional_argument(search_string, "Only run matching cases.", "pattern", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue