diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-04-20 02:31:28 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-04-20 02:31:28 -0400 |
| commit | 037a9d937d41552a44f8fd597e14a2d3491cb499 (patch) | |
| tree | 398f7b9d18988b61ad12db21aa72e21da3aec4d4 /src/main.cpp | |
| parent | 237dfdbdc6f83071cff88489cc66cb83a2d65b00 (diff) | |
| parent | 8654bc18104d64c7a7f9f80bdba75ed4e0c005fa (diff) | |
| download | zig-037a9d937d41552a44f8fd597e14a2d3491cb499.tar.gz zig-037a9d937d41552a44f8fd597e14a2d3491cb499.zip | |
Merge branch 'self-hosted-tests'
Now instead of:
```
./run_tests
```
Do this:
```
./zig build --build-file ../build.zig test
```
For more options, see:
```
./zig build --build-file ../build.zig --help
```
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 32b22e8bda..1d37352427 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,6 +64,9 @@ static int usage(const char *arg0) { " -mwindows (windows only) --subsystem windows to the linker\n" " -rdynamic add all symbols to the dynamic symbol table\n" " -rpath [path] add directory to the runtime library search path\n" + "Test Options:\n" + " --test-filter [text] skip tests that do not match filter\n" + " --test-name-prefix [text] add prefix to all tests\n" , arg0); return EXIT_FAILURE; } @@ -151,6 +154,8 @@ int main(int argc, char **argv) { ZigList<const char *> rpath_list = {0}; bool each_lib_rpath = false; ZigList<const char *> objects = {0}; + const char *test_filter = nullptr; + const char *test_name_prefix = nullptr; if (argc >= 2 && strcmp(argv[1], "build") == 0) { const char *zig_exe_path = arg0; @@ -168,6 +173,7 @@ int main(int argc, char **argv) { ZigList<const char *> args = {0}; args.append(zig_exe_path); + args.append(NULL); // placeholder for (int i = 2; i < argc; i += 1) { if (strcmp(argv[i], "--debug-build-verbose") == 0) { verbose = true; @@ -202,6 +208,8 @@ int main(int argc, char **argv) { Buf build_file_dirname = BUF_INIT; os_path_split(&build_file_abs, &build_file_dirname, &build_file_basename); + args.items[1] = buf_ptr(&build_file_dirname); + bool build_file_exists; if ((err = os_file_exists(&build_file_abs, &build_file_exists))) { fprintf(stderr, "unable to open '%s': %s\n", buf_ptr(&build_file_abs), err_str(err)); @@ -214,11 +222,14 @@ int main(int argc, char **argv) { "Usage: %s build [options]\n" "\n" "General Options:\n" - " --help Print this help and exit.\n" - " --build-file [file] Override path to build.zig.\n" - " --verbose Print commands before executing them.\n" - " --debug-build-verbose Print verbose debugging information for the build system itself.\n" - " --prefix [prefix] Override default install prefix.\n" + " --help Print this help and exit\n" + " --build-file [file] Override path to build.zig\n" + " --verbose Print commands before executing them\n" + " --debug-build-verbose Print verbose debugging information for the build system itself\n" + " --prefix [prefix] Override default install prefix\n" + "\n" + "More options become available when the build file is found.\n" + "Run this command with no options to generate a build.zig template.\n" , zig_exe_path); return 0; } @@ -335,6 +346,10 @@ int main(int argc, char **argv) { linker_script = argv[i]; } else if (strcmp(arg, "-rpath") == 0) { rpath_list.append(argv[i]); + } else if (strcmp(arg, "--test-filter") == 0) { + test_filter = argv[i]; + } else if (strcmp(arg, "--test-name-prefix") == 0) { + test_name_prefix = argv[i]; } else { fprintf(stderr, "Invalid argument: %s\n", arg); return usage(arg0); @@ -556,6 +571,14 @@ int main(int argc, char **argv) { codegen_set_mios_version_min(g, buf_create_from_str(mios_version_min)); } + if (test_filter) { + codegen_set_test_filter(g, buf_create_from_str(test_filter)); + } + + if (test_name_prefix) { + codegen_set_test_name_prefix(g, buf_create_from_str(test_name_prefix)); + } + if (cmd == CmdBuild) { codegen_add_root_code(g, &root_source_dir, &root_source_name, &root_source_code); codegen_link(g, out_file); |
