lib/path: #138 c2-stack buffer port — buffer/push/appendnorm/appendlit/string/isroot/set + dot/dotdot, cstage @test
Faithful realignment of lib/path to Hare's buffer-centric API
(ref/hare/path/{stack,buffer}.ha). Replaces the old str-only path.ww
wholesale (zero consumers). Scope = stack-core: init() deferred (returns
~4KB (buffer|error), rides the #40 arc / #147); abs/dirname/basename land
in c3; extension/join dropped.
appendlit uses the #145 slice-copy-assign arm (buf.buf[lo:hi]=bs), no hand
loop. dot/dotdot are faithful module-global []u8 (D2 #148). MAX =
os.PATH_MAX-1. Divergences (size->i32 indices, frombytes, module-global
consts) cited inline.
Tests: lib/path/pathtest.ww (table-driven), wired at test/wcc/989_path_run.c;
push rows mirror stack.ha:107-111 verbatim incl the restored "/d"
intermediate. Slot 989 (overflow bucket) since 970 is taken.
C-first: cstage @test green; wwstage byte-id deferred to the #125 batch.
path classified M_WWREJECT in 989_lib_byteid (w6c_ww rejects the module-
global slice consts = #120/#29; + the #148 twin #151) — self-graduates back
to M_ID the day wwstage accepts. path moved off the 900_stdlib standalone
list (import-dependent: os.PATH_MAX def-dim + match over imported error
types; coverage at 989_path_run), per the bytes/fmt/os precedent.
Gate: all 324 passed, byte-id 990-997 green, w6c/w6c_ww unchanged
(lib-only, non-embedded).
This commit is contained in:
@@ -15,7 +15,6 @@ static const char *modules[] = {
|
||||
"lib/io/io.ww",
|
||||
"lib/strconv/strconv.ww",
|
||||
"lib/sort/sort.ww",
|
||||
"lib/path/path.ww",
|
||||
"lib/encoding/utf8/utf8.ww",
|
||||
"lib/encoding/base32/base32.ww",
|
||||
"lib/hash/fnv/fnv.ww",
|
||||
@@ -41,13 +40,17 @@ static const char *modules[] = {
|
||||
* lib/encoding/base64 graduated to Hare's io-streaming surface
|
||||
* (hex references io.handle / fmt.fprint / memio.dynamic / strconv /
|
||||
* errors.invalid; base64 references io.handle / memio.dynamic /
|
||||
* bytes.zero / strings.frombytes / errors.invalid). Coverage lives at
|
||||
* bytes.zero / strings.frombytes / errors.invalid); lib/path.path
|
||||
* is import-dependent post-c2-stack realignment ([MAX]u8 via
|
||||
* os.PATH_MAX def-dim + match over imported path error types).
|
||||
* Coverage lives at
|
||||
* lib/bufio/bufiotest.ww + lib/bytes/bytestest.ww +
|
||||
* lib/errors/errnotest.ww + lib/fmt/fmttest.ww + lib/os/stattest.ww
|
||||
* + lib/strings/stringstest.ww + lib/encoding/hex/hextest.ww +
|
||||
* lib/encoding/base64/base64_test.ww (wired at 998_bufio_run.c,
|
||||
* 967_bytes_run.c, 902_errno_run.c, 970_fmt_run.c, 976_stat_run.c,
|
||||
* 966_strings_run.c, 979_hex_run.c, 984_base64_run.c), plus the
|
||||
* 966_strings_run.c, 979_hex_run.c, 984_base64_run.c) + path at
|
||||
* lib/path/pathtest.ww (989_path_run.c), plus the
|
||||
* bufio.scanline / fmt.println e2e rows in test/wcc/700_e2e.c. */
|
||||
"lib/net/net.ww",
|
||||
NULL
|
||||
|
||||
@@ -107,8 +107,14 @@ static const struct ent ents[] = {
|
||||
/* fixtureless modules, import-probe shape */
|
||||
{ .probe = "package main;\nimport sort;\nfn main() i32 = { return 0; };\n",
|
||||
.mode = M_ID, .sentinel = "package sort;", .moddir = "lib/sort" },
|
||||
/* c2-stack path::buffer realignment: w6c compiles, w6c_ww rejects
|
||||
* path's module-global slice consts (const dot/dotdot: []u8) = the
|
||||
* #120/#29 acceptance divergence (module-level composite globals);
|
||||
* + the #148 twin #151 (global []u8 by-value arg). Both → #125
|
||||
* batch. cstage runtime is covered by 989_path_run. M_WWREJECT
|
||||
* self-graduates: flips RED to M_ID the day wwstage accepts this. */
|
||||
{ .probe = "package main;\nimport path;\nfn main() i32 = { return 0; };\n",
|
||||
.mode = M_ID, .sentinel = "package path;", .moddir = "lib/path" },
|
||||
.mode = M_WWREJECT, .cite = "#120/#29", .sentinel = "package path;", .moddir = "lib/path" },
|
||||
{ .probe = "package main;\nimport endian;\nfn main() i32 = { return 0; };\n",
|
||||
.mode = M_ID, .sentinel = "package endian;", .moddir = "lib/endian" },
|
||||
{ .probe = "package main;\nimport net;\nfn main() i32 = { return 0; };\n",
|
||||
|
||||
49
test/wcc/989_path_run.c
Normal file
49
test/wcc/989_path_run.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 989_path_run — execute the lib/path @test fixture under the
|
||||
* C-side `ww run` driver and assert exit 0.
|
||||
*
|
||||
* Same thin-wrapper shape as 979_hex_run / 967_bytes_run:
|
||||
* pathtest.ww carries its own `export fn main()` that drives the
|
||||
* @test fns and signals which case failed via the exit code.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
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/path/pathtest.ww";
|
||||
char path[1024], cmd[2048];
|
||||
snprintf(path, sizeof path, "%s/%s", cwd, src);
|
||||
snprintf(cmd, sizeof cmd, "%s/ww run %s", bin, path);
|
||||
int rc = runwait(cmd);
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "path_run FAIL: %s exited %d\n", src, rc);
|
||||
return 1;
|
||||
}
|
||||
printf("path_run: %s ok\n", src);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user