| author | |
| committer | |
| log | d12f1f5b4954d893111c05420060354537a1485c |
| tree | 1026150a776607a5aae06273b3c3fa37ec47831f |
| parent | 9b7f438882b4f283d252d8ca364607fae385cc1a |
rename self hosted tests to behavior tests10 files changed, 137 insertions(+), 84 deletions(-)
build.zig+12-8| ... | @@ -5,18 +5,20 @@ pub fn build(b: &Builder) { | ... | @@ -5,18 +5,20 @@ pub fn build(b: &Builder) { |
| 5 | const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter"); | 5 | const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter"); |
| 6 | const test_step = b.step("test", "Run all the tests"); | 6 | const test_step = b.step("test", "Run all the tests"); |
| 7 | 7 | ||
| 8 | const self_hosted_tests = b.step("test-self-hosted", "Run the self-hosted tests"); | 8 | const behavior_tests = b.step("test-behavior", "Run the behavior tests"); |
| 9 | test_step.dependOn(self_hosted_tests); | 9 | test_step.dependOn(behavior_tests); |
| 10 | for ([]bool{false, true}) |release| { | 10 | for ([]bool{false, true}) |release| { |
| 11 | for ([]bool{false, true}) |link_libc| { | 11 | for ([]bool{false, true}) |link_libc| { |
| 12 | const these_tests = b.addTest("test/self_hosted.zig"); | 12 | const these_tests = b.addTest("test/behavior.zig"); |
| 13 | // TODO add prefix to test names | 13 | these_tests.setNamePrefix(b.fmt("behavior-{}-{} ", |
| 14 | // TODO pass test_filter to these_tests | 14 | if (release) "release" else "debug", |
| 15 | if (link_libc) "c" else "bare")); | ||
| 16 | these_tests.setFilter(test_filter); | ||
| 15 | these_tests.setRelease(release); | 17 | these_tests.setRelease(release); |
| 16 | if (link_libc) { | 18 | if (link_libc) { |
| 17 | these_tests.linkLibrary("c"); | 19 | these_tests.linkLibrary("c"); |
| 18 | } | 20 | } |
| 19 | self_hosted_tests.dependOn(&these_tests.step); | 21 | behavior_tests.dependOn(&these_tests.step); |
| 20 | } | 22 | } |
| 21 | } | 23 | } |
| 22 | 24 | ||
| ... | @@ -25,8 +27,10 @@ pub fn build(b: &Builder) { | ... | @@ -25,8 +27,10 @@ pub fn build(b: &Builder) { |
| 25 | for ([]bool{false, true}) |release| { | 27 | for ([]bool{false, true}) |release| { |
| 26 | for ([]bool{false, true}) |link_libc| { | 28 | for ([]bool{false, true}) |link_libc| { |
| 27 | const these_tests = b.addTest("std/index.zig"); | 29 | const these_tests = b.addTest("std/index.zig"); |
| 28 | // TODO add prefix to test names | 30 | these_tests.setNamePrefix(b.fmt("std-{}-{} ", |
| 29 | // TODO pass test_filter to these_tests | 31 | if (release) "release" else "debug", |
| 32 | if (link_libc) "c" else "bare")); | ||
| 33 | these_tests.setFilter(test_filter); | ||
| 30 | these_tests.setRelease(release); | 34 | these_tests.setRelease(release); |
| 31 | if (link_libc) { | 35 | if (link_libc) { |
| 32 | these_tests.linkLibrary("c"); | 36 | these_tests.linkLibrary("c"); |
src/all_types.hpp+3| ... | @@ -1458,6 +1458,9 @@ struct CodeGen { | ... | @@ -1458,6 +1458,9 @@ struct CodeGen { |
| 1458 | ZigList<Buf *> link_objects; | 1458 | ZigList<Buf *> link_objects; |
| 1459 | 1459 | ||
| 1460 | ZigList<TypeTableEntry *> name_table_enums; | 1460 | ZigList<TypeTableEntry *> name_table_enums; |
| 1461 | |||
| 1462 | Buf *test_filter; | ||
| 1463 | Buf *test_name_prefix; | ||
| 1461 | }; | 1464 | }; |
| 1462 | 1465 | ||
| 1463 | enum VarLinkage { | 1466 | enum VarLinkage { |
src/analyze.cpp+8-1| ... | @@ -1959,7 +1959,14 @@ static void preview_test_decl(CodeGen *g, AstNode *node, ScopeDecls *decls_scope | ... | @@ -1959,7 +1959,14 @@ static void preview_test_decl(CodeGen *g, AstNode *node, ScopeDecls *decls_scope |
| 1959 | if (import->package != g->root_package) | 1959 | if (import->package != g->root_package) |
| 1960 | return; | 1960 | return; |
| 1961 | 1961 | ||
| 1962 | Buf *test_name = node->data.test_decl.name; | 1962 | Buf *decl_name_buf = node->data.test_decl.name; |
| 1963 | |||
| 1964 | Buf *test_name = g->test_name_prefix ? | ||
| 1965 | buf_sprintf("%s%s", buf_ptr(g->test_name_prefix), buf_ptr(decl_name_buf)) : decl_name_buf; | ||
| 1966 | |||
| 1967 | if (g->test_filter != nullptr && strstr(buf_ptr(test_name), buf_ptr(g->test_filter)) == nullptr) { | ||
| 1968 | return; | ||
| 1969 | } | ||
| 1963 | 1970 | ||
| 1964 | TldFn *tld_fn = allocate<TldFn>(1); | 1971 | TldFn *tld_fn = allocate<TldFn>(1); |
| 1965 | init_tld(&tld_fn->base, TldIdFn, test_name, VisibModPrivate, node, &decls_scope->base); | 1972 | init_tld(&tld_fn->base, TldIdFn, test_name, VisibModPrivate, node, &decls_scope->base); |
src/codegen.cpp+8| ... | @@ -147,6 +147,14 @@ void codegen_set_omit_zigrt(CodeGen *g, bool omit_zigrt) { | ... | @@ -147,6 +147,14 @@ void codegen_set_omit_zigrt(CodeGen *g, bool omit_zigrt) { |
| 147 | g->omit_zigrt = omit_zigrt; | 147 | g->omit_zigrt = omit_zigrt; |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | void codegen_set_test_filter(CodeGen *g, Buf *filter) { | ||
| 151 | g->test_filter = filter; | ||
| 152 | } | ||
| 153 | |||
| 154 | void codegen_set_test_name_prefix(CodeGen *g, Buf *prefix) { | ||
| 155 | g->test_name_prefix = prefix; | ||
| 156 | } | ||
| 157 | |||
| 150 | void codegen_set_is_test(CodeGen *g, bool is_test_build) { | 158 | void codegen_set_is_test(CodeGen *g, bool is_test_build) { |
| 151 | g->is_test_build = is_test_build; | 159 | g->is_test_build = is_test_build; |
| 152 | } | 160 | } |
src/codegen.hpp+2| ... | @@ -44,6 +44,8 @@ void codegen_set_mmacosx_version_min(CodeGen *g, Buf *mmacosx_version_min); | ... | @@ -44,6 +44,8 @@ void codegen_set_mmacosx_version_min(CodeGen *g, Buf *mmacosx_version_min); |
| 44 | void codegen_set_mios_version_min(CodeGen *g, Buf *mios_version_min); | 44 | void codegen_set_mios_version_min(CodeGen *g, Buf *mios_version_min); |
| 45 | void codegen_set_linker_script(CodeGen *g, const char *linker_script); | 45 | void codegen_set_linker_script(CodeGen *g, const char *linker_script); |
| 46 | void codegen_set_omit_zigrt(CodeGen *g, bool omit_zigrt); | 46 | void codegen_set_omit_zigrt(CodeGen *g, bool omit_zigrt); |
| 47 | void codegen_set_test_filter(CodeGen *g, Buf *filter); | ||
| 48 | void codegen_set_test_name_prefix(CodeGen *g, Buf *prefix); | ||
| 47 | 49 | ||
| 48 | PackageTableEntry *new_package(const char *root_src_dir, const char *root_src_path); | 50 | PackageTableEntry *new_package(const char *root_src_dir, const char *root_src_path); |
| 49 | void codegen_add_root_code(CodeGen *g, Buf *source_dir, Buf *source_basename, Buf *source_code); | 51 | void codegen_add_root_code(CodeGen *g, Buf *source_dir, Buf *source_basename, Buf *source_code); |
src/main.cpp+17| ... | @@ -64,6 +64,9 @@ static int usage(const char *arg0) { | ... | @@ -64,6 +64,9 @@ static int usage(const char *arg0) { |
| 64 | " -mwindows (windows only) --subsystem windows to the linker\n" | 64 | " -mwindows (windows only) --subsystem windows to the linker\n" |
| 65 | " -rdynamic add all symbols to the dynamic symbol table\n" | 65 | " -rdynamic add all symbols to the dynamic symbol table\n" |
| 66 | " -rpath [path] add directory to the runtime library search path\n" | 66 | " -rpath [path] add directory to the runtime library search path\n" |
| 67 | "Test Options:\n" | ||
| 68 | " --test-filter [text] skip tests that do not match filter\n" | ||
| 69 | " --test-name-prefix [text] add prefix to all tests\n" | ||
| 67 | , arg0); | 70 | , arg0); |
| 68 | return EXIT_FAILURE; | 71 | return EXIT_FAILURE; |
| 69 | } | 72 | } |
| ... | @@ -151,6 +154,8 @@ int main(int argc, char **argv) { | ... | @@ -151,6 +154,8 @@ int main(int argc, char **argv) { |
| 151 | ZigList<const char *> rpath_list = {0}; | 154 | ZigList<const char *> rpath_list = {0}; |
| 152 | bool each_lib_rpath = false; | 155 | bool each_lib_rpath = false; |
| 153 | ZigList<const char *> objects = {0}; | 156 | ZigList<const char *> objects = {0}; |
| 157 | const char *test_filter = nullptr; | ||
| 158 | const char *test_name_prefix = nullptr; | ||
| 154 | 159 | ||
| 155 | if (argc >= 2 && strcmp(argv[1], "build") == 0) { | 160 | if (argc >= 2 && strcmp(argv[1], "build") == 0) { |
| 156 | const char *zig_exe_path = arg0; | 161 | const char *zig_exe_path = arg0; |
| ... | @@ -341,6 +346,10 @@ int main(int argc, char **argv) { | ... | @@ -341,6 +346,10 @@ int main(int argc, char **argv) { |
| 341 | linker_script = argv[i]; | 346 | linker_script = argv[i]; |
| 342 | } else if (strcmp(arg, "-rpath") == 0) { | 347 | } else if (strcmp(arg, "-rpath") == 0) { |
| 343 | rpath_list.append(argv[i]); | 348 | rpath_list.append(argv[i]); |
| 349 | } else if (strcmp(arg, "--test-filter") == 0) { | ||
| 350 | test_filter = argv[i]; | ||
| 351 | } else if (strcmp(arg, "--test-name-prefix") == 0) { | ||
| 352 | test_name_prefix = argv[i]; | ||
| 344 | } else { | 353 | } else { |
| 345 | fprintf(stderr, "Invalid argument: %s\n", arg); | 354 | fprintf(stderr, "Invalid argument: %s\n", arg); |
| 346 | return usage(arg0); | 355 | return usage(arg0); |
| ... | @@ -562,6 +571,14 @@ int main(int argc, char **argv) { | ... | @@ -562,6 +571,14 @@ int main(int argc, char **argv) { |
| 562 | codegen_set_mios_version_min(g, buf_create_from_str(mios_version_min)); | 571 | codegen_set_mios_version_min(g, buf_create_from_str(mios_version_min)); |
| 563 | } | 572 | } |
| 564 | 573 | ||
| 574 | if (test_filter) { | ||
| 575 | codegen_set_test_filter(g, buf_create_from_str(test_filter)); | ||
| 576 | } | ||
| 577 | |||
| 578 | if (test_name_prefix) { | ||
| 579 | codegen_set_test_name_prefix(g, buf_create_from_str(test_name_prefix)); | ||
| 580 | } | ||
| 581 | |||
| 565 | if (cmd == CmdBuild) { | 582 | if (cmd == CmdBuild) { |
| 566 | codegen_add_root_code(g, &root_source_dir, &root_source_name, &root_source_code); | 583 | codegen_add_root_code(g, &root_source_dir, &root_source_name, &root_source_code); |
| 567 | codegen_link(g, out_file); | 584 | codegen_link(g, out_file); |
std/build.zig+46-34| ... | @@ -10,7 +10,7 @@ const StdIo = os.ChildProcess.StdIo; | ... | @@ -10,7 +10,7 @@ const StdIo = os.ChildProcess.StdIo; |
| 10 | const Term = os.ChildProcess.Term; | 10 | const Term = os.ChildProcess.Term; |
| 11 | const BufSet = @import("buf_set.zig").BufSet; | 11 | const BufSet = @import("buf_set.zig").BufSet; |
| 12 | const BufMap = @import("buf_map.zig").BufMap; | 12 | const BufMap = @import("buf_map.zig").BufMap; |
| 13 | const fmt = @import("fmt.zig"); | 13 | const fmt_lib = @import("fmt.zig"); |
| 14 | 14 | ||
| 15 | error ExtraArg; | 15 | error ExtraArg; |
| 16 | error UncleanExit; | 16 | error UncleanExit; |
| ... | @@ -189,7 +189,7 @@ pub const Builder = struct { | ... | @@ -189,7 +189,7 @@ pub const Builder = struct { |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | pub fn addLog(self: &Builder, comptime format: []const u8, args: ...) -> &LogStep { | 191 | pub fn addLog(self: &Builder, comptime format: []const u8, args: ...) -> &LogStep { |
| 192 | const data = %%fmt.allocPrint(self.allocator, format, args); | 192 | const data = self.fmt(format, args); |
| 193 | const log_step = %%self.allocator.create(LogStep); | 193 | const log_step = %%self.allocator.create(LogStep); |
| 194 | *log_step = LogStep.init(self, data); | 194 | *log_step = LogStep.init(self, data); |
| 195 | return log_step; | 195 | return log_step; |
| ... | @@ -543,6 +543,10 @@ pub const Builder = struct { | ... | @@ -543,6 +543,10 @@ pub const Builder = struct { |
| 543 | fn pathFromRoot(self: &Builder, rel_path: []const u8) -> []u8 { | 543 | fn pathFromRoot(self: &Builder, rel_path: []const u8) -> []u8 { |
| 544 | return %%os.path.join(self.allocator, self.build_root, rel_path); | 544 | return %%os.path.join(self.allocator, self.build_root, rel_path); |
| 545 | } | 545 | } |
| 546 | |||
| 547 | pub fn fmt(self: &Builder, comptime format: []const u8, args: ...) -> []u8 { | ||
| 548 | return %%fmt_lib.allocPrint(self.allocator, format, args); | ||
| 549 | } | ||
| 546 | }; | 550 | }; |
| 547 | 551 | ||
| 548 | const Version = struct { | 552 | const Version = struct { |
| ... | @@ -891,19 +895,16 @@ pub const LinkStep = struct { | ... | @@ -891,19 +895,16 @@ pub const LinkStep = struct { |
| 891 | fn computeOutFileName(self: &LinkStep) { | 895 | fn computeOutFileName(self: &LinkStep) { |
| 892 | switch (self.out_type) { | 896 | switch (self.out_type) { |
| 893 | OutType.Exe => { | 897 | OutType.Exe => { |
| 894 | self.out_filename = %%fmt.allocPrint(self.builder.allocator, "{}{}", | 898 | self.out_filename = self.builder.fmt("{}{}", self.name, self.target.exeFileExt()); |
| 895 | self.name, self.target.exeFileExt()); | ||
| 896 | }, | 899 | }, |
| 897 | OutType.Lib => { | 900 | OutType.Lib => { |
| 898 | if (self.static) { | 901 | if (self.static) { |
| 899 | self.out_filename = %%fmt.allocPrint(self.builder.allocator, "lib{}.a", self.name); | 902 | self.out_filename = self.builder.fmt("lib{}.a", self.name); |
| 900 | } else { | 903 | } else { |
| 901 | self.out_filename = %%fmt.allocPrint(self.builder.allocator, "lib{}.so.{d}.{d}.{d}", | 904 | self.out_filename = self.builder.fmt("lib{}.so.{d}.{d}.{d}", |
| 902 | self.name, self.version.major, self.version.minor, self.version.patch); | 905 | self.name, self.version.major, self.version.minor, self.version.patch); |
| 903 | self.major_only_filename = %%fmt.allocPrint(self.builder.allocator, | 906 | self.major_only_filename = self.builder.fmt("lib{}.so.{d}", self.name, self.version.major); |
| 904 | "lib{}.so.{d}", self.name, self.version.major); | 907 | self.name_only_filename = self.builder.fmt("lib{}.so", self.name); |
| 905 | self.name_only_filename = %%fmt.allocPrint(self.builder.allocator, | ||
| 906 | "lib{}.so", self.name); | ||
| 907 | } | 908 | } |
| 908 | }, | 909 | }, |
| 909 | } | 910 | } |
| ... | @@ -1051,15 +1052,19 @@ pub const TestStep = struct { | ... | @@ -1051,15 +1052,19 @@ pub const TestStep = struct { |
| 1051 | release: bool, | 1052 | release: bool, |
| 1052 | verbose: bool, | 1053 | verbose: bool, |
| 1053 | link_libs: BufSet, | 1054 | link_libs: BufSet, |
| 1055 | name_prefix: []const u8, | ||
| 1056 | filter: ?[]const u8, | ||
| 1054 | 1057 | ||
| 1055 | pub fn init(builder: &Builder, root_src: []const u8) -> TestStep { | 1058 | pub fn init(builder: &Builder, root_src: []const u8) -> TestStep { |
| 1056 | const step_name = %%fmt.allocPrint(builder.allocator, "test {}", root_src); | 1059 | const step_name = builder.fmt("test {}", root_src); |
| 1057 | TestStep { | 1060 | TestStep { |
| 1058 | .step = Step.init(step_name, builder.allocator, make), | 1061 | .step = Step.init(step_name, builder.allocator, make), |
| 1059 | .builder = builder, | 1062 | .builder = builder, |
| 1060 | .root_src = root_src, | 1063 | .root_src = root_src, |
| 1061 | .release = false, | 1064 | .release = false, |
| 1062 | .verbose = false, | 1065 | .verbose = false, |
| 1066 | .name_prefix = "", | ||
| 1067 | .filter = null, | ||
| 1063 | .link_libs = BufSet.init(builder.allocator), | 1068 | .link_libs = BufSet.init(builder.allocator), |
| 1064 | } | 1069 | } |
| 1065 | } | 1070 | } |
| ... | @@ -1076,6 +1081,14 @@ pub const TestStep = struct { | ... | @@ -1076,6 +1081,14 @@ pub const TestStep = struct { |
| 1076 | %%self.link_libs.put(name); | 1081 | %%self.link_libs.put(name); |
| 1077 | } | 1082 | } |
| 1078 | 1083 | ||
| 1084 | pub fn setNamePrefix(self: &TestStep, text: []const u8) { | ||
| 1085 | self.name_prefix = text; | ||
| 1086 | } | ||
| 1087 | |||
| 1088 | pub fn setFilter(self: &TestStep, text: ?[]const u8) { | ||
| 1089 | self.filter = text; | ||
| 1090 | } | ||
| 1091 | |||
| 1079 | fn make(step: &Step) -> %void { | 1092 | fn make(step: &Step) -> %void { |
| 1080 | const self = @fieldParentPtr(TestStep, "step", step); | 1093 | const self = @fieldParentPtr(TestStep, "step", step); |
| 1081 | const builder = self.builder; | 1094 | const builder = self.builder; |
| ... | @@ -1094,6 +1107,16 @@ pub const TestStep = struct { | ... | @@ -1094,6 +1107,16 @@ pub const TestStep = struct { |
| 1094 | %%zig_args.append("--release"); | 1107 | %%zig_args.append("--release"); |
| 1095 | } | 1108 | } |
| 1096 | 1109 | ||
| 1110 | if (const filter ?= self.filter) { | ||
| 1111 | %%zig_args.append("--test-filter"); | ||
| 1112 | %%zig_args.append(filter); | ||
| 1113 | } | ||
| 1114 | |||
| 1115 | if (self.name_prefix.len != 0) { | ||
| 1116 | %%zig_args.append("--test-name-prefix"); | ||
| 1117 | %%zig_args.append(self.name_prefix); | ||
| 1118 | } | ||
| 1119 | |||
| 1097 | { | 1120 | { |
| 1098 | var it = self.link_libs.iterator(); | 1121 | var it = self.link_libs.iterator(); |
| 1099 | while (true) { | 1122 | while (true) { |
| ... | @@ -1169,14 +1192,12 @@ pub const CLibrary = struct { | ... | @@ -1169,14 +1192,12 @@ pub const CLibrary = struct { |
| 1169 | 1192 | ||
| 1170 | fn computeOutFileName(self: &CLibrary) { | 1193 | fn computeOutFileName(self: &CLibrary) { |
| 1171 | if (self.static) { | 1194 | if (self.static) { |
| 1172 | self.out_filename = %%fmt.allocPrint(self.builder.allocator, "lib{}.a", self.name); | 1195 | self.out_filename = self.builder.fmt("lib{}.a", self.name); |
| 1173 | } else { | 1196 | } else { |
| 1174 | self.out_filename = %%fmt.allocPrint(self.builder.allocator, "lib{}.so.{d}.{d}.{d}", | 1197 | self.out_filename = self.builder.fmt("lib{}.so.{d}.{d}.{d}", |
| 1175 | self.name, self.version.major, self.version.minor, self.version.patch); | 1198 | self.name, self.version.major, self.version.minor, self.version.patch); |
| 1176 | self.major_only_filename = %%fmt.allocPrint(self.builder.allocator, | 1199 | self.major_only_filename = self.builder.fmt("lib{}.so.{d}", self.name, self.version.major); |
| 1177 | "lib{}.so.{d}", self.name, self.version.major); | 1200 | self.name_only_filename = self.builder.fmt("lib{}.so", self.name); |
| 1178 | self.name_only_filename = %%fmt.allocPrint(self.builder.allocator, | ||
| 1179 | "lib{}.so", self.name); | ||
| 1180 | } | 1201 | } |
| 1181 | } | 1202 | } |
| 1182 | 1203 | ||
| ... | @@ -1235,7 +1256,7 @@ pub const CLibrary = struct { | ... | @@ -1235,7 +1256,7 @@ pub const CLibrary = struct { |
| 1235 | %%cc_args.append(source_file); | 1256 | %%cc_args.append(source_file); |
| 1236 | 1257 | ||
| 1237 | // TODO don't dump the .o file in the same place as the source file | 1258 | // TODO don't dump the .o file in the same place as the source file |
| 1238 | const o_file = %%fmt.allocPrint(builder.allocator, "{}{}", source_file, self.target.oFileExt()); | 1259 | const o_file = builder.fmt("{}{}", source_file, self.target.oFileExt()); |
| 1239 | defer builder.allocator.free(o_file); | 1260 | defer builder.allocator.free(o_file); |
| 1240 | %%cc_args.append("-o"); | 1261 | %%cc_args.append("-o"); |
| 1241 | %%cc_args.append(o_file); | 1262 | %%cc_args.append(o_file); |
| ... | @@ -1262,8 +1283,7 @@ pub const CLibrary = struct { | ... | @@ -1262,8 +1283,7 @@ pub const CLibrary = struct { |
| 1262 | %%cc_args.append("-fPIC"); | 1283 | %%cc_args.append("-fPIC"); |
| 1263 | %%cc_args.append("-shared"); | 1284 | %%cc_args.append("-shared"); |
| 1264 | 1285 | ||
| 1265 | const soname_arg = %%fmt.allocPrint(builder.allocator, "-Wl,-soname,lib{}.so.{d}", | 1286 | const soname_arg = builder.fmt("-Wl,-soname,lib{}.so.{d}", self.name, self.version.major); |
| 1266 | self.name, self.version.major); | ||
| 1267 | defer builder.allocator.free(soname_arg); | 1287 | defer builder.allocator.free(soname_arg); |
| 1268 | %%cc_args.append(soname_arg); | 1288 | %%cc_args.append(soname_arg); |
| 1269 | 1289 | ||
| ... | @@ -1372,7 +1392,7 @@ pub const CExecutable = struct { | ... | @@ -1372,7 +1392,7 @@ pub const CExecutable = struct { |
| 1372 | %%cc_args.append(source_file); | 1392 | %%cc_args.append(source_file); |
| 1373 | 1393 | ||
| 1374 | // TODO don't dump the .o file in the same place as the source file | 1394 | // TODO don't dump the .o file in the same place as the source file |
| 1375 | const o_file = %%fmt.allocPrint(builder.allocator, "{}{}", source_file, self.target.oFileExt()); | 1395 | const o_file = builder.fmt("{}{}", source_file, self.target.oFileExt()); |
| 1376 | defer builder.allocator.free(o_file); | 1396 | defer builder.allocator.free(o_file); |
| 1377 | %%cc_args.append("-o"); | 1397 | %%cc_args.append("-o"); |
| 1378 | %%cc_args.append(o_file); | 1398 | %%cc_args.append(o_file); |
| ... | @@ -1400,7 +1420,7 @@ pub const CExecutable = struct { | ... | @@ -1400,7 +1420,7 @@ pub const CExecutable = struct { |
| 1400 | %%cc_args.append("-o"); | 1420 | %%cc_args.append("-o"); |
| 1401 | %%cc_args.append(self.name); | 1421 | %%cc_args.append(self.name); |
| 1402 | 1422 | ||
| 1403 | const rpath_arg = %%fmt.allocPrint(builder.allocator, "-Wl,-rpath,{}", builder.out_dir); | 1423 | const rpath_arg = builder.fmt("-Wl,-rpath,{}", builder.out_dir); |
| 1404 | defer builder.allocator.free(rpath_arg); | 1424 | defer builder.allocator.free(rpath_arg); |
| 1405 | %%cc_args.append(rpath_arg); | 1425 | %%cc_args.append(rpath_arg); |
| 1406 | 1426 | ||
| ... | @@ -1462,9 +1482,7 @@ pub const InstallCLibraryStep = struct { | ... | @@ -1462,9 +1482,7 @@ pub const InstallCLibraryStep = struct { |
| 1462 | pub fn init(builder: &Builder, lib: &CLibrary) -> InstallCLibraryStep { | 1482 | pub fn init(builder: &Builder, lib: &CLibrary) -> InstallCLibraryStep { |
| 1463 | var self = InstallCLibraryStep { | 1483 | var self = InstallCLibraryStep { |
| 1464 | .builder = builder, | 1484 | .builder = builder, |
| 1465 | .step = Step.init( | 1485 | .step = Step.init(builder.fmt("install {}", lib.step.name), builder.allocator, make), |
| 1466 | %%fmt.allocPrint(builder.allocator, "install {}", lib.step.name), | ||
| 1467 | builder.allocator, make), | ||
| 1468 | .lib = lib, | 1486 | .lib = lib, |
| 1469 | .dest_file = undefined, | 1487 | .dest_file = undefined, |
| 1470 | }; | 1488 | }; |
| ... | @@ -1497,9 +1515,7 @@ pub const InstallFileStep = struct { | ... | @@ -1497,9 +1515,7 @@ pub const InstallFileStep = struct { |
| 1497 | pub fn init(builder: &Builder, src_path: []const u8, dest_path: []const u8) -> InstallFileStep { | 1515 | pub fn init(builder: &Builder, src_path: []const u8, dest_path: []const u8) -> InstallFileStep { |
| 1498 | return InstallFileStep { | 1516 | return InstallFileStep { |
| 1499 | .builder = builder, | 1517 | .builder = builder, |
| 1500 | .step = Step.init( | 1518 | .step = Step.init(builder.fmt("install {}", src_path), builder.allocator, make), |
| 1501 | %%fmt.allocPrint(builder.allocator, "install {}", src_path), | ||
| 1502 | builder.allocator, make), | ||
| 1503 | .src_path = src_path, | 1519 | .src_path = src_path, |
| 1504 | .dest_path = dest_path, | 1520 | .dest_path = dest_path, |
| 1505 | }; | 1521 | }; |
| ... | @@ -1521,9 +1537,7 @@ pub const WriteFileStep = struct { | ... | @@ -1521,9 +1537,7 @@ pub const WriteFileStep = struct { |
| 1521 | pub fn init(builder: &Builder, file_path: []const u8, data: []const u8) -> WriteFileStep { | 1537 | pub fn init(builder: &Builder, file_path: []const u8, data: []const u8) -> WriteFileStep { |
| 1522 | return WriteFileStep { | 1538 | return WriteFileStep { |
| 1523 | .builder = builder, | 1539 | .builder = builder, |
| 1524 | .step = Step.init( | 1540 | .step = Step.init(builder.fmt("writefile {}", file_path), builder.allocator, make), |
| 1525 | %%fmt.allocPrint(builder.allocator, "writefile {}", file_path), | ||
| 1526 | builder.allocator, make), | ||
| 1527 | .file_path = file_path, | 1541 | .file_path = file_path, |
| 1528 | .data = data, | 1542 | .data = data, |
| 1529 | }; | 1543 | }; |
| ... | @@ -1550,9 +1564,7 @@ pub const LogStep = struct { | ... | @@ -1550,9 +1564,7 @@ pub const LogStep = struct { |
| 1550 | pub fn init(builder: &Builder, data: []const u8) -> LogStep { | 1564 | pub fn init(builder: &Builder, data: []const u8) -> LogStep { |
| 1551 | return LogStep { | 1565 | return LogStep { |
| 1552 | .builder = builder, | 1566 | .builder = builder, |
| 1553 | .step = Step.init( | 1567 | .step = Step.init(builder.fmt("log {}", data), builder.allocator, make), |
| 1554 | %%fmt.allocPrint(builder.allocator, "log {}", data), | ||
| 1555 | builder.allocator, make), | ||
| 1556 | .data = data, | 1568 | .data = data, |
| 1557 | }; | 1569 | }; |
| 1558 | } | 1570 | } |
test/behavior.zig created+39| ... | @@ -0,0 +1,39 @@ | ||
| 1 | comptime { | ||
| 2 | _ = @import("cases/array.zig"); | ||
| 3 | _ = @import("cases/asm.zig"); | ||
| 4 | _ = @import("cases/atomics.zig"); | ||
| 5 | _ = @import("cases/bool.zig"); | ||
| 6 | _ = @import("cases/cast.zig"); | ||
| 7 | _ = @import("cases/const_slice_child.zig"); | ||
| 8 | _ = @import("cases/defer.zig"); | ||
| 9 | _ = @import("cases/enum.zig"); | ||
| 10 | _ = @import("cases/enum_with_members.zig"); | ||
| 11 | _ = @import("cases/error.zig"); | ||
| 12 | _ = @import("cases/eval.zig"); | ||
| 13 | _ = @import("cases/field_parent_ptr.zig"); | ||
| 14 | _ = @import("cases/fn.zig"); | ||
| 15 | _ = @import("cases/for.zig"); | ||
| 16 | _ = @import("cases/generics.zig"); | ||
| 17 | _ = @import("cases/goto.zig"); | ||
| 18 | _ = @import("cases/if.zig"); | ||
| 19 | _ = @import("cases/import.zig"); | ||
| 20 | _ = @import("cases/incomplete_struct_param_tld.zig"); | ||
| 21 | _ = @import("cases/ir_block_deps.zig"); | ||
| 22 | _ = @import("cases/math.zig"); | ||
| 23 | _ = @import("cases/misc.zig"); | ||
| 24 | _ = @import("cases/namespace_depends_on_compile_var/index.zig"); | ||
| 25 | _ = @import("cases/null.zig"); | ||
| 26 | _ = @import("cases/pub_enum/index.zig"); | ||
| 27 | _ = @import("cases/sizeof_and_typeof.zig"); | ||
| 28 | _ = @import("cases/struct.zig"); | ||
| 29 | _ = @import("cases/struct_contains_slice_of_itself.zig"); | ||
| 30 | _ = @import("cases/switch.zig"); | ||
| 31 | _ = @import("cases/switch_prong_err_enum.zig"); | ||
| 32 | _ = @import("cases/switch_prong_implicit_cast.zig"); | ||
| 33 | _ = @import("cases/this.zig"); | ||
| 34 | _ = @import("cases/try.zig"); | ||
| 35 | _ = @import("cases/undefined.zig"); | ||
| 36 | _ = @import("cases/var_args.zig"); | ||
| 37 | _ = @import("cases/void.zig"); | ||
| 38 | _ = @import("cases/while.zig"); | ||
| 39 | } | ||
test/self_hosted.zig deleted-39| ... | @@ -1,39 +0,0 @@ | ||
| 1 | comptime { | ||
| 2 | _ = @import("cases/array.zig"); | ||
| 3 | _ = @import("cases/asm.zig"); | ||
| 4 | _ = @import("cases/atomics.zig"); | ||
| 5 | _ = @import("cases/bool.zig"); | ||
| 6 | _ = @import("cases/cast.zig"); | ||
| 7 | _ = @import("cases/const_slice_child.zig"); | ||
| 8 | _ = @import("cases/defer.zig"); | ||
| 9 | _ = @import("cases/enum.zig"); | ||
| 10 | _ = @import("cases/enum_with_members.zig"); | ||
| 11 | _ = @import("cases/error.zig"); | ||
| 12 | _ = @import("cases/eval.zig"); | ||
| 13 | _ = @import("cases/field_parent_ptr.zig"); | ||
| 14 | _ = @import("cases/fn.zig"); | ||
| 15 | _ = @import("cases/for.zig"); | ||
| 16 | _ = @import("cases/generics.zig"); | ||
| 17 | _ = @import("cases/goto.zig"); | ||
| 18 | _ = @import("cases/if.zig"); | ||
| 19 | _ = @import("cases/import.zig"); | ||
| 20 | _ = @import("cases/incomplete_struct_param_tld.zig"); | ||
| 21 | _ = @import("cases/ir_block_deps.zig"); | ||
| 22 | _ = @import("cases/math.zig"); | ||
| 23 | _ = @import("cases/misc.zig"); | ||
| 24 | _ = @import("cases/namespace_depends_on_compile_var/index.zig"); | ||
| 25 | _ = @import("cases/null.zig"); | ||
| 26 | _ = @import("cases/pub_enum/index.zig"); | ||
| 27 | _ = @import("cases/sizeof_and_typeof.zig"); | ||
| 28 | _ = @import("cases/struct.zig"); | ||
| 29 | _ = @import("cases/struct_contains_slice_of_itself.zig"); | ||
| 30 | _ = @import("cases/switch.zig"); | ||
| 31 | _ = @import("cases/switch_prong_err_enum.zig"); | ||
| 32 | _ = @import("cases/switch_prong_implicit_cast.zig"); | ||
| 33 | _ = @import("cases/this.zig"); | ||
| 34 | _ = @import("cases/try.zig"); | ||
| 35 | _ = @import("cases/undefined.zig"); | ||
| 36 | _ = @import("cases/var_args.zig"); | ||
| 37 | _ = @import("cases/void.zig"); | ||
| 38 | _ = @import("cases/while.zig"); | ||
| 39 | } | ||
test/tests.zig+2-2| ... | @@ -341,8 +341,8 @@ pub const CompareOutputContext = struct { | ... | @@ -341,8 +341,8 @@ pub const CompareOutputContext = struct { |
| 341 | }, | 341 | }, |
| 342 | Special.None => { | 342 | Special.None => { |
| 343 | for ([]bool{false, true}) |release| { | 343 | for ([]bool{false, true}) |release| { |
| 344 | const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "{} ({})", | 344 | const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "{} {} ({})", |
| 345 | case.name, if (release) "release" else "debug"); | 345 | "compare-output", case.name, if (release) "release" else "debug"); |
| 346 | if (const filter ?= self.test_filter) { | 346 | if (const filter ?= self.test_filter) { |
| 347 | if (mem.indexOf(u8, annotated_case_name, filter) == null) | 347 | if (mem.indexOf(u8, annotated_case_name, filter) == null) |
| 348 | continue; | 348 | continue; |