/* * 905_nkname_run — execute the lib/ww nkname @test fixture under the * C-side `ww run` driver and assert exit 0. * * Same thin-wrapper shape as 904_tok_run / 904_ascii_run: asttest.ww * carries its own `export fn main()` that drives the @test fn and * signals which case failed via the exit code. This pins nkname's * if-ladder -> switch fold (every nkind + the unknown-kind fallback), * which the 990_selfhost wwdump diff only covers for kinds that appear * in its corpus. * * Unlike 904_tok_run, the fixture imports the `syntax` package, whose * printer references the token tkind/tokname, so the run needs * `-I lib/ww` to resolve the `import syntax` directory package. */ #include #include #include #include static int runwait(const char *cmd) { int rc = system(cmd); if (rc == -1) return -1; if (WIFEXITED(rc)) return WEXITSTATUS(rc); return 1; } int main(void) { const char *bin = getenv("BIN"); if (!bin) bin = "out/bin"; char absbin[1024]; if (bin[0] != '/') { char cwd[1024]; if (getcwd(cwd, sizeof cwd) == NULL) return 1; snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin); bin = absbin; } char cwd[1024]; if (getcwd(cwd, sizeof cwd) == NULL) return 1; const char *src = "lib/ww/syntax/asttest.ww"; char path[1024], inc[1024], cmd[3072]; snprintf(path, sizeof path, "%s/%s", cwd, src); snprintf(inc, sizeof inc, "%s/lib/ww", cwd); snprintf(cmd, sizeof cmd, "%s/ww test -I %s %s", bin, inc, path); int rc = runwait(cmd); if (rc != 0) { fprintf(stderr, "nkname_run FAIL: %s exited %d\n", src, rc); return 1; } printf("nkname_run: %s ok\n", src); return 0; }