Template
feat(detect): define feature-check registry schema
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* LINK: ../../src/kdl/schema.c ../../src/kdl/value.c ../../src/kdl/parser.c ../../src/kdl/lexer.c ../../src/error.c ../../src/span.c */
|
||||
/* LINK: ../../src/kdl/schema.c ../../src/detect/check_registry.c ../../src/kdl/value.c ../../src/kdl/parser.c ../../src/kdl/lexer.c ../../src/error.c ../../src/span.c */
|
||||
/* tests/unit/test_schema.c
|
||||
*
|
||||
* Unit tests for the stupidtools DSL schema validator (todo 9).
|
||||
@@ -396,24 +396,29 @@ test_target_children(const MunitParameter params[], void *data)
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
/* feature children: structural validation only (the 8 check kinds are
|
||||
* todo 10). Any check name passes provided it has >= 1 non-empty string
|
||||
* argument and no children; check-kind semantics are out of scope here. */
|
||||
/* feature children: each check's NAME must be one of the 8 kinds from
|
||||
* the feature-check registry (todo 10), and the kind's argument shape is
|
||||
* enforced (exactly one non-empty string target, no children; the
|
||||
* optional `version` property is todo 10's too - see
|
||||
* test_check_registry.c for the per-kind table). */
|
||||
static MunitResult
|
||||
test_feature_checks_structural(const MunitParameter params[], void *data)
|
||||
{
|
||||
(void)params;
|
||||
(void)data;
|
||||
|
||||
/* the two fixture kinds plus arbitrary names all pass structurally */
|
||||
/* the two fixture kinds plus the rest of the 8 kinds pass */
|
||||
assert_valid("project \"p\" version \"1.0\"\n"
|
||||
"feature \"f\" { header \"h.h\"\nlibrary \"l\" }");
|
||||
assert_valid("project \"p\" version \"1.0\"\n"
|
||||
"feature \"f\" { type \"size_t\"\nsizeof \"int\"\n"
|
||||
"function \"strdup\"\nprogram \"gcc\"\n"
|
||||
"compiler_flag \"-Wall\"\npkg_config \"zlib\" }");
|
||||
assert_valid("project \"p\" version \"1.0\"\n"
|
||||
"feature \"f\" { frobnicate \"x\" }");
|
||||
|
||||
/* unknown check kinds are rejected (registry dispatch, todo 10) */
|
||||
assert_schema_error(
|
||||
"project \"p\" version \"1.0\"\nfeature \"f\" { frobnicate \"x\" }",
|
||||
"'frobnicate'", 2, 15);
|
||||
|
||||
/* but a check still needs its argument (a non-empty string) */
|
||||
assert_schema_error(
|
||||
|
||||
Reference in New Issue
Block a user