commit 0804feac00ce4aff2ae746f4246d1675b6b4e491 (tree) parent 59bd8201dc0f5ed31146ae2c9cff06b89e94cfc8 Author: fardragon <michaldrozd@protonmail.ch> Date: Thu, 4 Jun 2026 17:37:11 +0000 Deduplicate and cleanup cmake tests Diffstat:
19 files changed, 462 insertions(+), 634 deletions(-)
diff --git a/test/standalone/config_header/build.zig b/test/standalone/config_header/build.zig @@ -5,9 +5,7 @@ pub fn build(b: *std.Build) void { b.default_step = test_step; const config_header = b.addConfigHeader( - .{ .style = .{ - .autoconf_undef = b.path("autoconf_undef/config.h.in"), - } }, + .{ .style = .{ .autoconf_undef = b.path("autoconf_undef/config.h.in") } }, .{ .SOME_NO = null, .SOME_TRUE = true, @@ -30,9 +28,7 @@ pub fn build(b: *std.Build) void { }); const config_header_autoconf_at = b.addConfigHeader( - .{ .style = .{ - .autoconf_at = b.path("autoconf_at/autoconf_at.txt.in"), - } }, + .{ .style = .{ .autoconf_at = b.path("autoconf_at/autoconf_at.txt.in") } }, .{ .undefined = null, .defined = {}, @@ -54,132 +50,85 @@ pub fn build(b: *std.Build) void { fn addCmakeChecks(b: *std.Build, test_step: *std.Build.Step) void { const config_header = b.addConfigHeader( + .{ .style = .{ .cmake = b.path("cmake/config.h.in") } }, .{ - .style = .{ .cmake = b.path("cmake/config.h.in") }, - .include_path = "config.h", - }, - .{ - .noval = null, - .trueval = true, - .falseval = false, - .zeroval = 0, - .oneval = 1, - .tenval = 10, - .stringval = "test", + .NOVAL = null, + .TRUEVAL = true, + .FALSEVAL = false, + .ZEROVAL = 0, + .ONEVAL = 1, + .TENVAL = 10, + .STRINGVAL = "test", - .boolnoval = {}, - .booltrueval = true, - .boolfalseval = false, - .boolzeroval = 0, - .booloneval = 1, - .booltenval = 10, - .boolstringval = "test", + .BOOLNOVAL = {}, + .BOOLTRUEVAL = true, + .BOOLFALSEVAL = false, + .BOOLZEROVAL = 0, + .BOOLONEVAL = 1, + .BOOLTENVAL = 10, + .BOOLSTRINGVAL = "test", }, ); const check_config_header = b.addCheckFile(config_header.getOutputFile(), .{ - .expected_exact = @embedFile("cmake/expected_config.h"), + .expected_exact = @embedFile("cmake/config.h"), }); test_step.dependOn(&check_config_header.step); const pwd_sh = b.addConfigHeader( - .{ - .style = .{ .cmake = b.path("cmake/pwd.sh.in") }, - .include_path = "pwd.sh", - }, + .{ .style = .{ .cmake = b.path("cmake/pwd.sh.in") } }, .{ .DIR = "${PWD}" }, ); const check_pwd_sh = b.addCheckFile(pwd_sh.getOutputFile(), .{ - .expected_exact = @embedFile("cmake/expected_pwd.sh"), + .expected_exact = @embedFile("cmake/pwd.sh"), }); test_step.dependOn(&check_pwd_sh.step); - const sigil_header = b.addConfigHeader( - .{ - .style = .{ .cmake = b.path("cmake/sigil.h.in") }, - .include_path = "sigil.h", - }, - .{}, - ); - const check_sigil_header = b.addCheckFile(sigil_header.getOutputFile(), .{ - .expected_exact = @embedFile("cmake/expected_sigil.h"), - }); - test_step.dependOn(&check_sigil_header.step); - - const stack_header = b.addConfigHeader( - .{ - .style = .{ .cmake = b.path("cmake/stack.h.in") }, - .include_path = "stack.h", - }, - .{ - .UNDERSCORE = "_", - .NEST_UNDERSCORE_PROXY = "UNDERSCORE", - .NEST_PROXY = "NEST_UNDERSCORE_PROXY", - }, - ); - const check_stack_header = b.addCheckFile(stack_header.getOutputFile(), .{ - .expected_exact = @embedFile("cmake/expected_stack.h"), - }); - test_step.dependOn(&check_stack_header.step); - - const wrapper_header = b.addConfigHeader( - .{ - .style = .{ .cmake = b.path("cmake/wrapper.h.in") }, - .include_path = "wrapper.h", - }, + const config_header_edge_cases = b.addConfigHeader( + .{ .style = .{ .cmake = b.path("cmake/edge_cases.h.in") } }, .{ .DOLLAR = "$", - .TEXT = "TRAP", - - .STRING = "TEXT", + .UNDERSCORE = "_", + .STRING = "text", + .STRING_PROXY = "STRING", .STRING_AT = "@STRING@", .STRING_CURLY = "{STRING}", .STRING_VAR = "${STRING}", + .NEST_UNDERSCORE_PROXY = "UNDERSCORE", + .NEST_PROXY = "NEST_UNDERSCORE_PROXY", }, ); - const check_wrapper_header = b.addCheckFile(wrapper_header.getOutputFile(), .{ - .expected_exact = @embedFile("cmake/expected_wrapper.h"), + const check_config_header_edge_cases = b.addCheckFile(config_header_edge_cases.getOutputFile(), .{ + .expected_exact = @embedFile("cmake/edge_cases.h"), }); - test_step.dependOn(&check_wrapper_header.step); + test_step.dependOn(&check_config_header_edge_cases.step); - const config_header_cmake = b.addConfigHeader( - .{ .style = .{ - .cmake = b.path("cmake/cmake.txt.in"), - } }, + const config_header_cmakedefine_edge_cases = b.addConfigHeader( .{ - .undef = null, - .defined = {}, - .true = true, - .false = false, - .int = 42, - .ident = "value", - .string = "text", + .style = .{ .cmake = b.path("cmake/cmakedefine_edge_cases.h.in") }, + .include_path = "cmakedefine_edge_cases_renamed.h", }, - ); - const check_config_header_cmake = b.addCheckFile(config_header_cmake.getOutputFile(), .{ - .expected_exact = @embedFile("cmake/cmake.txt"), - }); - test_step.dependOn(&check_config_header_cmake.step); - - const config_header_cmake_edge_cases = b.addConfigHeader( - .{ .style = .{ - .cmake = b.path("cmake/cmake_edge_cases.txt.in"), - } }, .{ - // .at = "@", - // .trueval = true, - .dollar = "$", - .underscore = "_", - .string = "text", - .string_proxy = "string", - .string_at = "@string@", - .string_curly = "{string}", - .string_var = "${string}", - .nest_underscore_proxy = "underscore", - .nest_proxy = "nest_underscore_proxy", + .MULTI_WORD = true, + .MULTI_WORD_FALSE = false, + .NO_VALUE = true, + .NO_VALUE_FALSE = false, + .WITH_UNDERSCORE_TRUE = true, + .WITH_UNDERSCORE_FALSE = false, + ._LEADING = true, + .TRAILING_ = true, + ._UNDER_01 = true, + .UNDER_01_ = true, + .SUBST_VAL = true, + .SUBST_VAL_FALSE = false, + .STRING = "text", + .VAR_NAME = "ACTUAL_VAR", + .ACTUAL_VAR = true, + .AT_SIGN = "@", + .DOLLAR_SIGN = "$", }, ); - const check_config_header_cmake_edge_cases = b.addCheckFile(config_header_cmake_edge_cases.getOutputFile(), .{ - .expected_exact = @embedFile("cmake/cmake_edge_cases.txt"), + const check_config_header_cmakedefine_edge_cases = b.addCheckFile(config_header_cmakedefine_edge_cases.getOutputFile(), .{ + .expected_exact = @embedFile("cmake/cmakedefine_edge_cases.h"), }); - test_step.dependOn(&check_config_header_cmake_edge_cases.step); + test_step.dependOn(&check_config_header_cmakedefine_edge_cases.step); } diff --git a/test/standalone/config_header/cmake/cmake.txt b/test/standalone/config_header/cmake/cmake.txt @@ -1,66 +0,0 @@ -/* This file was generated by ConfigHeader using the Zig Build System. */ -// empty strings are preserved - -// line with misc content is preserved -no substitution - -// empty @ sigils are preserved -@ -@@ -@@@ -@@@@ - -// simple substitution - - - - -1 -1 -0 -0 -42 -42 -value -value -text -text - -// double packed substitution -texttext -texttext - -// triple packed substitution -text42text -text42text -text42text -text42text - -// double separated substitution -42.42 -42.42 - -// triple separated substitution -42.1.42 -42.1.42 -42.1.42 -42.1.42 - -// misc prefix is preserved -false is 0 -false is 0 - -// misc suffix is preserved -1 is true -1 is true - -// surrounding content is preserved -what is 6*7? 42! -what is 6*7? 42! - -// incomplete key is preserved -@undef -${undef -{undef} -undef@ -undef} diff --git a/test/standalone/config_header/cmake/cmake.txt.in b/test/standalone/config_header/cmake/cmake.txt.in @@ -1,65 +0,0 @@ -// empty strings are preserved - -// line with misc content is preserved -no substitution - -// empty @ sigils are preserved -@ -@@ -@@@ -@@@@ - -// simple substitution -@undef@ -${undef} -@defined@ -${defined} -@true@ -${true} -@false@ -${false} -@int@ -${int} -@ident@ -${ident} -@string@ -${string} - -// double packed substitution -@string@@string@ -${string}${string} - -// triple packed substitution -@string@@int@@string@ -@string@${int}@string@ -${string}@int@${string} -${string}${int}${string} - -// double separated substitution -@int@.@int@ -${int}.${int} - -// triple separated substitution -@int@.@true@.@int@ -@int@.${true}.@int@ -${int}.@true@.${int} -${int}.${true}.${int} - -// misc prefix is preserved -false is @false@ -false is ${false} - -// misc suffix is preserved -@true@ is true -${true} is true - -// surrounding content is preserved -what is 6*7? @int@! -what is 6*7? ${int}! - -// incomplete key is preserved -@undef -${undef -{undef} -undef@ -undef} diff --git a/test/standalone/config_header/cmake/cmake_edge_cases.txt b/test/standalone/config_header/cmake/cmake_edge_cases.txt @@ -1,38 +0,0 @@ -/* This file was generated by ConfigHeader using the Zig Build System. */ -// empty lines are preserved - -// @-substition tests -// @-vars resolved only when they wrap valid characters, otherwise considered literals -@text@ -@text@ - -// at-vars are resolved inside curly-vars -text - -// expanded variables are considered strings after expansion -@string@ -@string@ -${string} -${string} -${string} -${string} -${text} -${text} -${text} - -// nested expanded variables are expanded from the inside out -string -string - -// nested vars are only expanded when curly braces are closed -nest_underscore_proxy -nest_underscore_proxy - -// backslash is an invalid character for @ lookup -\@string\@ - -// backslash is preserved, but doesn't affect $curly-braces variable expansion -\text - -// backslash breaks $curly-braces opening bracket identification -$\{string} diff --git a/test/standalone/config_header/cmake/cmake_edge_cases.txt.in b/test/standalone/config_header/cmake/cmake_edge_cases.txt.in @@ -1,37 +0,0 @@ -// empty lines are preserved - -// @-substition tests -// @-vars resolved only when they wrap valid characters, otherwise considered literals -@@string@@ -@${string}@ - -// at-vars are resolved inside curly-vars -${@string_proxy@} - -// expanded variables are considered strings after expansion -@string_at@ -${string_at} -$@string_curly@ -$${string_curly} -${string_var} -@string_var@ -${dollar}{${string}} -@dollar@{${string}} -@dollar@{@string@} - -// nested expanded variables are expanded from the inside out -${string${underscore}proxy} -${string@underscore@proxy} - -// nested vars are only expanded when curly braces are closed -${nest${underscore}proxy} -${nest${${nest_underscore${underscore}proxy}}proxy} - -// backslash is an invalid character for @ lookup -\@string\@ - -// backslash is preserved, but doesn't affect $curly-braces variable expansion -\${string} - -// backslash breaks $curly-braces opening bracket identification -$\{string} diff --git a/test/standalone/config_header/cmake/cmakedefine_edge_cases.h b/test/standalone/config_header/cmake/cmakedefine_edge_cases.h @@ -0,0 +1,43 @@ +/* This file was generated by ConfigHeader using the Zig Build System. */ +// cmakedefine with multi-word string value (truthy) +#define MULTI_WORD "hello world" + +// cmakedefine with multi-word string value (falsy) +/* #undef MULTI_WORD_FALSE */ + +// cmakedefine with no replacement value (truthy) +// TODO: unexpected whitespace is being added here +#define NO_VALUE + +// cmakedefine with no replacement value (falsy) +/* #undef NO_VALUE_FALSE */ + +// cmakedefine01 with underscored variable names (truthy) +#define WITH_UNDERSCORE_TRUE 1 + +// cmakedefine01 with underscored variable names (falsy) +#define WITH_UNDERSCORE_FALSE 0 + +// cmakedefine with leading/trailing underscores (truthy) +#define _LEADING 1 +#define TRAILING_ 1 + +// cmakedefine01 with leading/trailing underscores (truthy) +#define _UNDER_01 1 +#define UNDER_01_ 1 + +// cmakedefine with @ substitution in the replacement value (truthy) +#define SUBST_VAL text + +// cmakedefine with @ substitution in the replacement value (falsy) +/* #undef SUBST_VAL_FALSE */ + +// cmakedefine with @ substitution as the variable name +#define ACTUAL_VAR custom_val + +// cmakedefine with dollar-curly substitution as the variable name +#define ACTUAL_VAR custom_val + +// @ and $ as literal config values +@ +$ diff --git a/test/standalone/config_header/cmake/cmakedefine_edge_cases.h.in b/test/standalone/config_header/cmake/cmakedefine_edge_cases.h.in @@ -0,0 +1,42 @@ +// cmakedefine with multi-word string value (truthy) +#cmakedefine MULTI_WORD "hello world" + +// cmakedefine with multi-word string value (falsy) +#cmakedefine MULTI_WORD_FALSE "hello world" + +// cmakedefine with no replacement value (truthy) +// TODO: unexpected whitespace is being added here +#cmakedefine NO_VALUE + +// cmakedefine with no replacement value (falsy) +#cmakedefine NO_VALUE_FALSE + +// cmakedefine01 with underscored variable names (truthy) +#cmakedefine01 WITH_UNDERSCORE_TRUE + +// cmakedefine01 with underscored variable names (falsy) +#cmakedefine01 WITH_UNDERSCORE_FALSE + +// cmakedefine with leading/trailing underscores (truthy) +#cmakedefine _LEADING 1 +#cmakedefine TRAILING_ 1 + +// cmakedefine01 with leading/trailing underscores (truthy) +#cmakedefine01 _UNDER_01 +#cmakedefine01 UNDER_01_ + +// cmakedefine with @ substitution in the replacement value (truthy) +#cmakedefine SUBST_VAL @STRING@ + +// cmakedefine with @ substitution in the replacement value (falsy) +#cmakedefine SUBST_VAL_FALSE @STRING@ + +// cmakedefine with @ substitution as the variable name +#cmakedefine @VAR_NAME@ custom_val + +// cmakedefine with dollar-curly substitution as the variable name +#cmakedefine ${VAR_NAME} custom_val + +// @ and $ as literal config values +@AT_SIGN@ +${DOLLAR_SIGN} diff --git a/test/standalone/config_header/cmake/config.h b/test/standalone/config_header/cmake/config.h @@ -0,0 +1,144 @@ +/* This file was generated by ConfigHeader using the Zig Build System. */ +// cmakedefine — value is null (undefined) → /* #undef */ +/* #undef NOVAL */ + +// cmakedefine — value is true → #define ... 1 +#define TRUEVAL 1 + +// cmakedefine — value is false → /* #undef */ +/* #undef FALSEVAL */ + +// cmakedefine — value is 0 (falsy) → /* #undef */ +/* #undef ZEROVAL */ + +// cmakedefine — value is 1 (truthy) → #define ... 1 +#define ONEVAL 1 + +// cmakedefine — value is 10 (truthy) → #define ... 1 +#define TENVAL 1 + +// cmakedefine — value is non-empty string (truthy) → #define ... 1 +#define STRINGVAL 1 + +// cmakedefine — leading whitespace preserved in output + #define STRINGVAL 1 + #define STRINGVAL 1 + + +// cmakedefine01 — value is {} (defined, no value) → 0 +#define BOOLNOVAL 0 + +// cmakedefine01 — value is true → 1 +#define BOOLTRUEVAL 1 + +// cmakedefine01 — value is false → 0 +#define BOOLFALSEVAL 0 + +// cmakedefine01 — value is 0 (falsy) → 0 +#define BOOLZEROVAL 0 + +// cmakedefine01 — value is 1 (truthy) → 1 +#define BOOLONEVAL 1 + +// cmakedefine01 — value is 10 (truthy) → 1 +#define BOOLTENVAL 1 + +// cmakedefine01 — value is non-empty string (truthy) → 1 +#define BOOLSTRINGVAL 1 + + +// @-substitution — value is null → empty string +// + +// @-substitution — null values produce nothing even when packed +// + +// @-substitution — null values produce nothing even when separated +// . + +// @-substitution — value is true → "1" +// 1 + +// @-substitution — value is false → "0" +// 0 + +// @-substitution — true + false packed → "10" +// 10 + +// @-substitution — false + true separated → "0.1" +// 0.1 + +// @-substitution — value is 0 → "0" +// 0 + +// @-substitution — value is 1 → "1" +// 1 + +// @-substitution — value is 10 → "10" +// 10 + +// @-substitution — 0 + 1 packed → "01" +// 01 + +// @-substitution — 0 + 10 separated → "0.10" +// 0.10 + +// @-substitution — value is string "test" → "test" +// test + +// @-substitution — strings packed → "testtest" +// testtest + +// @-substitution — strings separated → "test.test" +// test.test + +// @-substitution — mixed null/string/true/zero → "test10" +// test10 + +// dollar-curly substitution — value is null → empty string +// + +// dollar-curly substitution — null values produce nothing even when packed +// + +// dollar-curly substitution — null values produce nothing even when separated +// . + +// dollar-curly substitution — value is true → "1" +// 1 + +// dollar-curly substitution — value is false → "0" +// 0 + +// dollar-curly substitution — true + false packed → "10" +// 10 + +// dollar-curly substitution — false + true separated → "0.1" +// 0.1 + +// dollar-curly substitution — value is 0 → "0" +// 0 + +// dollar-curly substitution — value is 1 → "1" +// 1 + +// dollar-curly substitution — value is 10 → "10" +// 10 + +// dollar-curly substitution — 0 + 1 packed → "01" +// 01 + +// dollar-curly substitution — 0 + 10 separated → "0.10" +// 0.10 + +// dollar-curly substitution — value is string "test" → "test" +// test + +// dollar-curly substitution — strings packed → "testtest" +// testtest + +// dollar-curly substitution — strings separated → "test.test" +// test.test + +// dollar-curly substitution — mixed null/string/true/zero → "test10" +// test10 diff --git a/test/standalone/config_header/cmake/config.h.in b/test/standalone/config_header/cmake/config.h.in @@ -1,147 +1,143 @@ -// cmakedefine -// undefined -#cmakedefine noval unreachable +// cmakedefine — value is null (undefined) → /* #undef */ +#cmakedefine NOVAL unreachable -// 1 -#cmakedefine trueval 1 +// cmakedefine — value is true → #define ... 1 +#cmakedefine TRUEVAL 1 -// undefined -#cmakedefine falseval unreachable +// cmakedefine — value is false → /* #undef */ +#cmakedefine FALSEVAL unreachable -// undefined -#cmakedefine zeroval unreachable +// cmakedefine — value is 0 (falsy) → /* #undef */ +#cmakedefine ZEROVAL unreachable -// 1 -#cmakedefine oneval 1 +// cmakedefine — value is 1 (truthy) → #define ... 1 +#cmakedefine ONEVAL 1 -// 1 -#cmakedefine tenval 1 +// cmakedefine — value is 10 (truthy) → #define ... 1 +#cmakedefine TENVAL 1 -// 1 -#cmakedefine stringval 1 +// cmakedefine — value is non-empty string (truthy) → #define ... 1 +#cmakedefine STRINGVAL 1 -// whitespace test - #cmakedefine stringval 1 - #cmakedefine stringval 1 +// cmakedefine — leading whitespace preserved in output + #cmakedefine STRINGVAL 1 + #cmakedefine STRINGVAL 1 -// cmakedefine01 -// 0 -#cmakedefine01 boolnoval +// cmakedefine01 — value is {} (defined, no value) → 0 +#cmakedefine01 BOOLNOVAL -// 1 -#cmakedefine01 booltrueval +// cmakedefine01 — value is true → 1 +#cmakedefine01 BOOLTRUEVAL -// 0 -#cmakedefine01 boolfalseval +// cmakedefine01 — value is false → 0 +#cmakedefine01 BOOLFALSEVAL -// 0 -#cmakedefine01 boolzeroval +// cmakedefine01 — value is 0 (falsy) → 0 +#cmakedefine01 BOOLZEROVAL -// 1 -#cmakedefine01 booloneval +// cmakedefine01 — value is 1 (truthy) → 1 +#cmakedefine01 BOOLONEVAL -// 1 -#cmakedefine01 booltenval +// cmakedefine01 — value is 10 (truthy) → 1 +#cmakedefine01 BOOLTENVAL -// 1 -#cmakedefine01 boolstringval +// cmakedefine01 — value is non-empty string (truthy) → 1 +#cmakedefine01 BOOLSTRINGVAL -// @ substition +// @-substitution — value is null → empty string +// @NOVAL@ -// no substition -// @noval@ +// @-substitution — null values produce nothing even when packed +// @NOVAL@@NOVAL@ -// no substition -// @noval@@noval@ +// @-substitution — null values produce nothing even when separated +// @NOVAL@.@NOVAL@ -// no substition -// @noval@.@noval@ +// @-substitution — value is true → "1" +// @TRUEVAL@ -// 1 -// @trueval@ +// @-substitution — value is false → "0" +// @FALSEVAL@ -// 0 -// @falseval@ +// @-substitution — true + false packed → "10" +// @TRUEVAL@@FALSEVAL@ -// 10 -// @trueval@@falseval@ +// @-substitution — false + true separated → "0.1" +// @FALSEVAL@.@TRUEVAL@ -// 0.1 -// @falseval@.@trueval@ +// @-substitution — value is 0 → "0" +// @ZEROVAL@ -// 0 -// @zeroval@ +// @-substitution — value is 1 → "1" +// @ONEVAL@ -// 1 -// @oneval@ +// @-substitution — value is 10 → "10" +// @TENVAL@ -// 10 -// @tenval@ +// @-substitution — 0 + 1 packed → "01" +// @ZEROVAL@@ONEVAL@ -// 01 -// @zeroval@@oneval@ +// @-substitution — 0 + 10 separated → "0.10" +// @ZEROVAL@.@TENVAL@ -// 0.10 -// @zeroval@.@tenval@ +// @-substitution — value is string "test" → "test" +// @STRINGVAL@ -// test -// @stringval@ +// @-substitution — strings packed → "testtest" +// @STRINGVAL@@STRINGVAL@ -// testtest -// @stringval@@stringval@ +// @-substitution — strings separated → "test.test" +// @STRINGVAL@.@STRINGVAL@ -// test.test -// @stringval@.@stringval@ +// @-substitution — mixed null/string/true/zero → "test10" +// @NOVAL@@STRINGVAL@@TRUEVAL@@ZEROVAL@ -// test10 -// @noval@@stringval@@trueval@@zeroval@ +// dollar-curly substitution — value is null → empty string +// ${NOVAL} -// no substition -// ${noval} +// dollar-curly substitution — null values produce nothing even when packed +// ${NOVAL}${NOVAL} -// no substition -// ${noval}${noval} +// dollar-curly substitution — null values produce nothing even when separated +// ${NOVAL}.${NOVAL} -// no substition -// ${noval}.${noval} +// dollar-curly substitution — value is true → "1" +// ${TRUEVAL} -// 1 -// ${trueval} +// dollar-curly substitution — value is false → "0" +// ${FALSEVAL} -// 0 -// ${falseval} +// dollar-curly substitution — true + false packed → "10" +// ${TRUEVAL}${FALSEVAL} -// 10 -// ${trueval}${falseval} +// dollar-curly substitution — false + true separated → "0.1" +// ${FALSEVAL}.${TRUEVAL} -// 0.1 -// ${falseval}.${trueval} +// dollar-curly substitution — value is 0 → "0" +// ${ZEROVAL} -// 0 -// ${zeroval} +// dollar-curly substitution — value is 1 → "1" +// ${ONEVAL} -// 1 -// ${oneval} +// dollar-curly substitution — value is 10 → "10" +// ${TENVAL} -// 10 -// ${tenval} +// dollar-curly substitution — 0 + 1 packed → "01" +// ${ZEROVAL}${ONEVAL} -// 01 -// ${zeroval}${oneval} +// dollar-curly substitution — 0 + 10 separated → "0.10" +// ${ZEROVAL}.${TENVAL} -// 0.10 -// ${zeroval}.${tenval} +// dollar-curly substitution — value is string "test" → "test" +// ${STRINGVAL} -// test -// ${stringval} +// dollar-curly substitution — strings packed → "testtest" +// ${STRINGVAL}${STRINGVAL} -// testtest -// ${stringval}${stringval} +// dollar-curly substitution — strings separated → "test.test" +// ${STRINGVAL}.${STRINGVAL} -// test.test -// ${stringval}.${stringval} - -// test10 -// ${noval}${stringval}${trueval}${zeroval} +// dollar-curly substitution — mixed null/string/true/zero → "test10" +// ${NOVAL}${STRINGVAL}${TRUEVAL}${ZEROVAL} diff --git a/test/standalone/config_header/cmake/edge_cases.h b/test/standalone/config_header/cmake/edge_cases.h @@ -0,0 +1,43 @@ +/* This file was generated by ConfigHeader using the Zig Build System. */ +// empty lines are preserved + +// double-wrapped at-sigils work like single-wrapped +@text@ +@text@ + +// at-var lookup happens inside dollar-curly before dollar-curly lookup +text + +// expanded variables are treated as strings and can be re-substituted +@STRING@ +@STRING@ +${STRING} +${STRING} +${STRING} +${STRING} +${text} +${text} +${text} + +// nested dollar-curly expansion from the inside out +STRING +STRING + +// nested dollar-curly — only completed brace blocks are expanded +NEST_UNDERSCORE_PROXY +NEST_UNDERSCORE_PROXY + +// backslash is invalid in at-var names — preserved as literal +\@STRING\@ + +// backslash does not affect dollar-curly expansion +\text + +// backslash before opening brace breaks dollar-curly identification +$\{STRING} + +// bare at-sigils pass through unchanged with no variable map +#define AT @ +#define ATAT @@ +#define ATATAT @@@ +#define ATATATAT @@@@ diff --git a/test/standalone/config_header/cmake/edge_cases.h.in b/test/standalone/config_header/cmake/edge_cases.h.in @@ -0,0 +1,42 @@ +// empty lines are preserved + +// double-wrapped at-sigils work like single-wrapped +@@STRING@@ +@${STRING}@ + +// at-var lookup happens inside dollar-curly before dollar-curly lookup +${@STRING_PROXY@} + +// expanded variables are treated as strings and can be re-substituted +@STRING_AT@ +${STRING_AT} +$@STRING_CURLY@ +$${STRING_CURLY} +${STRING_VAR} +@STRING_VAR@ +${DOLLAR}{${STRING}} +@DOLLAR@{${STRING}} +@DOLLAR@{@STRING@} + +// nested dollar-curly expansion from the inside out +${STRING${UNDERSCORE}PROXY} +${STRING@UNDERSCORE@PROXY} + +// nested dollar-curly — only completed brace blocks are expanded +${NEST${UNDERSCORE}PROXY} +${NEST${${NEST_UNDERSCORE${UNDERSCORE}PROXY}}PROXY} + +// backslash is invalid in at-var names — preserved as literal +\@STRING\@ + +// backslash does not affect dollar-curly expansion +\${STRING} + +// backslash before opening brace breaks dollar-curly identification +$\{STRING} + +// bare at-sigils pass through unchanged with no variable map +#define AT @ +#define ATAT @@ +#define ATATAT @@@ +#define ATATATAT @@@@ diff --git a/test/standalone/config_header/cmake/expected_config.h b/test/standalone/config_header/cmake/expected_config.h @@ -1,148 +0,0 @@ -/* This file was generated by ConfigHeader using the Zig Build System. */ -// cmakedefine -// undefined -/* #undef noval */ - -// 1 -#define trueval 1 - -// undefined -/* #undef falseval */ - -// undefined -/* #undef zeroval */ - -// 1 -#define oneval 1 - -// 1 -#define tenval 1 - -// 1 -#define stringval 1 - -// whitespace test - #define stringval 1 - #define stringval 1 - - -// cmakedefine01 -// 0 -#define boolnoval 0 - -// 1 -#define booltrueval 1 - -// 0 -#define boolfalseval 0 - -// 0 -#define boolzeroval 0 - -// 1 -#define booloneval 1 - -// 1 -#define booltenval 1 - -// 1 -#define boolstringval 1 - - -// @ substition - -// no substition -// - -// no substition -// - -// no substition -// . - -// 1 -// 1 - -// 0 -// 0 - -// 10 -// 10 - -// 0.1 -// 0.1 - -// 0 -// 0 - -// 1 -// 1 - -// 10 -// 10 - -// 01 -// 01 - -// 0.10 -// 0.10 - -// test -// test - -// testtest -// testtest - -// test.test -// test.test - -// test10 -// test10 - -// no substition -// - -// no substition -// - -// no substition -// . - -// 1 -// 1 - -// 0 -// 0 - -// 10 -// 10 - -// 0.1 -// 0.1 - -// 0 -// 0 - -// 1 -// 1 - -// 10 -// 10 - -// 01 -// 01 - -// 0.10 -// 0.10 - -// test -// test - -// testtest -// testtest - -// test.test -// test.test - -// test10 -// test10 diff --git a/test/standalone/config_header/cmake/expected_sigil.h b/test/standalone/config_header/cmake/expected_sigil.h @@ -1,5 +0,0 @@ -/* This file was generated by ConfigHeader using the Zig Build System. */ -#define AT @ -#define ATAT @@ -#define ATATAT @@@ -#define ATATATAT @@@@ diff --git a/test/standalone/config_header/cmake/expected_stack.h b/test/standalone/config_header/cmake/expected_stack.h @@ -1,4 +0,0 @@ -/* This file was generated by ConfigHeader using the Zig Build System. */ -#define NEST_UNDERSCORE_PROXY NEST_UNDERSCORE_PROXY - -#define NEST_UNDERSCORE_PROXY NEST_UNDERSCORE_PROXY diff --git a/test/standalone/config_header/cmake/expected_wrapper.h b/test/standalone/config_header/cmake/expected_wrapper.h @@ -1,31 +0,0 @@ -/* This file was generated by ConfigHeader using the Zig Build System. */ -// becomes TEXT -#define TEXT -#define TEXT - -// becomes `at`TEXT`at` -#define @TEXT@ -#define @TEXT@ - -// becomes TRAP -#define TRAP - -// becomes `dollar sign`{STRING} -#define ${STRING} -#define ${STRING} - -// becomes `dollar sign`{STRING} -#define ${STRING} -#define ${STRING} - -// becomes `dollar sign`{TEXT} -#define ${TEXT} -#define ${TEXT} - -// becomes `at`STRING`at` -#define @STRING@ -#define @STRING@ - -#define \@STRING_VAR\@ -#define \${STRING} -#define $\{STRING_VAR} diff --git a/test/standalone/config_header/cmake/expected_pwd.sh b/test/standalone/config_header/cmake/pwd.sh diff --git a/test/standalone/config_header/cmake/sigil.h.in b/test/standalone/config_header/cmake/sigil.h.in @@ -1,4 +0,0 @@ -#define AT @ -#define ATAT @@ -#define ATATAT @@@ -#define ATATATAT @@@@ diff --git a/test/standalone/config_header/cmake/stack.h.in b/test/standalone/config_header/cmake/stack.h.in @@ -1,3 +0,0 @@ -#define NEST_UNDERSCORE_PROXY ${NEST${UNDERSCORE}PROXY} - -#define NEST_UNDERSCORE_PROXY ${NEST${${NEST_UNDERSCORE${UNDERSCORE}PROXY}}PROXY} diff --git a/test/standalone/config_header/cmake/wrapper.h.in b/test/standalone/config_header/cmake/wrapper.h.in @@ -1,30 +0,0 @@ -// becomes TEXT -#define @STRING@ -#define ${STRING} - -// becomes `at`TEXT`at` -#define @${STRING}@ -#define @@STRING@@ - -// becomes TRAP -#define ${@STRING@} - -// becomes `dollar sign`{STRING} -#define $@STRING_CURLY@ -#define $${STRING_CURLY} - -// becomes `dollar sign`{STRING} -#define @STRING_VAR@ -#define ${STRING_VAR} - -// becomes `dollar sign`{TEXT} -#define ${DOLLAR}{${STRING}} -#define @DOLLAR@{${STRING}} - -// becomes `at`STRING`at` -#define ${STRING_AT} -#define @STRING_AT@ - -#define \@STRING_VAR\@ -#define \${STRING_VAR} -#define $\{STRING_VAR}