authorgravatar for michaldrozd@protonmail.chfardragon <michaldrozd@protonmail.ch> 2026-06-04 16:24:13+00:00
committergravatar for michaldrozd@protonmail.chfardragon <michaldrozd@protonmail.ch> 2026-06-05 14:59:18+02:00
log59bd8201dc0f5ed31146ae2c9cff06b89e94cfc8
tree234b7b31dd10bb8e52099592afff6ee5140f1357
parent17093e1dd89497b76c97a83917f0d7e4513f7f88

Restore cmake tests. Merge standalone/cmakedefine and standalone/config_header.


32 files changed, 765 insertions(+), 550 deletions(-)

test/standalone/build.zig.zon-3
...@@ -141,9 +141,6 @@...@@ -141,9 +141,6 @@
141 .strip_struct_init = .{141 .strip_struct_init = .{
142 .path = "strip_struct_init",142 .path = "strip_struct_init",
143 },143 },
144 .cmakedefine = .{
145 .path = "cmakedefine",
146 },
147 .zerolength_check = .{144 .zerolength_check = .{
148 .path = "zerolength_check",145 .path = "zerolength_check",
149 },146 },
test/standalone/cmakedefine/build.zig deleted-104
...@@ -1,104 +0,0 @@
1const std = @import("std");
2const ConfigHeader = std.Build.Step.ConfigHeader;
3
4pub fn build(b: *std.Build) void {
5 const config_header = b.addConfigHeader(
6 .{
7 .style = .{ .cmake = b.path("config.h.in") },
8 .include_path = "config.h",
9 },
10 .{
11 .noval = null,
12 .trueval = true,
13 .falseval = false,
14 .zeroval = 0,
15 .oneval = 1,
16 .tenval = 10,
17 .stringval = "test",
18
19 .boolnoval = {},
20 .booltrueval = true,
21 .boolfalseval = false,
22 .boolzeroval = 0,
23 .booloneval = 1,
24 .booltenval = 10,
25 .boolstringval = "test",
26 },
27 );
28
29 const pwd_sh = b.addConfigHeader(
30 .{
31 .style = .{ .cmake = b.path("pwd.sh.in") },
32 .include_path = "pwd.sh",
33 },
34 .{ .DIR = "${PWD}" },
35 );
36
37 const sigil_header = b.addConfigHeader(
38 .{
39 .style = .{ .cmake = b.path("sigil.h.in") },
40 .include_path = "sigil.h",
41 },
42 .{},
43 );
44
45 const stack_header = b.addConfigHeader(
46 .{
47 .style = .{ .cmake = b.path("stack.h.in") },
48 .include_path = "stack.h",
49 },
50 .{
51 .UNDERSCORE = "_",
52 .NEST_UNDERSCORE_PROXY = "UNDERSCORE",
53 .NEST_PROXY = "NEST_UNDERSCORE_PROXY",
54 },
55 );
56
57 const wrapper_header = b.addConfigHeader(
58 .{
59 .style = .{ .cmake = b.path("wrapper.h.in") },
60 .include_path = "wrapper.h",
61 },
62 .{
63 .DOLLAR = "$",
64 .TEXT = "TRAP",
65
66 .STRING = "TEXT",
67 .STRING_AT = "@STRING@",
68 .STRING_CURLY = "{STRING}",
69 .STRING_VAR = "${STRING}",
70 },
71 );
72
73 const check_exe = b.addExecutable(.{
74 .name = "check",
75 .root_module = b.createModule(.{
76 .target = b.graph.host,
77 .root_source_file = b.path("check.zig"),
78 }),
79 });
80
81 const test_step = b.step("test", "Test it");
82 b.default_step = test_step;
83 test_step.dependOn(addCheck(b, check_exe, config_header));
84 test_step.dependOn(addCheck(b, check_exe, pwd_sh));
85 test_step.dependOn(addCheck(b, check_exe, sigil_header));
86 test_step.dependOn(addCheck(b, check_exe, stack_header));
87 test_step.dependOn(addCheck(b, check_exe, wrapper_header));
88}
89
90fn addCheck(
91 b: *std.Build,
92 check_exe: *std.Build.Step.Compile,
93 ch: *ConfigHeader,
94) *std.Build.Step {
95 // We expect `ch.include_path` to only be a basename to infer where the expected output is.
96 std.debug.assert(std.fs.path.dirname(ch.include_path) == null);
97 const expected_path = b.fmt("expected_{s}", .{ch.include_path});
98
99 const run_check = b.addRunArtifact(check_exe);
100 run_check.addFileArg(ch.getOutputFile());
101 run_check.addFileArg(b.path(expected_path));
102
103 return &run_check.step;
104}
test/standalone/cmakedefine/check.zig deleted-26
...@@ -1,26 +0,0 @@
1const std = @import("std");
2const builtin = @import("builtin");
3
4pub fn main(init: std.process.Init) !void {
5 const arena = init.arena.allocator();
6 const io = init.io;
7 const args = try init.minimal.args.toSlice(arena);
8
9 if (args.len != 3) return error.BadUsage;
10 const actual_path = args[1];
11 const expected_path = args[2];
12
13 const actual = try std.Io.Dir.cwd().readFileAlloc(io, actual_path, arena, .limited(1024 * 1024));
14 const expected = try std.Io.Dir.cwd().readFileAlloc(io, expected_path, arena, .limited(1024 * 1024));
15
16 // The actual output starts with a comment which we should strip out before comparing.
17 const comment_str = "/* This file was generated by ConfigHeader using the Zig Build System. */\n";
18 if (!std.mem.startsWith(u8, actual, comment_str)) {
19 return error.MissingOrMalformedComment;
20 }
21 const actual_without_comment = actual[comment_str.len..];
22
23 if (builtin.os.tag == .windows) return; // https://codeberg.org/ziglang/zig/issues/30138
24
25 try std.testing.expectEqualStrings(expected, actual_without_comment);
26}
test/standalone/cmakedefine/config.h.in deleted-147
...@@ -1,147 +0,0 @@
1// cmakedefine
2// undefined
3#cmakedefine noval unreachable
4
5// 1
6#cmakedefine trueval 1
7
8// undefined
9#cmakedefine falseval unreachable
10
11// undefined
12#cmakedefine zeroval unreachable
13
14// 1
15#cmakedefine oneval 1
16
17// 1
18#cmakedefine tenval 1
19
20// 1
21#cmakedefine stringval 1
22
23// whitespace test
24 #cmakedefine stringval 1
25 #cmakedefine stringval 1
26
27
28// cmakedefine01
29// 0
30#cmakedefine01 boolnoval
31
32// 1
33#cmakedefine01 booltrueval
34
35// 0
36#cmakedefine01 boolfalseval
37
38// 0
39#cmakedefine01 boolzeroval
40
41// 1
42#cmakedefine01 booloneval
43
44// 1
45#cmakedefine01 booltenval
46
47// 1
48#cmakedefine01 boolstringval
49
50
51// @ substition
52
53// no substition
54// @noval@
55
56// no substition
57// @noval@@noval@
58
59// no substition
60// @noval@.@noval@
61
62// 1
63// @trueval@
64
65// 0
66// @falseval@
67
68// 10
69// @trueval@@falseval@
70
71// 0.1
72// @falseval@.@trueval@
73
74// 0
75// @zeroval@
76
77// 1
78// @oneval@
79
80// 10
81// @tenval@
82
83// 01
84// @zeroval@@oneval@
85
86// 0.10
87// @zeroval@.@tenval@
88
89// test
90// @stringval@
91
92// testtest
93// @stringval@@stringval@
94
95// test.test
96// @stringval@.@stringval@
97
98// test10
99// @noval@@stringval@@trueval@@zeroval@
100
101// no substition
102// ${noval}
103
104// no substition
105// ${noval}${noval}
106
107// no substition
108// ${noval}.${noval}
109
110// 1
111// ${trueval}
112
113// 0
114// ${falseval}
115
116// 10
117// ${trueval}${falseval}
118
119// 0.1
120// ${falseval}.${trueval}
121
122// 0
123// ${zeroval}
124
125// 1
126// ${oneval}
127
128// 10
129// ${tenval}
130
131// 01
132// ${zeroval}${oneval}
133
134// 0.10
135// ${zeroval}.${tenval}
136
137// test
138// ${stringval}
139
140// testtest
141// ${stringval}${stringval}
142
143// test.test
144// ${stringval}.${stringval}
145
146// test10
147// ${noval}${stringval}${trueval}${zeroval}
test/standalone/cmakedefine/expected_config.h deleted-147
...@@ -1,147 +0,0 @@
1// cmakedefine
2// undefined
3/* #undef noval */
4
5// 1
6#define trueval 1
7
8// undefined
9/* #undef falseval */
10
11// undefined
12/* #undef zeroval */
13
14// 1
15#define oneval 1
16
17// 1
18#define tenval 1
19
20// 1
21#define stringval 1
22
23// whitespace test
24 #define stringval 1
25 #define stringval 1
26
27
28// cmakedefine01
29// 0
30#define boolnoval 0
31
32// 1
33#define booltrueval 1
34
35// 0
36#define boolfalseval 0
37
38// 0
39#define boolzeroval 0
40
41// 1
42#define booloneval 1
43
44// 1
45#define booltenval 1
46
47// 1
48#define boolstringval 1
49
50
51// @ substition
52
53// no substition
54//
55
56// no substition
57//
58
59// no substition
60// .
61
62// 1
63// 1
64
65// 0
66// 0
67
68// 10
69// 10
70
71// 0.1
72// 0.1
73
74// 0
75// 0
76
77// 1
78// 1
79
80// 10
81// 10
82
83// 01
84// 01
85
86// 0.10
87// 0.10
88
89// test
90// test
91
92// testtest
93// testtest
94
95// test.test
96// test.test
97
98// test10
99// test10
100
101// no substition
102//
103
104// no substition
105//
106
107// no substition
108// .
109
110// 1
111// 1
112
113// 0
114// 0
115
116// 10
117// 10
118
119// 0.1
120// 0.1
121
122// 0
123// 0
124
125// 1
126// 1
127
128// 10
129// 10
130
131// 01
132// 01
133
134// 0.10
135// 0.10
136
137// test
138// test
139
140// testtest
141// testtest
142
143// test.test
144// test.test
145
146// test10
147// test10
test/standalone/cmakedefine/expected_pwd.sh deleted-1
...@@ -1 +0,0 @@
1echo ${PWD}
test/standalone/cmakedefine/expected_sigil.h deleted-4
...@@ -1,4 +0,0 @@
1#define AT @
2#define ATAT @@
3#define ATATAT @@@
4#define ATATATAT @@@@
test/standalone/cmakedefine/expected_stack.h deleted-3
...@@ -1,3 +0,0 @@
1#define NEST_UNDERSCORE_PROXY NEST_UNDERSCORE_PROXY
2
3#define NEST_UNDERSCORE_PROXY NEST_UNDERSCORE_PROXY
test/standalone/cmakedefine/expected_wrapper.h deleted-30
...@@ -1,30 +0,0 @@
1// becomes TEXT
2#define TEXT
3#define TEXT
4
5// becomes `at`TEXT`at`
6#define @TEXT@
7#define @TEXT@
8
9// becomes TRAP
10#define TRAP
11
12// becomes `dollar sign`{STRING}
13#define ${STRING}
14#define ${STRING}
15
16// becomes `dollar sign`{STRING}
17#define ${STRING}
18#define ${STRING}
19
20// becomes `dollar sign`{TEXT}
21#define ${TEXT}
22#define ${TEXT}
23
24// becomes `at`STRING`at`
25#define @STRING@
26#define @STRING@
27
28#define \@STRING_VAR\@
29#define \${STRING}
30#define $\{STRING_VAR}
test/standalone/cmakedefine/pwd.sh.in deleted-1
...@@ -1 +0,0 @@
1echo @DIR@
test/standalone/cmakedefine/sigil.h.in deleted-4
...@@ -1,4 +0,0 @@
1#define AT @
2#define ATAT @@
3#define ATATAT @@@
4#define ATATATAT @@@@
test/standalone/cmakedefine/stack.h.in deleted-3
...@@ -1,3 +0,0 @@
1#define NEST_UNDERSCORE_PROXY ${NEST${UNDERSCORE}PROXY}
2
3#define NEST_UNDERSCORE_PROXY ${NEST${${NEST_UNDERSCORE${UNDERSCORE}PROXY}}PROXY}
test/standalone/cmakedefine/wrapper.h.in deleted-30
...@@ -1,30 +0,0 @@
1// becomes TEXT
2#define @STRING@
3#define ${STRING}
4
5// becomes `at`TEXT`at`
6#define @${STRING}@
7#define @@STRING@@
8
9// becomes TRAP
10#define ${@STRING@}
11
12// becomes `dollar sign`{STRING}
13#define $@STRING_CURLY@
14#define $${STRING_CURLY}
15
16// becomes `dollar sign`{STRING}
17#define @STRING_VAR@
18#define ${STRING_VAR}
19
20// becomes `dollar sign`{TEXT}
21#define ${DOLLAR}{${STRING}}
22#define @DOLLAR@{${STRING}}
23
24// becomes `at`STRING`at`
25#define ${STRING_AT}
26#define @STRING_AT@
27
28#define \@STRING_VAR\@
29#define \${STRING_VAR}
30#define $\{STRING_VAR}
test/standalone/config_header/autoconf_undef/config.h created+23
...@@ -0,0 +1,23 @@
1/* This file was generated by ConfigHeader using the Zig Build System. */
2/* Some Comment */
3
4int foo();
5
6/* #undef SOME_NO */
7#define SOME_TRUE 1
8#define SOME_FALSE 0
9#define SOME_ZERO 0
10#define SOME_ONE 1
11#define SOME_TEN 10
12#define SOME_ENUM foo
13#define SOME_ENUM_LITERAL test
14#define SOME_STRING "test"
15
16// Used twice
17#define SOME_TRUE 1
18
19/* #undef PREFIX_SPACE */
20/* #undef PREFIX_TAB */
21/* #undef POSTFIX_SPACE */
22/* #undef POSTFIX_TAB */
23// TODO: unexpected newline is being added here
test/standalone/config_header/autoconf_undef/config.h.in created+22
...@@ -0,0 +1,22 @@
1/* Some Comment */
2
3int foo();
4
5#undef SOME_NO
6#undef SOME_TRUE
7#undef SOME_FALSE
8#undef SOME_ZERO
9#undef SOME_ONE
10#undef SOME_TEN
11#undef SOME_ENUM
12#undef SOME_ENUM_LITERAL
13#undef SOME_STRING
14
15// Used twice
16#undef SOME_TRUE
17
18#undef PREFIX_SPACE
19#undef PREFIX_TAB
20#undef POSTFIX_SPACE
21#undef POSTFIX_TAB
22// TODO: unexpected newline is being added here
\ No newline at end of file
test/standalone/config_header/build.zig+139-3
...@@ -5,7 +5,9 @@ pub fn build(b: *std.Build) void {...@@ -5,7 +5,9 @@ pub fn build(b: *std.Build) void {
5 b.default_step = test_step;5 b.default_step = test_step;
66
7 const config_header = b.addConfigHeader(7 const config_header = b.addConfigHeader(
8 .{ .style = .{ .autoconf_undef = b.path("config.h.in") } },8 .{ .style = .{
9 .autoconf_undef = b.path("autoconf_undef/config.h.in"),
10 } },
9 .{11 .{
10 .SOME_NO = null,12 .SOME_NO = null,
11 .SOME_TRUE = true,13 .SOME_TRUE = true,
...@@ -23,8 +25,9 @@ pub fn build(b: *std.Build) void {...@@ -23,8 +25,9 @@ pub fn build(b: *std.Build) void {
23 .POSTFIX_TAB = null,25 .POSTFIX_TAB = null,
24 },26 },
25 );27 );
2628 const check_config_header = b.addCheckFile(config_header.getOutputFile(), .{
27 const check_config_header = b.addCheckFile(config_header.getOutputFile(), .{ .expected_exact = @embedFile("config.h") });29 .expected_exact = @embedFile("autoconf_undef/config.h"),
30 });
2831
29 const config_header_autoconf_at = b.addConfigHeader(32 const config_header_autoconf_at = b.addConfigHeader(
30 .{ .style = .{33 .{ .style = .{
...@@ -46,4 +49,137 @@ pub fn build(b: *std.Build) void {...@@ -46,4 +49,137 @@ pub fn build(b: *std.Build) void {
4649
47 test_step.dependOn(&check_config_header.step);50 test_step.dependOn(&check_config_header.step);
48 test_step.dependOn(&check_config_header_autoconf_at.step);51 test_step.dependOn(&check_config_header_autoconf_at.step);
52 addCmakeChecks(b, test_step);
53}
54
55fn addCmakeChecks(b: *std.Build, test_step: *std.Build.Step) void {
56 const config_header = b.addConfigHeader(
57 .{
58 .style = .{ .cmake = b.path("cmake/config.h.in") },
59 .include_path = "config.h",
60 },
61 .{
62 .noval = null,
63 .trueval = true,
64 .falseval = false,
65 .zeroval = 0,
66 .oneval = 1,
67 .tenval = 10,
68 .stringval = "test",
69
70 .boolnoval = {},
71 .booltrueval = true,
72 .boolfalseval = false,
73 .boolzeroval = 0,
74 .booloneval = 1,
75 .booltenval = 10,
76 .boolstringval = "test",
77 },
78 );
79 const check_config_header = b.addCheckFile(config_header.getOutputFile(), .{
80 .expected_exact = @embedFile("cmake/expected_config.h"),
81 });
82 test_step.dependOn(&check_config_header.step);
83
84 const pwd_sh = b.addConfigHeader(
85 .{
86 .style = .{ .cmake = b.path("cmake/pwd.sh.in") },
87 .include_path = "pwd.sh",
88 },
89 .{ .DIR = "${PWD}" },
90 );
91 const check_pwd_sh = b.addCheckFile(pwd_sh.getOutputFile(), .{
92 .expected_exact = @embedFile("cmake/expected_pwd.sh"),
93 });
94 test_step.dependOn(&check_pwd_sh.step);
95
96 const sigil_header = b.addConfigHeader(
97 .{
98 .style = .{ .cmake = b.path("cmake/sigil.h.in") },
99 .include_path = "sigil.h",
100 },
101 .{},
102 );
103 const check_sigil_header = b.addCheckFile(sigil_header.getOutputFile(), .{
104 .expected_exact = @embedFile("cmake/expected_sigil.h"),
105 });
106 test_step.dependOn(&check_sigil_header.step);
107
108 const stack_header = b.addConfigHeader(
109 .{
110 .style = .{ .cmake = b.path("cmake/stack.h.in") },
111 .include_path = "stack.h",
112 },
113 .{
114 .UNDERSCORE = "_",
115 .NEST_UNDERSCORE_PROXY = "UNDERSCORE",
116 .NEST_PROXY = "NEST_UNDERSCORE_PROXY",
117 },
118 );
119 const check_stack_header = b.addCheckFile(stack_header.getOutputFile(), .{
120 .expected_exact = @embedFile("cmake/expected_stack.h"),
121 });
122 test_step.dependOn(&check_stack_header.step);
123
124 const wrapper_header = b.addConfigHeader(
125 .{
126 .style = .{ .cmake = b.path("cmake/wrapper.h.in") },
127 .include_path = "wrapper.h",
128 },
129 .{
130 .DOLLAR = "$",
131 .TEXT = "TRAP",
132
133 .STRING = "TEXT",
134 .STRING_AT = "@STRING@",
135 .STRING_CURLY = "{STRING}",
136 .STRING_VAR = "${STRING}",
137 },
138 );
139 const check_wrapper_header = b.addCheckFile(wrapper_header.getOutputFile(), .{
140 .expected_exact = @embedFile("cmake/expected_wrapper.h"),
141 });
142 test_step.dependOn(&check_wrapper_header.step);
143
144 const config_header_cmake = b.addConfigHeader(
145 .{ .style = .{
146 .cmake = b.path("cmake/cmake.txt.in"),
147 } },
148 .{
149 .undef = null,
150 .defined = {},
151 .true = true,
152 .false = false,
153 .int = 42,
154 .ident = "value",
155 .string = "text",
156 },
157 );
158 const check_config_header_cmake = b.addCheckFile(config_header_cmake.getOutputFile(), .{
159 .expected_exact = @embedFile("cmake/cmake.txt"),
160 });
161 test_step.dependOn(&check_config_header_cmake.step);
162
163 const config_header_cmake_edge_cases = b.addConfigHeader(
164 .{ .style = .{
165 .cmake = b.path("cmake/cmake_edge_cases.txt.in"),
166 } },
167 .{
168 // .at = "@",
169 // .trueval = true,
170 .dollar = "$",
171 .underscore = "_",
172 .string = "text",
173 .string_proxy = "string",
174 .string_at = "@string@",
175 .string_curly = "{string}",
176 .string_var = "${string}",
177 .nest_underscore_proxy = "underscore",
178 .nest_proxy = "nest_underscore_proxy",
179 },
180 );
181 const check_config_header_cmake_edge_cases = b.addCheckFile(config_header_cmake_edge_cases.getOutputFile(), .{
182 .expected_exact = @embedFile("cmake/cmake_edge_cases.txt"),
183 });
184 test_step.dependOn(&check_config_header_cmake_edge_cases.step);
49}185}
test/standalone/config_header/cmake/cmake.txt created+66
...@@ -0,0 +1,66 @@
1/* This file was generated by ConfigHeader using the Zig Build System. */
2// empty strings are preserved
3
4// line with misc content is preserved
5no substitution
6
7// empty @ sigils are preserved
8@
9@@
10@@@
11@@@@
12
13// simple substitution
14
15
16
17
181
191
200
210
2242
2342
24value
25value
26text
27text
28
29// double packed substitution
30texttext
31texttext
32
33// triple packed substitution
34text42text
35text42text
36text42text
37text42text
38
39// double separated substitution
4042.42
4142.42
42
43// triple separated substitution
4442.1.42
4542.1.42
4642.1.42
4742.1.42
48
49// misc prefix is preserved
50false is 0
51false is 0
52
53// misc suffix is preserved
541 is true
551 is true
56
57// surrounding content is preserved
58what is 6*7? 42!
59what is 6*7? 42!
60
61// incomplete key is preserved
62@undef
63${undef
64{undef}
65undef@
66undef}
test/standalone/config_header/cmake/cmake.txt.in created+65
...@@ -0,0 +1,65 @@
1// empty strings are preserved
2
3// line with misc content is preserved
4no substitution
5
6// empty @ sigils are preserved
7@
8@@
9@@@
10@@@@
11
12// simple substitution
13@undef@
14${undef}
15@defined@
16${defined}
17@true@
18${true}
19@false@
20${false}
21@int@
22${int}
23@ident@
24${ident}
25@string@
26${string}
27
28// double packed substitution
29@string@@string@
30${string}${string}
31
32// triple packed substitution
33@string@@int@@string@
34@string@${int}@string@
35${string}@int@${string}
36${string}${int}${string}
37
38// double separated substitution
39@int@.@int@
40${int}.${int}
41
42// triple separated substitution
43@int@.@true@.@int@
44@int@.${true}.@int@
45${int}.@true@.${int}
46${int}.${true}.${int}
47
48// misc prefix is preserved
49false is @false@
50false is ${false}
51
52// misc suffix is preserved
53@true@ is true
54${true} is true
55
56// surrounding content is preserved
57what is 6*7? @int@!
58what is 6*7? ${int}!
59
60// incomplete key is preserved
61@undef
62${undef
63{undef}
64undef@
65undef}
test/standalone/config_header/cmake/cmake_edge_cases.txt created+38
...@@ -0,0 +1,38 @@
1/* This file was generated by ConfigHeader using the Zig Build System. */
2// empty lines are preserved
3
4// @-substition tests
5// @-vars resolved only when they wrap valid characters, otherwise considered literals
6@text@
7@text@
8
9// at-vars are resolved inside curly-vars
10text
11
12// expanded variables are considered strings after expansion
13@string@
14@string@
15${string}
16${string}
17${string}
18${string}
19${text}
20${text}
21${text}
22
23// nested expanded variables are expanded from the inside out
24string
25string
26
27// nested vars are only expanded when curly braces are closed
28nest_underscore_proxy
29nest_underscore_proxy
30
31// backslash is an invalid character for @ lookup
32\@string\@
33
34// backslash is preserved, but doesn't affect $curly-braces variable expansion
35\text
36
37// backslash breaks $curly-braces opening bracket identification
38$\{string}
test/standalone/config_header/cmake/cmake_edge_cases.txt.in created+37
...@@ -0,0 +1,37 @@
1// empty lines are preserved
2
3// @-substition tests
4// @-vars resolved only when they wrap valid characters, otherwise considered literals
5@@string@@
6@${string}@
7
8// at-vars are resolved inside curly-vars
9${@string_proxy@}
10
11// expanded variables are considered strings after expansion
12@string_at@
13${string_at}
14$@string_curly@
15$${string_curly}
16${string_var}
17@string_var@
18${dollar}{${string}}
19@dollar@{${string}}
20@dollar@{@string@}
21
22// nested expanded variables are expanded from the inside out
23${string${underscore}proxy}
24${string@underscore@proxy}
25
26// nested vars are only expanded when curly braces are closed
27${nest${underscore}proxy}
28${nest${${nest_underscore${underscore}proxy}}proxy}
29
30// backslash is an invalid character for @ lookup
31\@string\@
32
33// backslash is preserved, but doesn't affect $curly-braces variable expansion
34\${string}
35
36// backslash breaks $curly-braces opening bracket identification
37$\{string}
test/standalone/config_header/cmake/config.h.in created+147
...@@ -0,0 +1,147 @@
1// cmakedefine
2// undefined
3#cmakedefine noval unreachable
4
5// 1
6#cmakedefine trueval 1
7
8// undefined
9#cmakedefine falseval unreachable
10
11// undefined
12#cmakedefine zeroval unreachable
13
14// 1
15#cmakedefine oneval 1
16
17// 1
18#cmakedefine tenval 1
19
20// 1
21#cmakedefine stringval 1
22
23// whitespace test
24 #cmakedefine stringval 1
25 #cmakedefine stringval 1
26
27
28// cmakedefine01
29// 0
30#cmakedefine01 boolnoval
31
32// 1
33#cmakedefine01 booltrueval
34
35// 0
36#cmakedefine01 boolfalseval
37
38// 0
39#cmakedefine01 boolzeroval
40
41// 1
42#cmakedefine01 booloneval
43
44// 1
45#cmakedefine01 booltenval
46
47// 1
48#cmakedefine01 boolstringval
49
50
51// @ substition
52
53// no substition
54// @noval@
55
56// no substition
57// @noval@@noval@
58
59// no substition
60// @noval@.@noval@
61
62// 1
63// @trueval@
64
65// 0
66// @falseval@
67
68// 10
69// @trueval@@falseval@
70
71// 0.1
72// @falseval@.@trueval@
73
74// 0
75// @zeroval@
76
77// 1
78// @oneval@
79
80// 10
81// @tenval@
82
83// 01
84// @zeroval@@oneval@
85
86// 0.10
87// @zeroval@.@tenval@
88
89// test
90// @stringval@
91
92// testtest
93// @stringval@@stringval@
94
95// test.test
96// @stringval@.@stringval@
97
98// test10
99// @noval@@stringval@@trueval@@zeroval@
100
101// no substition
102// ${noval}
103
104// no substition
105// ${noval}${noval}
106
107// no substition
108// ${noval}.${noval}
109
110// 1
111// ${trueval}
112
113// 0
114// ${falseval}
115
116// 10
117// ${trueval}${falseval}
118
119// 0.1
120// ${falseval}.${trueval}
121
122// 0
123// ${zeroval}
124
125// 1
126// ${oneval}
127
128// 10
129// ${tenval}
130
131// 01
132// ${zeroval}${oneval}
133
134// 0.10
135// ${zeroval}.${tenval}
136
137// test
138// ${stringval}
139
140// testtest
141// ${stringval}${stringval}
142
143// test.test
144// ${stringval}.${stringval}
145
146// test10
147// ${noval}${stringval}${trueval}${zeroval}
test/standalone/config_header/cmake/expected_config.h created+148
...@@ -0,0 +1,148 @@
1/* This file was generated by ConfigHeader using the Zig Build System. */
2// cmakedefine
3// undefined
4/* #undef noval */
5
6// 1
7#define trueval 1
8
9// undefined
10/* #undef falseval */
11
12// undefined
13/* #undef zeroval */
14
15// 1
16#define oneval 1
17
18// 1
19#define tenval 1
20
21// 1
22#define stringval 1
23
24// whitespace test
25 #define stringval 1
26 #define stringval 1
27
28
29// cmakedefine01
30// 0
31#define boolnoval 0
32
33// 1
34#define booltrueval 1
35
36// 0
37#define boolfalseval 0
38
39// 0
40#define boolzeroval 0
41
42// 1
43#define booloneval 1
44
45// 1
46#define booltenval 1
47
48// 1
49#define boolstringval 1
50
51
52// @ substition
53
54// no substition
55//
56
57// no substition
58//
59
60// no substition
61// .
62
63// 1
64// 1
65
66// 0
67// 0
68
69// 10
70// 10
71
72// 0.1
73// 0.1
74
75// 0
76// 0
77
78// 1
79// 1
80
81// 10
82// 10
83
84// 01
85// 01
86
87// 0.10
88// 0.10
89
90// test
91// test
92
93// testtest
94// testtest
95
96// test.test
97// test.test
98
99// test10
100// test10
101
102// no substition
103//
104
105// no substition
106//
107
108// no substition
109// .
110
111// 1
112// 1
113
114// 0
115// 0
116
117// 10
118// 10
119
120// 0.1
121// 0.1
122
123// 0
124// 0
125
126// 1
127// 1
128
129// 10
130// 10
131
132// 01
133// 01
134
135// 0.10
136// 0.10
137
138// test
139// test
140
141// testtest
142// testtest
143
144// test.test
145// test.test
146
147// test10
148// test10
test/standalone/config_header/cmake/expected_pwd.sh created+2
...@@ -0,0 +1,2 @@
1/* This file was generated by ConfigHeader using the Zig Build System. */
2echo ${PWD}
test/standalone/config_header/cmake/expected_sigil.h created+5
...@@ -0,0 +1,5 @@
1/* This file was generated by ConfigHeader using the Zig Build System. */
2#define AT @
3#define ATAT @@
4#define ATATAT @@@
5#define ATATATAT @@@@
test/standalone/config_header/cmake/expected_stack.h created+4
...@@ -0,0 +1,4 @@
1/* This file was generated by ConfigHeader using the Zig Build System. */
2#define NEST_UNDERSCORE_PROXY NEST_UNDERSCORE_PROXY
3
4#define NEST_UNDERSCORE_PROXY NEST_UNDERSCORE_PROXY
test/standalone/config_header/cmake/expected_wrapper.h created+31
...@@ -0,0 +1,31 @@
1/* This file was generated by ConfigHeader using the Zig Build System. */
2// becomes TEXT
3#define TEXT
4#define TEXT
5
6// becomes `at`TEXT`at`
7#define @TEXT@
8#define @TEXT@
9
10// becomes TRAP
11#define TRAP
12
13// becomes `dollar sign`{STRING}
14#define ${STRING}
15#define ${STRING}
16
17// becomes `dollar sign`{STRING}
18#define ${STRING}
19#define ${STRING}
20
21// becomes `dollar sign`{TEXT}
22#define ${TEXT}
23#define ${TEXT}
24
25// becomes `at`STRING`at`
26#define @STRING@
27#define @STRING@
28
29#define \@STRING_VAR\@
30#define \${STRING}
31#define $\{STRING_VAR}
test/standalone/config_header/cmake/pwd.sh.in created+1
...@@ -0,0 +1 @@
1echo @DIR@
test/standalone/config_header/cmake/sigil.h.in created+4
...@@ -0,0 +1,4 @@
1#define AT @
2#define ATAT @@
3#define ATATAT @@@
4#define ATATATAT @@@@
test/standalone/config_header/cmake/stack.h.in created+3
...@@ -0,0 +1,3 @@
1#define NEST_UNDERSCORE_PROXY ${NEST${UNDERSCORE}PROXY}
2
3#define NEST_UNDERSCORE_PROXY ${NEST${${NEST_UNDERSCORE${UNDERSCORE}PROXY}}PROXY}
test/standalone/config_header/cmake/wrapper.h.in created+30
...@@ -0,0 +1,30 @@
1// becomes TEXT
2#define @STRING@
3#define ${STRING}
4
5// becomes `at`TEXT`at`
6#define @${STRING}@
7#define @@STRING@@
8
9// becomes TRAP
10#define ${@STRING@}
11
12// becomes `dollar sign`{STRING}
13#define $@STRING_CURLY@
14#define $${STRING_CURLY}
15
16// becomes `dollar sign`{STRING}
17#define @STRING_VAR@
18#define ${STRING_VAR}
19
20// becomes `dollar sign`{TEXT}
21#define ${DOLLAR}{${STRING}}
22#define @DOLLAR@{${STRING}}
23
24// becomes `at`STRING`at`
25#define ${STRING_AT}
26#define @STRING_AT@
27
28#define \@STRING_VAR\@
29#define \${STRING_VAR}
30#define $\{STRING_VAR}
test/standalone/config_header/config.h deleted-23
...@@ -1,23 +0,0 @@
1/* This file was generated by ConfigHeader using the Zig Build System. */
2/* Some Comment */
3
4int foo();
5
6/* #undef SOME_NO */
7#define SOME_TRUE 1
8#define SOME_FALSE 0
9#define SOME_ZERO 0
10#define SOME_ONE 1
11#define SOME_TEN 10
12#define SOME_ENUM foo
13#define SOME_ENUM_LITERAL test
14#define SOME_STRING "test"
15
16// Used twice
17#define SOME_TRUE 1
18
19/* #undef PREFIX_SPACE */
20/* #undef PREFIX_TAB */
21/* #undef POSTFIX_SPACE */
22/* #undef POSTFIX_TAB */
23
test/standalone/config_header/config.h.in deleted-21
...@@ -1,21 +0,0 @@
1/* Some Comment */
2
3int foo();
4
5#undef SOME_NO
6#undef SOME_TRUE
7#undef SOME_FALSE
8#undef SOME_ZERO
9#undef SOME_ONE
10#undef SOME_TEN
11#undef SOME_ENUM
12#undef SOME_ENUM_LITERAL
13#undef SOME_STRING
14
15// Used twice
16#undef SOME_TRUE
17
18#undef PREFIX_SPACE
19#undef PREFIX_TAB
20#undef POSTFIX_SPACE
21#undef POSTFIX_TAB