diff options
| author | Claudius Holeksa <mail@keldu.de> | 2023-05-09 17:58:30 +0200 |
|---|---|---|
| committer | Claudius Holeksa <mail@keldu.de> | 2023-05-09 17:58:30 +0200 |
| commit | 2e8ee05aee8c03aaf1f991b8403a6980eeb1f4fc (patch) | |
| tree | 14aabbe752f00f218eb3a01df2e1f155fde3e409 | |
| parent | a178b64a681dc0a381835ab567853c132753902f (diff) | |
| download | mini-test-2e8ee05aee8c03aaf1f991b8403a6980eeb1f4fc.tar.gz | |
Fixed build and install issues. Confirmed install and build on nix
| -rw-r--r-- | .nix/derivation.nix | 6 | ||||
| -rw-r--r-- | Makefile | 12 | ||||
| -rw-r--r-- | src/keltest/test.cpp | 15 | ||||
| -rw-r--r-- | src/keltest/test.h | 2 |
4 files changed, 22 insertions, 13 deletions
diff --git a/.nix/derivation.nix b/.nix/derivation.nix index 3d2d7d0..23dd938 100644 --- a/.nix/derivation.nix +++ b/.nix/derivation.nix @@ -15,5 +15,9 @@ stdenvNoCC.mkDerivation { gnumake ]; - output = [ "out" "dev" ]; + installPhase = '' + PREFIX=$out make install + ''; + + output = [ "out" ]; } @@ -1,17 +1,19 @@ .PHONY: all clean +PREFIX ?= /usr/local + all: build/libkeltest.a build/libkeltest.a: mkdir -p ./build c++ -std=c++17 -DKELTEST_COMPILE_TEST_BINARY src/keltest/test.cpp -o build/test.o - ar build/libkeltest.a build/test.o + ar q build/libkeltest.a build/test.o clean: rm -rf ./build install: build/libkeltest.a - mkdir -p ${prefix}/lib - mkdir -p ${prefix}/include/keltest - cp build/libkeltest.a ${prefix}/lib/libkeltest.a - cp src/keltest/test.h ${prefix}/include/keltest/test.h + mkdir -p ${PREFIX}/lib + mkdir -p ${PREFIX}/include/keltest + cp build/libkeltest.a ${PREFIX}/lib/libkeltest.a + cp src/keltest/test.h ${PREFIX}/include/keltest/test.h diff --git a/src/keltest/test.cpp b/src/keltest/test.cpp index 1178b20..d8c5886 100644 --- a/src/keltest/test.cpp +++ b/src/keltest/test.cpp @@ -3,6 +3,7 @@ #include <chrono> #include <iostream> #include <string_view> +#include <variant> namespace keltest { @@ -12,7 +13,7 @@ constexpr bool always_false = false; test_case* test_case_head = nullptr; test_case** test_case_tail = &test_case_head; -test_case::test_case(std::string file_, uint32_t line_, std::string& description_): +test_case::test_case(std::string file_, uint32_t line_, std::string description_): file{std::move(file_)}, line{line_}, description{std::move(description_)}, @@ -87,8 +88,8 @@ public: size_t failed_count = 0; for(test_case* test = test_case_head; test != nullptr; test = test->next){ - std::string name = test->fil + std::string{":"} + std::to_string(test->line) + std::string{":"} + test->description; - write(colour::blue, "[ TEST ] ", name); + std::string name = test->file + std::string{":"} + std::to_string(test->line) + std::string{":"} + test->description; + write(colour::blue{}, "[ TEST ] ", name); bool failed = true; std::string fail_message; @@ -110,17 +111,17 @@ public: std::string message = name + std::string{" ("} + std::to_string(runtime_duration.count()) + std::string{" µs) "}; if( failed ){ - write(colour::red, "[ FAIL ] ", message + std::string{" "} + fail_message); + write(colour::red{}, "[ FAIL ] ", message + std::string{" "} + fail_message); ++failed_count; }else{ - write(colour::green, "[ PASS ] ", message); + write(colour::green{}, "[ PASS ] ", message); ++passed_count; } } - if( passed_count > 0 ) write(colour::green, std::to_string(passed_count) + std::string{" test(s) passed"}, ""); + if( passed_count > 0 ) write(colour::green{}, std::to_string(passed_count) + std::string{" test(s) passed"}, ""); - if( failed_count > 0 ) write(colour::red, std::to_string(failed_count) + std::string{" test(s) failed"}, ""); + if( failed_count > 0 ) write(colour::red{}, std::to_string(failed_count) + std::string{" test(s) failed"}, ""); return failed_count > 0 ? -1 : 0; } diff --git a/src/keltest/test.h b/src/keltest/test.h index 24f008f..cd23f28 100644 --- a/src/keltest/test.h +++ b/src/keltest/test.h @@ -12,6 +12,8 @@ private: std::string description; test_case* next; test_case** prev; + + friend class test_runner; public: test_case(std::string file_, uint32_t line_, std::string description_); ~test_case(); |
