summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2024-10-02 21:20:40 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2024-10-03 12:06:38 +0200
commit0008920eed996009068fe9f71512c436577b6220 (patch)
tree60350de98747a63e1739841b966269f5e312b9ba /test
parenta38c6682e4fb1f45aa1f37d10c2480aa517ea3bc (diff)
Ensure the initial task order is preserved. Fixes bad ordering during linking.develop
Diffstat (limited to 'test')
-rw-r--r--test/execute_test.cc18
-rw-r--r--test/tasks_test.cc55
2 files changed, 39 insertions, 34 deletions
diff --git a/test/execute_test.cc b/test/execute_test.cc
index 03b3c2a..d5d40c9 100644
--- a/test/execute_test.cc
+++ b/test/execute_test.cc
@@ -2,10 +2,11 @@
#include <fstream>
#include <map>
-#include <set>
+#include <vector>
#include <execute.h>
#include <util.h>
+#include <algorithm>
#include "paths.h"
#include "tmpfile.h"
@@ -34,6 +35,8 @@ public:
void env()
{
+ using namespace std::string_literals;
+
auto cur_path = std::filesystem::path(paths::argv_0).parent_path();
std::vector<std::string> paths{{cur_path.string()}};
auto cmd = locate("testprog", paths);
@@ -52,22 +55,25 @@ public:
uASSERT_EQUAL(0, execute(cmd, {"envdump", tmp.get()}, env, false));
- std::set<std::string> vars;
+ std::vector<std::string> vars;
{
std::ifstream infile(tmp.get());
std::string line;
while (std::getline(infile, line))
{
- vars.insert(line);
+ vars.push_back(line);
}
}
// Check the two explicitly set vars
- uASSERT(vars.find("foo=bar") != vars.end());
- uASSERT(vars.find("bar=42") != vars.end());
+ auto chk = std::find(vars.begin(), vars.end(), "foo=bar"s);
+ uASSERT(chk != vars.end());
+ chk = std::find(vars.begin(), vars.end(), "bar=42"s);
+ uASSERT(chk != vars.end());
// Check the one that should have overwritten the existing one (probably LANG=en_US.UTF-8 or something)
- uASSERT(vars.find("LANG=foo") != vars.end());
+ chk = std::find(vars.begin(), vars.end(), "LANG=foo"s);
+ uASSERT(chk != vars.end());
// Check that other vars are also there (ie. the env wasn't cleared on entry)
uASSERT(vars.size() > 3);
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<std::shared_ptr<Task>>& tasks,
+std::size_t count(const std::vector<std::shared_ptr<Task>>& 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<std::shared_ptr<T>> 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<std::shared_ptr<Task>> allTasks;
- std::set<std::shared_ptr<Task>> dirtyTasks;
+ std::vector<std::shared_ptr<Task>> allTasks;
+ std::vector<std::shared_ptr<Task>> dirtyTasks;
for(auto& task : dirtyTasks)
{
@@ -156,10 +155,10 @@ public:
{ // Zero (One task, no dirty)
auto task1 = std::make_shared<TestTask>("task1", false);
- std::set<std::shared_ptr<Task>> allTasks;
- allTasks.insert(task1);
+ std::vector<std::shared_ptr<Task>> allTasks;
+ allTasks.push_back(task1);
- std::set<std::shared_ptr<Task>> dirtyTasks;
+ std::vector<std::shared_ptr<Task>> dirtyTasks;
for(auto& task : dirtyTasks)
{
@@ -172,11 +171,11 @@ public:
{ // One (One task, one dirty)
auto task1 = std::make_shared<TestTask>("task1", true);
- std::set<std::shared_ptr<Task>> allTasks;
- allTasks.insert(task1);
+ std::vector<std::shared_ptr<Task>> allTasks;
+ allTasks.push_back(task1);
- std::set<std::shared_ptr<Task>> dirtyTasks;
- dirtyTasks.insert(task1);
+ std::vector<std::shared_ptr<Task>> dirtyTasks;
+ dirtyTasks.push_back(task1);
for(auto& task : dirtyTasks)
{
@@ -191,12 +190,12 @@ public:
auto task1 = std::make_shared<TestTask>("task1", false);
auto task2 = std::make_shared<TestTask>("task2", true);
- std::set<std::shared_ptr<Task>> allTasks;
- allTasks.insert(task1);
- allTasks.insert(task2);
+ std::vector<std::shared_ptr<Task>> allTasks;
+ allTasks.push_back(task1);
+ allTasks.push_back(task2);
- std::set<std::shared_ptr<Task>> dirtyTasks;
- dirtyTasks.insert(task2);
+ std::vector<std::shared_ptr<Task>> dirtyTasks;
+ dirtyTasks.push_back(task2);
for(auto& task : dirtyTasks)
{
@@ -213,12 +212,12 @@ public:
std::vector<std::string> deps = {"task1"};
auto task2 = std::make_shared<TestTask>("task2", true, deps);
- std::set<std::shared_ptr<Task>> allTasks;
- allTasks.insert(task1);
- allTasks.insert(task2);
+ std::vector<std::shared_ptr<Task>> allTasks;
+ allTasks.push_back(task1);
+ allTasks.push_back(task2);
- std::set<std::shared_ptr<Task>> dirtyTasks;
- dirtyTasks.insert(task2);
+ std::vector<std::shared_ptr<Task>> dirtyTasks;
+ dirtyTasks.push_back(task2);
for(auto& task : dirtyTasks)
{
@@ -235,13 +234,13 @@ public:
std::vector<std::string> deps = {"task1"};
auto task2 = std::make_shared<TestTask>("task2", true, deps);
- std::set<std::shared_ptr<Task>> allTasks;
- allTasks.insert(task2);
- allTasks.insert(task1);
+ std::vector<std::shared_ptr<Task>> allTasks;
+ allTasks.push_back(task2);
+ allTasks.push_back(task1);
- std::set<std::shared_ptr<Task>> dirtyTasks;
- dirtyTasks.insert(task2);
- dirtyTasks.insert(task1);
+ std::vector<std::shared_ptr<Task>> dirtyTasks;
+ dirtyTasks.push_back(task2);
+ dirtyTasks.push_back(task1);
for(auto& task : dirtyTasks)
{