From 3ad10bcef1d6e65bd9d3318e95a4cb32f4c6443a Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Sat, 8 Aug 2026 13:47:55 +0900 Subject: [PATCH] test: enroll lib/regex in test-library; retire 989_regex_run --- Makefile | 4 +- test/wcc/989_regex_run.c | 196 --------------------------------------- 2 files changed, 3 insertions(+), 197 deletions(-) delete mode 100644 test/wcc/989_regex_run.c diff --git a/Makefile b/Makefile index 977e1718..d7cdd334 100644 --- a/Makefile +++ b/Makefile @@ -465,13 +465,15 @@ $(BYTEID_WW_TARGETS): wwtest/%: $(BIN)/ww $(BIN)/w6c $(BIN)/w6a \ test-lang: $(LANG_TEST_TARGETS) test-library: $(LIBRARY_TEST_TARGETS) $(BIN)/w6c $(BIN)/w6c_ww \ - $(LIBRARY_STANDALONE_SOURCES) + $(WWTEST_BIN) $(LIBRARY_STANDALONE_SOURCES) @set -e; for f in $(LIBRARY_STANDALONE_SOURCES); do \ echo "library compile c $$f"; \ $(CURDIR)/$(BIN)/w6c $(CURDIR)/$$f > /dev/null; \ echo "library compile ww $$f"; \ $(CURDIR)/$(BIN)/w6c_ww $(CURDIR)/$$f > /dev/null; \ done + @echo "ww test lib/regex" + @$(CURDIR)/$(BIN)/ww test lib/regex test-bootstrap-native: $(WRAPPER_TOOLS) $(BOOTSTRAP_WRAPPER_BINS) @set -e; for t in $(BOOTSTRAP_WRAPPER_BINS); do \ diff --git a/test/wcc/989_regex_run.c b/test/wcc/989_regex_run.c deleted file mode 100644 index cf236df2..00000000 --- a/test/wcc/989_regex_run.c +++ /dev/null @@ -1,196 +0,0 @@ -/* The canonical package route builds separate regex and regex_test -T roots - * under one `ww test ` result. This legacy oracle pins the real 15/33 - * split without recreating package discovery itself. */ -#include -#include -#include -#include -#include - -static const char *whitebox[] = { - "thread_shape", - "newmatch_discriminates", - "is_consuming_kinds", - "delete_thread_middle", - "add_thread_dedup_inherit", - "add_thread_dup_independence", - "run_thread_literal_program", - "run_thread_anchored_route", - "search_matches", - "search_early_exit", - "search_no_match", - "find_last_groupstart_cases", - "shift_direct", - "run_thread_group_arms", - "parse_repetition_cases", -}; - -static int -runwait(const char *cmd) -{ - int rc; - - rc = system(cmd); - if (rc == -1) - return -1; - if (WIFEXITED(rc)) - return WEXITSTATUS(rc); - return 1; -} - -static int -runcapture(const char *cmd, char *out, size_t outsz) -{ - FILE *p; - size_t n; - int ch, overflow, status; - - p = popen(cmd, "r"); - if (p == NULL) - return -1; - n = 0; - overflow = 0; - while ((ch = fgetc(p)) != EOF) { - if (n + 1 < outsz) - out[n++] = ch; - else - overflow = 1; - } - out[n] = '\0'; - status = pclose(p); - if (overflow || status == -1) - return -1; - if (WIFEXITED(status)) - return WEXITSTATUS(status); - return 1; -} - -static int -linecount(const char *out, const char *want) -{ - const char *p, *end; - size_t n; - int count; - - n = strlen(want); - count = 0; - for (p = out; *p != '\0'; p = *end == '\0' ? end : end + 1) { - end = strchr(p, '\n'); - if (end == NULL) - end = p + strlen(p); - if ((size_t)(end - p) == n && memcmp(p, want, n) == 0) - count++; - } - return count; -} - -static int -okcount(const char *out) -{ - const char *p, *end; - static const char suffix[] = " ... ok"; - size_t n, slen; - int count; - - slen = sizeof suffix - 1; - count = 0; - for (p = out; *p != '\0'; p = *end == '\0' ? end : end + 1) { - end = strchr(p, '\n'); - if (end == NULL) - end = p + strlen(p); - n = (size_t)(end - p); - if (n >= slen && memcmp(end - slen, suffix, slen) == 0) - count++; - } - return count; -} - -static int -checkresult(const char *out) -{ - char row[256]; - const char *white_account, *external_account; - int bad; - - bad = 0; - white_account = strstr(out, - "15 discovered, 15 selected, 15 started, 15 completed\n"); - external_account = strstr(out, - "33 discovered, 33 selected, 33 started, 33 completed\n"); - if (linecount(out, - "15 passed, 0 failed, 0 skipped, 0 harness errors") != 1 - || linecount(out, - "15 discovered, 15 selected, 15 started, 15 completed") != 1 - || linecount(out, - "33 passed, 0 failed, 0 skipped, 0 harness errors") != 1 - || linecount(out, - "33 discovered, 33 selected, 33 started, 33 completed") != 1 - || okcount(out) != 48 || white_account == NULL - || external_account == NULL || white_account >= external_account - || strstr(out, "FAIL") != NULL || strstr(out, "HARNESS") != NULL - || strstr(out, "[no tests]") != NULL - || strstr(out, "[no matches]") != NULL) { - fprintf(stderr, "regex_run FAIL: package result was incomplete\n%s", - out); - bad = 1; - } - for (size_t i = 0; i < sizeof whitebox / sizeof whitebox[0]; i++) { - snprintf(row, sizeof row, "regex.%s ... ok", whitebox[i]); - if (linecount(out, row) != 1) { - fprintf(stderr, "regex_run FAIL: regex.%s did not execute " - "exactly once\n", whitebox[i]); - bad = 1; - } - } - return bad ? -1 : 0; -} - -int -main(void) -{ - const char *bin; - char absbin[1024], cwd[1024], tmp[] = "/tmp/wwregex.XXXXXX"; - char cmd[4096], output[32768]; - int rc, failed; - - bin = getenv("BIN"); - if (bin == NULL) - bin = "out/bin"; - if (bin[0] != '/') { - if (getcwd(cwd, sizeof cwd) == NULL) - return 1; - if (snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin) - >= (int)sizeof absbin) - return 1; - bin = absbin; - } - if (getcwd(cwd, sizeof cwd) == NULL) - return 1; - if (mkdtemp(tmp) == NULL) - return 1; - - failed = 0; - /* A unique cwd prevents an unrelated local `regex` path from winning; - * the package coordinator owns both compatible groups in lexical order. */ - if (snprintf(cmd, sizeof cmd, - "cd '%s' && timeout 180 '%s/ww' " - "test -I '%s/lib' '%s/lib/regex'", - tmp, bin, cwd, cwd) >= (int)sizeof cmd) { - failed = 1; - } else { - rc = runcapture(cmd, output, sizeof output); - if (rc != 0 || checkresult(output) != 0) { - fprintf(stderr, "regex_run FAIL: package exited %d\n", rc); - failed = 1; - } else { - printf("regex_run: package 15 white-box + 33 external, " - "48 passed, 0 failed\n"); - } - } - - if (rmdir(tmp) != 0) { - fprintf(stderr, "regex_run FAIL: cannot clean temporary directory\n"); - failed = 1; - } - return failed ? 1 : 0; -}