From 1c2e94894088a7c640ffbfa63dc77f92639d1946 Mon Sep 17 00:00:00 2001 From: iTrooz Date: Mon, 20 May 2024 00:35:24 +0200 Subject: [PATCH] test: Make description pragma mandatory (#251) --- patterns/bplist.hexpat | 2 ++ patterns/gltf.hexpat | 2 ++ patterns/hinf_bitmap.hexpat | 2 ++ patterns/ras.hexpat | 2 +- patterns/usb.hexpat | 2 ++ tests/patterns/source/main.cpp | 8 +++++++- 6 files changed, 16 insertions(+), 2 deletions(-) diff --git a/patterns/bplist.hexpat b/patterns/bplist.hexpat index 268bb42..f5e3a72 100644 --- a/patterns/bplist.hexpat +++ b/patterns/bplist.hexpat @@ -1,3 +1,5 @@ +#pragma description TODO + import std.math; import std.core; import type.magic; diff --git a/patterns/gltf.hexpat b/patterns/gltf.hexpat index 27e43fd..69205e2 100644 --- a/patterns/gltf.hexpat +++ b/patterns/gltf.hexpat @@ -22,6 +22,8 @@ * SOFTWARE. */ +#pragma description TODO + import std.mem; import std.io; diff --git a/patterns/hinf_bitmap.hexpat b/patterns/hinf_bitmap.hexpat index e23b7a8..c7c145c 100644 --- a/patterns/hinf_bitmap.hexpat +++ b/patterns/hinf_bitmap.hexpat @@ -1,3 +1,5 @@ +#pragma description TODO + import std.mem; import std.io; import std.string; diff --git a/patterns/ras.hexpat b/patterns/ras.hexpat index 54383f5..0c49f6c 100644 --- a/patterns/ras.hexpat +++ b/patterns/ras.hexpat @@ -1,5 +1,5 @@ #pragma author Fl3ch4 - +#pragma description TODO #pragma MIME image/webp #pragma endian big diff --git a/patterns/usb.hexpat b/patterns/usb.hexpat index 1d7c74d..ddb87c5 100644 --- a/patterns/usb.hexpat +++ b/patterns/usb.hexpat @@ -1,3 +1,5 @@ +#pragma description TODO + import std.core; import std.io; import std.mem; diff --git a/tests/patterns/source/main.cpp b/tests/patterns/source/main.cpp index 4b9fe25..900fb8a 100644 --- a/tests/patterns/source/main.cpp +++ b/tests/patterns/source/main.cpp @@ -39,8 +39,13 @@ int main(int argc, char **argv) { // Setup Pattern Language Runtime pl::PatternLanguage runtime; + bool hasDescription = false; { constexpr auto DummyPragmaHandler = [](const auto&, const auto&){ return true; }; + auto DescPragmaHandler = [&hasDescription](const auto&, const auto&){ + hasDescription = true; + return true; + }; runtime.setDataSource(0x00, testFile.getSize(), [&](pl::u64 address, pl::u8 *data, size_t size) { @@ -51,6 +56,7 @@ int main(int argc, char **argv) { runtime.setDangerousFunctionCallHandler([]{ return true; }); runtime.setIncludePaths({ includePath }); runtime.addPragma("MIME", DummyPragmaHandler); + runtime.addPragma("description", DescPragmaHandler); runtime.addDefine("__PL_UNIT_TESTS__"); runtime.setLogCallback([](auto level, const std::string &message) { @@ -77,5 +83,5 @@ int main(int argc, char **argv) { return EXIT_FAILURE; } - return EXIT_SUCCESS; + return hasDescription ? EXIT_SUCCESS : EXIT_FAILURE; }