| ... | @@ -165,6 +165,41 @@ const ErrorMsg = union(enum) { | ... | @@ -165,6 +165,41 @@ const ErrorMsg = union(enum) { |
| 165 | } | 165 | } |
| 166 | }; | 166 | }; |
| 167 | | 167 | |
| | 168 | const TestManifestConfigDefaults = struct { |
| | 169 | /// Asserts if the key doesn't exist - yep, it's an oversight alright. |
| | 170 | fn get(@"type": TestManifest.Type, key: []const u8) []const u8 { |
| | 171 | if (std.mem.eql(u8, key, "backend")) { |
| | 172 | return "stage2"; |
| | 173 | } else if (std.mem.eql(u8, key, "target")) { |
| | 174 | comptime { |
| | 175 | var defaults: []const u8 = ""; |
| | 176 | // TODO should we only return "mainstream" targets by default here? |
| | 177 | // Linux |
| | 178 | inline for (&[_][]const u8{ "x86_64", "arm", "aarch64" }) |arch| { |
| | 179 | inline for (&[_][]const u8{ "gnu", "musl" }) |abi| { |
| | 180 | defaults = defaults ++ arch ++ "-linux-" ++ abi ++ ","; |
| | 181 | } |
| | 182 | } |
| | 183 | // macOS |
| | 184 | inline for (&[_][]const u8{ "x86_64", "aarch64" }) |arch| { |
| | 185 | defaults = defaults ++ arch ++ "-macos" ++ ","; |
| | 186 | } |
| | 187 | // Wasm |
| | 188 | defaults = defaults ++ "wasm32-wasi"; |
| | 189 | return defaults[0 .. defaults.len - 2]; |
| | 190 | } |
| | 191 | } else if (std.mem.eql(u8, key, "output_mode")) { |
| | 192 | return switch (@"type") { |
| | 193 | .@"error" => "Obj", |
| | 194 | .run => "Exe", |
| | 195 | .cli => @panic("TODO test harness for CLI tests"), |
| | 196 | }; |
| | 197 | } else if (std.mem.eql(u8, key, "is_test")) { |
| | 198 | return "0"; |
| | 199 | } else unreachable; |
| | 200 | } |
| | 201 | }; |
| | 202 | |
| 168 | /// Manifest syntax example: | 203 | /// Manifest syntax example: |
| 169 | /// (see https://github.com/ziglang/zig/issues/11288) | 204 | /// (see https://github.com/ziglang/zig/issues/11288) |
| 170 | /// | 205 | /// |