Add clang-format (#1086)

Co-authored-by: mwilsnd <mwilsnd@gmail.com>
This commit is contained in:
Bart Louwers
2023-05-01 16:57:37 +02:00
committed by GitHub
parent 403a12bd1b
commit 71f6da2722
1018 changed files with 27876 additions and 25862 deletions

View File

@@ -5,8 +5,7 @@
#include <random>
#include <iostream>
int main(int argc, char** argv)
try {
int main(int argc, char** argv) try {
// Parse args
std::vector<mbgl::filesystem::path> testPaths;
mbgl::filesystem::path rootPath;
@@ -19,7 +18,7 @@ try {
if (shuffle) {
printf(ANSI_COLOR_YELLOW "Shuffle seed: %d" ANSI_COLOR_RESET "\n", seed);
std::seed_seq sequence { seed };
std::seed_seq sequence{seed};
std::mt19937 shuffler(sequence);
std::shuffle(testPaths.begin(), testPaths.end(), shuffler);
}
@@ -28,13 +27,15 @@ try {
TestStats stats;
for (const auto& path : testPaths) {
const auto& expectation = path.parent_path().string();
std::string id = expectation.substr(rootPath.string().length() + 1, expectation.length() - rootPath.string().length());
std::string id = expectation.substr(rootPath.string().length() + 1,
expectation.length() - rootPath.string().length());
stats.ids.emplace_back(id);
bool shouldIgnore = false;
std::string ignoreReason;
const std::string ignoreName = "expression-tests/" + id;
const auto it = std::find_if(ignores.cbegin(), ignores.cend(), [&ignoreName] (const auto& ignore) { return ignore.id == ignoreName; });
const auto it = std::find_if(
ignores.cbegin(), ignores.cend(), [&ignoreName](const auto& ignore) { return ignore.id == ignoreName; });
if (it != ignores.end()) {
shouldIgnore = true;
ignoreReason = (*it).reason;
@@ -54,10 +55,14 @@ try {
if (shouldIgnore) {
if (testRun->passed) {
stats.ignorePassed.emplace_back(std::move(*testRun));
printf(ANSI_COLOR_YELLOW "* PASSED ignored test %s (%s)" ANSI_COLOR_RESET "\n", id.c_str(), ignoreReason.c_str());
printf(ANSI_COLOR_YELLOW "* PASSED ignored test %s (%s)" ANSI_COLOR_RESET "\n",
id.c_str(),
ignoreReason.c_str());
} else {
stats.ignoreFailed.emplace_back(std::move(*testRun));
printf(ANSI_COLOR_LIGHT_GRAY "* FAILED ignored test %s (%s)" ANSI_COLOR_RESET "\n", id.c_str(), ignoreReason.c_str());
printf(ANSI_COLOR_LIGHT_GRAY "* FAILED ignored test %s (%s)" ANSI_COLOR_RESET "\n",
id.c_str(),
ignoreReason.c_str());
}
} else {
if (testRun->passed) {
@@ -72,10 +77,9 @@ try {
printStats(stats);
writeHTMLResults(stats, rootPath.string(), shuffle, seed);
return stats.errored.size() + stats.failed.size() == 0 ? 0 : 1;
}
catch (std::exception const& ex) {
} catch (std::exception const& ex) {
std::cerr << "Caught an exception while running tests:\n" << ex.what() << '\n';
return 1;
}