From 1cc53f8bee47aa941f1c82e07346717b46381624 Mon Sep 17 00:00:00 2001 From: SoraKatadzuma Date: Fri, 26 Jun 2026 20:51:42 +0000 Subject: [PATCH] Test dependencies --- chinook/management/_load.py | 2 +- chinook/pipeline/_test.py | 2 +- examples/testing/chinookfile | 7 +++++++ examples/testing/entry.cpp | 12 ++++++++++-- examples/testing/fibonacci.cpp | 12 ++++++++++++ 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 examples/testing/fibonacci.cpp diff --git a/chinook/management/_load.py b/chinook/management/_load.py index df1de4f..cccfbde 100644 --- a/chinook/management/_load.py +++ b/chinook/management/_load.py @@ -93,7 +93,7 @@ def _flatten_tests(project: Project) -> None: def _flatten_target(target: Target) -> None: for dependency in target.deps: if (parent:=targets_by_name_mapping.get(dependency.value)) == None: - raise ValueError(f"No such dependable target: {dependency}") + raise ValueError(f"No such dependable target: {dependency.value}") _inherit_target(target, parent) def _inherit_target(target: Target, parent: Target) -> None: diff --git a/chinook/pipeline/_test.py b/chinook/pipeline/_test.py index 18e2233..d929194 100644 --- a/chinook/pipeline/_test.py +++ b/chinook/pipeline/_test.py @@ -50,5 +50,5 @@ def _prepare_dependencies( if dependency._prepared: continue project = find_project_by_target(required.value) - commands.extend(prepare(appcfg, project, target, logger)) + commands.extend(prepare(appcfg, project, dependency, logger)) return commands diff --git a/examples/testing/chinookfile b/examples/testing/chinookfile index 0e37860..5339297 100644 --- a/examples/testing/chinookfile +++ b/examples/testing/chinookfile @@ -2,8 +2,15 @@ name: testing gpid: examples semv: 1.0.0 +targets: +- name: fibonacci + type: archive + srcs: + - ./fibonacci.cpp + tests: - name: factorial_test type: program + deps: [fibonacci] srcs: - ./entry.cpp \ No newline at end of file diff --git a/examples/testing/entry.cpp b/examples/testing/entry.cpp index e9e69fe..9649a98 100644 --- a/examples/testing/entry.cpp +++ b/examples/testing/entry.cpp @@ -1,13 +1,21 @@ +#include + +extern "C" int fibonacci(int nth); + int factorial(int start) { if (start < 0) return 0; auto result = 1; - for (auto index = 2; index < start; index++) + for (auto index = start; index > 0; index--) result *= index; return result; } int main(int argc, char** argv) { - return factorial(5) == 120; + auto resultA = factorial(5) == 120; + auto resultB = fibonacci(5) == 5; + std::cout << "Result A: " << resultA << std::endl; + std::cout << "Result B: " << resultB << std::endl; + return !(resultA && resultB); } \ No newline at end of file diff --git a/examples/testing/fibonacci.cpp b/examples/testing/fibonacci.cpp new file mode 100644 index 0000000..f1cfec9 --- /dev/null +++ b/examples/testing/fibonacci.cpp @@ -0,0 +1,12 @@ +extern "C" int fibonacci(int nth) { + int next; + int temp1 = 0; + int temp2 = 1; + for (int index = 1; index <= nth; index++) { + next = temp1 + temp2; + temp1 = temp2; + temp2 = next; + } + + return nth; +} \ No newline at end of file