| 52 | } |
| 53 | |
| 54 | static int setup_parallel_repo(void) { |
| 55 | snprintf(g_par_tmpdir, sizeof(g_par_tmpdir), "/tmp/cbm_par_XXXXXX"); |
| 56 | if (!cbm_mkdtemp(g_par_tmpdir)) |
| 57 | return -1; |
| 58 | |
| 59 | char path[512]; |
| 60 | |
| 61 | /* main.go */ |
| 62 | snprintf(path, sizeof(path), "%s/main.go", g_par_tmpdir); |
| 63 | FILE *f = fopen(path, "w"); |
| 64 | if (!f) |
| 65 | return -1; |
| 66 | fprintf(f, "package main\n\nimport \"pkg\"\n\n" |
| 67 | "func main() {\n\tpkg.Serve()\n}\n"); |
| 68 | fclose(f); |
| 69 | |
| 70 | /* pkg/ */ |
| 71 | snprintf(path, sizeof(path), "%s/pkg", g_par_tmpdir); |
| 72 | cbm_mkdir(path); |
| 73 | |
| 74 | /* pkg/service.go */ |
| 75 | snprintf(path, sizeof(path), "%s/pkg/service.go", g_par_tmpdir); |
| 76 | f = fopen(path, "w"); |
| 77 | if (!f) |
| 78 | return -1; |
| 79 | fprintf(f, "package pkg\n\nimport \"pkg/util\"\n\n" |
| 80 | "func Serve() {\n\tutil.Help()\n}\n"); |
| 81 | fclose(f); |
| 82 | |
| 83 | /* pkg/util/ */ |
| 84 | snprintf(path, sizeof(path), "%s/pkg/util", g_par_tmpdir); |
| 85 | cbm_mkdir(path); |
| 86 | |
| 87 | /* pkg/util/helper.go */ |
| 88 | snprintf(path, sizeof(path), "%s/pkg/util/helper.go", g_par_tmpdir); |
| 89 | f = fopen(path, "w"); |
| 90 | if (!f) |
| 91 | return -1; |
| 92 | fprintf(f, "package util\n\nfunc Help() {}\n"); |
| 93 | fclose(f); |
| 94 | |
| 95 | /* Java interface/implements/extends trio: the parallel resolve path must |
| 96 | * make the same Interface-label edge split (IMPLEMENTS vs INHERITS) as |
| 97 | * the sequential semantic pass, and both must emit OVERRIDE for methods |
| 98 | * redefined from an explicit base. Without these files the IMPLEMENTS/ |
| 99 | * INHERITS parity tests compare 0 == 0 and guard nothing (the demotion |
| 100 | * bug shipped: elasticsearch had 11k implements-as-INHERITS edges). */ |
| 101 | snprintf(path, sizeof(path), "%s/probe", g_par_tmpdir); |
| 102 | cbm_mkdir(path); |
| 103 | snprintf(path, sizeof(path), "%s/probe/Shape.java", g_par_tmpdir); |
| 104 | f = fopen(path, "w"); |
| 105 | if (!f) |
| 106 | return -1; |
| 107 | fprintf(f, "package probe;\npublic interface Shape {\n double area();\n}\n"); |
| 108 | fclose(f); |
| 109 | snprintf(path, sizeof(path), "%s/probe/Circle.java", g_par_tmpdir); |
| 110 | f = fopen(path, "w"); |
| 111 | if (!f) |
no test coverage detected