diff options
-rw-r--r-- | test/tasks_test.cc | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/test/tasks_test.cc b/test/tasks_test.cc index 8e00974..b444bd5 100644 --- a/test/tasks_test.cc +++ b/test/tasks_test.cc @@ -34,16 +34,29 @@ ctor::build_configurations ctorTestConfigs2(const ctor::settings&) } } +namespace test_global { +ctor::toolchain toolchain{}; +ctor::arch arch{}; +} +const ctor::configuration& ctor::get_configuration() +{ + static ctor::configuration cfg{}; + cfg.build_toolchain = test_global::toolchain; + cfg.build_arch = test_global::arch; + return cfg; +} + + REG(ctorTestConfigs1); REG(ctorTestConfigs2); std::size_t count(const std::vector<std::shared_ptr<Task>>& tasks, - const std::string& name) + const std::filesystem::path& name) { auto cnt{0u}; for(const auto& task : tasks) { - if(task->target() == name) + if(task->target() == name.string()) { cnt++; } @@ -83,6 +96,8 @@ class TasksTest : public uUnit { public: + using fs = std::filesystem::path; + TasksTest() { uTEST(TasksTest::getTargets_test); @@ -111,26 +126,29 @@ public: void getTasks_test() { + test_global::toolchain = ctor::toolchain::gcc; + test_global::arch = ctor::arch::unix; + using namespace std::string_literals; ctor::settings settings{ .builddir = "foo" }; { auto tasks = getTasks(settings); uASSERT_EQUAL(6u, tasks.size()); // 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)); - uASSERT_EQUAL(1u, count(tasks, "target4"s)); - uASSERT_EQUAL(1u, count(tasks, "test/target1-foo_cc.o"s)); - uASSERT_EQUAL(1u, count(tasks, "test/target1-bar_c.o"s)); + uASSERT_EQUAL(1u, count(tasks, fs("target1"))); + uASSERT_EQUAL(1u, count(tasks, fs("target2"))); + uASSERT_EQUAL(1u, count(tasks, fs("target3"))); + uASSERT_EQUAL(1u, count(tasks, fs("target4"))); + uASSERT_EQUAL(1u, count(tasks, fs("test")/"target1-foo_cc.o")); + uASSERT_EQUAL(1u, count(tasks, fs("test")/"target1-bar_c.o")); } { auto tasks = getTasks(settings, {"target1", "target3"}); uASSERT_EQUAL(4u, tasks.size()); - uASSERT_EQUAL(1u, count(tasks, "target1"s)); - uASSERT_EQUAL(1u, count(tasks, "target3"s)); - uASSERT_EQUAL(1u, count(tasks, "test/target1-foo_cc.o"s)); - uASSERT_EQUAL(1u, count(tasks, "test/target1-bar_c.o"s)); + uASSERT_EQUAL(1u, count(tasks, fs("target1"))); + uASSERT_EQUAL(1u, count(tasks, fs("target3"))); + uASSERT_EQUAL(1u, count(tasks, fs("test")/"target1-foo_cc.o")); + uASSERT_EQUAL(1u, count(tasks, fs("test")/"target1-bar_c.o")); } { auto tasks = getTasks(settings, {"no-such-target"}); @@ -264,33 +282,36 @@ public: void comparison_test() { + test_global::toolchain = ctor::toolchain::gcc; + test_global::arch = ctor::arch::unix; + using namespace std::string_literals; ctor::settings settings{ .builddir = "foo" }; { // Test Task::operator== auto tasks = getTasks(settings, {"target1"}); uASSERT_EQUAL(3u, tasks.size()); - uASSERT_EQUAL(1u, count(tasks, "target1"s)); - uASSERT_EQUAL(1u, count(tasks, "test/target1-foo_cc.o"s)); - uASSERT_EQUAL(1u, count(tasks, "test/target1-bar_c.o"s)); + uASSERT_EQUAL(1u, count(tasks, fs("target1"))); + uASSERT_EQUAL(1u, count(tasks, fs("test")/"target1-foo_cc.o")); + uASSERT_EQUAL(1u, count(tasks, fs("test")/"target1-bar_c.o")); int cnt1{}; int cnt2{}; int cnt3{}; for(const auto& task : tasks) { - if(task->target() == "target1"s) + if(task->target() == fs("target1")) { ++cnt1; uASSERT(*task == "target1"); uASSERT(*task == "Target1"); } - if(task->target() == "test/target1-foo_cc.o"s) + if(task->target() == fs("test")/"target1-foo_cc.o") { ++cnt2; uASSERT(*task != "target1"); uASSERT(*task != "Target1"); } - if(task->target() == "test/target1-bar_c.o"s) + if(task->target() == fs("test")/"target1-bar_c.o") { ++cnt3; uASSERT(*task != "target1"); |