Scanner subset: newscanner, finish, scanbyte, scanline, scantok, overflow (named-void). Buffer caller-owned; EOF_DISCARD default. Skips Hare's scanner-as-io.stream embed pending task #6 (chained N_DOT-of-N_DOT miscompile).
78 lines
2.1 KiB
C
78 lines
2.1 KiB
C
/*
|
|
* 900_stdlib — verify each stdlib module parses, type-checks, and
|
|
* codegens. We don't link or run them; they exist for downstream
|
|
* users to import. As real applications come online they will start
|
|
* exercising the bodies through the e2e harness.
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
static const char *modules[] = {
|
|
"lib/types/types.ww",
|
|
"lib/ascii/ascii.ww",
|
|
"lib/bytes/bytes.ww",
|
|
"lib/strings/strings.ww",
|
|
"lib/io/io.ww",
|
|
"lib/errors/errors.ww",
|
|
"lib/os/os.ww",
|
|
"lib/strconv/strconv.ww",
|
|
"lib/sort/sort.ww",
|
|
"lib/path/path.ww",
|
|
"lib/encoding/utf8/utf8.ww",
|
|
"lib/encoding/hex/hex.ww",
|
|
"lib/encoding/base32/base32.ww",
|
|
"lib/encoding/base64/base64.ww",
|
|
"lib/hash/fnv/fnv.ww",
|
|
"lib/hash/adler32/adler32.ww",
|
|
"lib/hash/crc16/crc16.ww",
|
|
"lib/hash/crc32/crc32.ww",
|
|
"lib/hash/crc64/crc64.ww",
|
|
"lib/hash/siphash/siphash.ww",
|
|
"lib/math/random/random.ww",
|
|
"lib/time/time.ww",
|
|
"lib/c/libc/libc.ww",
|
|
/* lib/bufio/bufio.ww moved off this list: graduates to the
|
|
* io.stream-based scanner, which carries cross-module type
|
|
* refs (*io.stream, io.eof, io.closed) that only resolve once
|
|
* the driver concatenates `use`d modules. Coverage lives at
|
|
* lib/bufio/bufiotest.ww + the bufio.scanline e2e row in
|
|
* test/wcc/700_e2e.c. */
|
|
"lib/fmt/fmt.ww",
|
|
"lib/net/net.ww",
|
|
NULL
|
|
};
|
|
|
|
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;
|
|
|
|
int n = 0, fail = 0;
|
|
for (int i = 0; modules[i]; i++, n++) {
|
|
char path[1024], cmd[2048];
|
|
snprintf(path, sizeof path, "%s/%s", cwd, modules[i]);
|
|
snprintf(cmd, sizeof cmd, "%s/w6c %s > /dev/null 2>&1",
|
|
bin, path);
|
|
int rc = system(cmd);
|
|
if (rc != 0) {
|
|
fprintf(stderr, "stdlib FAIL: %s (rc=%d)\n", modules[i], rc);
|
|
fail++;
|
|
}
|
|
}
|
|
if (fail) { fprintf(stderr, "%d/%d stdlib modules failed\n", fail, n); return 1; }
|
|
printf("stdlib: %d/%d ok\n", n, n);
|
|
return 0;
|
|
}
|