From 0008920eed996009068fe9f71512c436577b6220 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 2 Oct 2024 21:20:40 +0200 Subject: Ensure the initial task order is preserved. Fixes bad ordering during linking. --- test/tasks_test.cc | 55 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) (limited to 'test/tasks_test.cc') diff --git a/test/tasks_test.cc b/test/tasks_test.cc index 5f1db26..3de6982 100644 --- a/test/tasks_test.cc +++ b/test/tasks_test.cc @@ -36,7 +36,7 @@ ctor::build_configurations ctorTestConfigs2(const ctor::settings&) REG(ctorTestConfigs1); REG(ctorTestConfigs2); -std::size_t count(const std::set>& tasks, +std::size_t count(const std::vector>& tasks, const std::string& name) { auto cnt{0u}; @@ -113,8 +113,7 @@ public: { auto tasks = getTasks(settings); uASSERT_EQUAL(6u, tasks.size()); - // Note: count() is used here because the order of - // std::set> is not deterministic. + // Note: count() is used here because the order doesn't matter uASSERT_EQUAL(1u, count(tasks, "target1"s)); uASSERT_EQUAL(1u, count(tasks, "target2"s)); uASSERT_EQUAL(1u, count(tasks, "target3"s)); @@ -142,8 +141,8 @@ public: ctor::settings settings{}; { // Zero (Empty) - std::set> allTasks; - std::set> dirtyTasks; + std::vector> allTasks; + std::vector> dirtyTasks; for(auto& task : dirtyTasks) { @@ -156,10 +155,10 @@ public: { // Zero (One task, no dirty) auto task1 = std::make_shared("task1", false); - std::set> allTasks; - allTasks.insert(task1); + std::vector> allTasks; + allTasks.push_back(task1); - std::set> dirtyTasks; + std::vector> dirtyTasks; for(auto& task : dirtyTasks) { @@ -172,11 +171,11 @@ public: { // One (One task, one dirty) auto task1 = std::make_shared("task1", true); - std::set> allTasks; - allTasks.insert(task1); + std::vector> allTasks; + allTasks.push_back(task1); - std::set> dirtyTasks; - dirtyTasks.insert(task1); + std::vector> dirtyTasks; + dirtyTasks.push_back(task1); for(auto& task : dirtyTasks) { @@ -191,12 +190,12 @@ public: auto task1 = std::make_shared("task1", false); auto task2 = std::make_shared("task2", true); - std::set> allTasks; - allTasks.insert(task1); - allTasks.insert(task2); + std::vector> allTasks; + allTasks.push_back(task1); + allTasks.push_back(task2); - std::set> dirtyTasks; - dirtyTasks.insert(task2); + std::vector> dirtyTasks; + dirtyTasks.push_back(task2); for(auto& task : dirtyTasks) { @@ -213,12 +212,12 @@ public: std::vector deps = {"task1"}; auto task2 = std::make_shared("task2", true, deps); - std::set> allTasks; - allTasks.insert(task1); - allTasks.insert(task2); + std::vector> allTasks; + allTasks.push_back(task1); + allTasks.push_back(task2); - std::set> dirtyTasks; - dirtyTasks.insert(task2); + std::vector> dirtyTasks; + dirtyTasks.push_back(task2); for(auto& task : dirtyTasks) { @@ -235,13 +234,13 @@ public: std::vector deps = {"task1"}; auto task2 = std::make_shared("task2", true, deps); - std::set> allTasks; - allTasks.insert(task2); - allTasks.insert(task1); + std::vector> allTasks; + allTasks.push_back(task2); + allTasks.push_back(task1); - std::set> dirtyTasks; - dirtyTasks.insert(task2); - dirtyTasks.insert(task1); + std::vector> dirtyTasks; + dirtyTasks.push_back(task2); + dirtyTasks.push_back(task1); for(auto& task : dirtyTasks) { -- cgit v1.2.3