8000 tests: actually randomise the order of tests by iscgar · Pull Request #1613 · solvespace/solvespace · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
8000
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions test/harness.cpp
8000
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//
// Copyright 2016 whitequark
//-----------------------------------------------------------------------------
#include <cstdio>
#include <random>
#include <regex>
#include <cairo.h>

Expand Down Expand Up @@ -337,19 +339,29 @@ int Test::Case::Register(Test::Case testCase) {
int main(int argc, char **argv) {
std::vector<std::string> args = Platform::InitCli(argc, argv);

std::regex filter(".*");
std::string filterPattern = ".*";
unsigned int seed = std::random_device{}();
if(args.size() == 1) {
} else if(args.size() == 2) {
filter = args[1];
filterPattern = args[1];
} else if(args.size() == 3) {
filterPattern = args[1];
seed = std::stoul(args[2]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8000
Suggested change
seed = std::stoul(args[2]);
filterPattern = args[1];
seed = std::stoul(args[2]);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! Fixed.

} else {
fprintf(stderr, "Usage: %s [test filter regex]\n", args[0].c_str());
fprintf(stderr, "Usage: %s [test filter regex] [shuffle seed]\n", args[0].c_str());
return 1;
}

fprintf(stderr, "info: using test filter `%s' and seed %u\n", filterPattern.c_str(), seed);

Platform::fontFiles.push_back(HostRoot().Join("Gentium-R.ttf"));

std::mt19937 g(seed);

// Wreck order dependencies between tests!
std::random_shuffle(testCasesPtr->begin(), testCasesPtr->end());
std::shuffle(testCasesPtr->begin(), testCasesPtr->end(), g);

std::regex filter(filterPattern);

auto testStartTime = std::chrono::steady_clock::now();
size_t ranTally = 0, skippedTally = 0, checkTally = 0, failTally = 0;
Expand Down
Loading
0