babel
aien-dev/babel
Brought by drakestapleton
GitHub aien-dev/babel#5 (code only)
Apply it
git checkout -b patch-5fe88edf99e5141b 156360f854a699ded0d000b7fdb6dd23821c9b14 curl -fsSL https://interplane.io/drakestapleton/babel/patches/5fe88edf99e5141b.patch | git am
Provenance
github-import 1
aien-dev/babel
5
a52b8e5210b91e643d8dad986ec14173d6e2bec5
{"kind":"github-import","owner":"aien-dev","repo":"babel","number":5,"url":"https://github.com/aien-dev/babel/pull/5","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:40:46Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb index 4aeadec..ea7b592 100644 --- a/.crumb +++ b/.crumb @@ -3,33 +3,33 @@ "generated": { "children": [ { - "digest": "af8fe5d090009428c3a7f7a6207bb8b53d6b2ee9ffd1c2c06e494d04f36fd119", - "last_commit": "13ad42d", + "digest": "82d819b4d960abb324717c6363e7b2960f1b11d13ebfb86b6ffbc536237931f4", + "last_commit": "d2d4150", "name": "examples", - "purpose": "sample input mixing S1 and unsupported code" + "purpose": "sample input mixing S1 and unsupported code; complete/ is an all-S1 input for the --complete gat" }, { - "digest": "a7d728a20559ca35eedad6b7de962b45a98668a39463eb7f6452dc47b4390238", - "last_commit": "13ad42d", + "digest": "6dc617e1e9e92e9a42205c850c72b3bf4506ccac9b9ef81eac14a5b7c47bace0", + "last_commit": "45564f3", "name": "src", "purpose": "babel driver in Omega, compiled in file order by build.sh" }, { - "digest": "dd282acfe6e92b7f93b9262d0eecf2cb2a354cbb4f5624f48434af0614fa1579", - "last_commit": "13ad42d", + "digest": "751a47ee52b040849dee910d04299ccf6c42d6e7136d1af368e4f083a0ec8787", + "last_commit": "45564f3", "name": "tests", "purpose": "independent checks of babel output, incl. mutated-oracle negative control" } ], - "children_root": "sha256:dc6ffb084a85883f9499e594ea5a6bce59505a0433e4a02b0efaa75e2f111e2d", - "compiled_at": "2026-10-28T21:30:12Z", + "children_root": "sha256:ea2829440ae17d7212557a9b46d75ed2199b4ca3d899140158ae6aef6f38935f", + "compiled_at": "2026-10-31T00:49:27Z", "compiler": "crumb-compile/1", - "digest": "sha256:894cb1341d1429c8a6c11cdf8348ce4761ad9b04ce1ffc2b17607e504485f942", + "digest": "sha256:6471bfe8aa05b8380145ec8023be3c047dbe8aa8b3169263f47112ca54199351", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 30, - "generated_at_commit": "13ad42d9c3383774f34caf9087bf5f7d9d3d675c", - "source_tree": "sha256:686ed332e9343a3c30ae0c81940788aa5650355e772e5822687daa5a1f4c7b64" + "files": 33, + "generated_at_commit": "45564f352035e039f19d2060c7254ed8f36085f9", + "source_tree": "sha256:1b6ed3323de20b98035049d3f0f0d9f0b1f601ce556a0ee8391aca282dc21c43" } }, "name": "babel", diff --git a/README.md b/README.md index fa08a3f..398cafc 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ examples/sample.babel/ report.json the same, schema babel.report.v1 ``` -With no `--to` and a terminal on stdin, babel asks for the target language. `--json` prints `report.json` on stdout instead of the summary table. +With no `--to` and a terminal on stdin, babel asks for the target language. `--json` prints `report.json` on stdout instead of the summary table. `--complete` makes the exit status follow the completion record (see [Completion](#completion)). `--exclude FILE` names a manifest of non-source entries that are excluded from completion with a reason (see [Exclusion manifest](#exclusion-manifest)). **Status: pre-alpha.** Only one narrow profile is implemented, and anything outside it is refused by name. The [ROADMAP](ROADMAP.md) is PROPOSED work, not a feature list. @@ -42,17 +42,72 @@ The omega-mv `<lang>-import` adapters exist for Rust, Python, C++, Zig and Go, o | UNSUPPORTED(rc) | An adapter refused the function with a profile exit code. The codes are 64 name, 65 syntax, 66 type, 67 limit, 68 arithmetic, 69 construct, 70 unknown identifier, 71 signature and 72 preprocessor. | | MISSING_IMPLEMENTATION | Nothing in the pipeline handles this item: C declarations, preprocessor lines, other languages. The reason names the item. | | FAIL | A stage ran and disagreed: an output differed on a vector, a build failed, or the oracle failed. Babel exits 1. | -| NOT_RUN | A required toolchain is absent, so the check did not happen. It does not count as a pass. | +| NOT_RUN | A required toolchain is absent, so the check did not happen. It does not count as a pass. A `ZIG=` or `GO=` path that is not executable counts as absent. | | ABSORBED | `#include <stdint.h>`: the S1 profile header, which babel supplies to every unit. | +| SKIPPED | Completion record only: an entry the walk did not enter (hidden entry, symbolic link, other non-regular file, `*.babel` folder, unreadable directory). | +| EXCLUDED | Completion record only: a non-source file or skipped entry named by the `--exclude` manifest, with the manifest's reason. | The vectors are the boundary values {0, 1, 2, 2^32−1, 2^32, 2^63−1, 2^63, 2^64−2, 2^64−1}. Functions of arity ≤ 3 get the full cross product; higher arities get 81 rows. Every function also gets 64 splitmix64 vectors from seed 20261026. The original C function is compiled verbatim by `cc` as the oracle. Babel never stores or replays source: every target file is adapter output. +## Completion + +Every run computes a completion record, policy `complete-v1`, and writes it to `report.json` (`"completion"`), to a "Completion" section of REPORT.md and to one summary line. Its denominator counts: + +- every walked file (a file in a language babel does not recognise, such as `README.txt`, is open as MISSING_IMPLEMENTATION); +- every split item (TRANSLATED, ABSORBED, UNSUPPORTED, MISSING_IMPLEMENTATION, FAIL, NOT_RUN); +- every SKIPPED entry, each listed by path; +- every required check: the three differential legs (original C, Omega, target) of each unit that reached the differential, the generated target test for rust and python, and each toolchain the target needs (`cc` for the oracle plus the target's own). + +The state is the first that applies: + +| State | Condition | +|---|---| +| FAILED | Any FAIL item or check, including a failed generated test. | +| BLOCKED | No FAIL, but a required check is NOT_RUN or a toolchain is missing. | +| PARTIAL | No FAIL and no NOT_RUN, but UNSUPPORTED, MISSING_IMPLEMENTATION or SKIPPED items remain. | +| COMPLETE | Every item TRANSLATED, ABSORBED or EXCLUDED (covered + excluded == denominator), nothing open, every required check ran and passed. | + +``` +"completion": {"policy": "complete-v1", "enforced": false, "state": "PARTIAL", "denominator": 39, "covered": 26, + "open": [{"kind": "unit", "item": "src/mix.c:15-17", "name": "zero", "verdict": "UNSUPPORTED(68)", "reason": "..."}, ...]} +``` + +`kind` is `file`, `unit`, `skipped`, `check` or `toolchain`; `item` is `path:line[-line]` for units and their legs, a path for files and skipped entries, and a tool name for toolchains. `enforced` is true under `--complete`. `examples/sample` is PARTIAL (26 of 39); `examples/complete` (three S1 functions and the stdint include) is COMPLETE. `excluded_count`, `excluded` and `manifest` are always present: without `--exclude` they are `0`, `[]` and `null`. + +### Exclusion manifest + +`--exclude FILE` reads a manifest of entries that are not source and need no translation, such as documentation or VCS metadata: + +``` +# <path> <reason...>; blank lines and # lines are ignored +README.txt notes for people, no code +.gitignore VCS metadata +docs/ prose only +``` + +Each entry is a path relative to the walked root: an exact path, or a directory prefix (`docs/` covers everything below `docs`). Globs are refused. A matched item stays in the denominator with verdict EXCLUDED and is listed under `"excluded"` with its `reason`, `matched_by` (the entry) and manifest `line`; it is not counted as covered. The summary line shows `C of D items covered, X excluded by manifest <sha8>`, and REPORT.md lists the excluded items with the manifest path and full sha256: + +``` +"excluded_count": 1, "excluded": [{"kind": "file", "item": "README.txt", "verdict": "EXCLUDED", "reason": "notes for people, no code", "matched_by": "README.txt", "line": 2}], +"manifest": {"path": "babel.exclude", "sha256": "...", "walked_as": "babel.exclude"} +``` + +A manifest inside the walked tree is itself counted as covered (`walked_as` is its walked path; `null` when it lies outside). Babel exits 2, before it writes any output folder, with one `babel: --exclude FILE line N: ...` diagnostic per bad line, when an entry + +- has no reason; +- is a glob; +- matches nothing in the walked tree (a stale manifest); +- names an entry babel splits as source, including a hidden or symbolically linked `.c` file: source cannot be excluded, only translated or left open. + `tests/run.sh` checks all of this independently of babel: - `cmp` on the three outputs; - line counts against the vector count; - `python3 -m json.tool` on both JSON outputs; -- a **negative control**: a `cc` wrapper changes `fold`'s original C (`- k` to `+ k`) only when compiling the oracle. Babel must then report FAIL ("differs from the original C on 127 of 145 vectors") and exit 1. +- a **negative control**: a `cc` wrapper changes `fold`'s original C (`- k` to `+ k`) only when compiling the oracle. Babel must then report FAIL ("differs from the original C on 127 of 145 vectors") and exit 1; +- the completion gate: `examples/sample --complete` is PARTIAL and exits 3; `examples/complete --complete` is COMPLETE and exits 0 (c and rust); the same input plus one hidden file, or plus one symbolic link, is PARTIAL and exits 3 with that entry as the only open item; the `cc` wrapper under `--complete` is FAILED and exits 1; `ZIG=/nonexistent --to zig --complete` is BLOCKED and exits 4; +- the remaining completion gaps: a FIFO, or a mode-000 directory, is the only open item (PARTIAL, exit 3); a `PATH` without `cc` is BLOCKED (exit 4); a `cargo` that fails only `cargo test` is FAILED (exit 1) with the generated test as the only open item; +- the exclusion manifest: `examples/complete` plus `README.txt` is PARTIAL (exit 3) and COMPLETE (exit 0) with `README.txt` excluded, same denominator; an in-tree manifest plus an excluded `.gitignore` is COMPLETE; manifests naming `src/arith.c`, `src/`, a hidden `.c`, a symlinked `.c`, a stale path, a glob, or an entry without a reason each exit 2 without an output folder. ## Why Omega is the middle @@ -82,20 +137,22 @@ BABEL_ADAPTERS=$PWD/omega-mv build/babel examples/sample --to go BABEL_ADAPTERS=$PWD/omega-mv tests/run.sh # ZIG=/GO= if not on PATH ``` -Babel refuses to run unless the adapters' native omc has sha256 `734f0a39…6b61`. Re-running babel replaces `input/`, `omega/`, `diff/` and the folder for the chosen language. Folders for other languages are kept. Hidden entries, symlinks and `*.babel` folders are not walked, and REPORT.md says so. +Babel refuses to run unless the adapters' native omc has sha256 `734f0a39…6b61`. Re-running babel replaces `input/`, `omega/`, `diff/` and the folder for the chosen language. Folders for other languages are kept. Hidden entries, symlinks and `*.babel` folders are not walked; each is counted and listed as SKIPPED in the completion record. Exit codes: -| Code | Meaning | -|---|---| -| 0 | No FAIL | -| 1 | At least one FAIL, or the generated test failed | -| 2 | Usage or environment error | -| 64 | No `--to` and no terminal | +| Code | Without `--complete` | With `--complete` | +|---|---|---| +| 0 | No FAIL | COMPLETE | +| 1 | At least one FAIL, or the generated test failed | FAILED | +| 2 | Usage or environment error, or a rejected `--exclude` manifest | same | +| 3 | not used | PARTIAL | +| 4 | not used | BLOCKED | +| 64 | No `--to` and no terminal | same | ## Implementation -Babel itself is written in Omega (`src/*.om`, 5,241 lines). It walks files, hashes them, splits C top-level items, spawns the adapters and toolchains, generates the projects and drivers, compares outputs and writes the reports. +Babel itself is written in Omega (`src/*.om`, 6,469 lines). It walks files, hashes them, splits C top-level items, spawns the adapters and toolchains, generates the projects and drivers, compares outputs and writes the reports. The only shell is in `build.sh` and `tests/run.sh`, which coordinate the build and run independent checks. Host programs babel launches are listed in [DEPENDENCIES.md](DEPENDENCIES.md), each with its Omega replacement. diff --git a/examples/.crumb b/examples/.crumb index 6b893f6..ac53a54 100644 --- a/examples/.crumb +++ b/examples/.crumb @@ -3,17 +3,17 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-26T20:47:25Z", + "compiled_at": "2026-10-31T00:30:03Z", "compiler": "crumb-compile/1", - "digest": "sha256:af8fe5d090009428c3a7f7a6207bb8b53d6b2ee9ffd1c2c06e494d04f36fd119", + "digest": "sha256:82d819b4d960abb324717c6363e7b2960f1b11d13ebfb86b6ffbc536237931f4", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 4, - "generated_at_commit": "3d13ecfc624f47e081807c891bc650bf537ddbbe", - "source_tree": "sha256:dd0f59c5a685c75ae7d329a761aee675d5228fb48ae0fbc578d6c245c4d4fca9" + "files": 5, + "generated_at_commit": "133773074a9f418fdc6d8768b5cfcc6815d32fd0", + "source_tree": "sha256:e2405a98bccc1e4d12a2001f89daf57aee9178d3e9a9dee669fdea9e4e4785b6" } }, "name": "babel-examples", - "purpose": "sample input mixing S1 and unsupported code", + "purpose": "sample input mixing S1 and unsupported code; complete/ is an all-S1 input for the --complete gate", "schema_version": "1.0.0" } diff --git a/examples/complete/src/arith.c b/examples/complete/src/arith.c new file mode 100644 index 0000000..e3f1829 --- /dev/null +++ b/examples/complete/src/arith.c @@ -0,0 +1,13 @@ +#include <stdint.h> + +uint64_t blend(uint64_t a, uint64_t b) { + return a * b + a - b; +} + +uint64_t cube(uint64_t x) { + return x * x * x; +} + +uint64_t spread(uint64_t a, uint64_t b, uint64_t c) { + return a * b + b * c - c * a; +} diff --git a/src/.crumb b/src/.crumb index e31dc29..36dbe47 100644 --- a/src/.crumb +++ b/src/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-26T20:53:05Z", + "compiled_at": "2026-10-31T00:49:27Z", "compiler": "crumb-compile/1", - "digest": "sha256:a7d728a20559ca35eedad6b7de962b45a98668a39463eb7f6452dc47b4390238", + "digest": "sha256:6dc617e1e9e92e9a42205c850c72b3bf4506ccac9b9ef81eac14a5b7c47bace0", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 8, - "generated_at_commit": "12fcc43fdd5d0c0304a9f3bb7e6b876a55de0b1e", - "source_tree": "sha256:a07323fa4924ff0e8e3b4cc1f2522fd5b4a6013295f6e43ac137553c105911bd" + "files": 10, + "generated_at_commit": "45564f352035e039f19d2060c7254ed8f36085f9", + "source_tree": "sha256:df242e891092c16e63cc45d5c976aec9c46d4cc2b9de87c58f09dae32288a5ca" } }, "name": "babel-src", diff --git a/src/20-split.om b/src/20-split.om index 0d10d54..3093cb0 100644 --- a/src/20-split.om +++ b/src/20-split.om @@ -37,6 +37,10 @@ global Umo ulong 1024 global Umt ulong 1024 global Uno ulong 1024 global Nu ulong 1 +global Sk0 ulong 2048 +global Skl ulong 2048 +global Skr ulong 2048 +global Nsk ulong 1 note scanner state global Sx ulong 1 global Sln ulong 1 @@ -112,7 +116,8 @@ put Nf 0 add n 1 end note walk directory Ob[p0, p1) whose path relative to the input root is Ob[r0, r1) -note dot entries and *.babel output folders are skipped; depth is limited to 24 +note dot entries, symbolic links, other non-regular files and *.babel output folders are not walked; +note each one is recorded in the skip table (skipadd) so the completion record counts it; depth <= 24 fn walk p0 ulong p1 ulong r0 ulong r1 ulong depth ulong to void if gt depth 24 put Cap 0 1 @@ -122,6 +127,7 @@ m = mark e = dirrecs p0 p1 if eq e 0 reset m +skipadd r0 r1 5 ret end o = m @@ -132,15 +138,11 @@ reset m end fn walkent o ulong p0 ulong p1 ulong r0 ulong r1 ulong depth ulong to ulong -ty = get Ob o n = add o 1 k = n while ne get Ob k 0 bound 4096 k = add k 1 end -if eq get Ob n 46 -ret add k 1 -end c0 = mark bob p0 sub p1 p0 bc 47 @@ -152,17 +154,82 @@ bc 47 end bob n sub k n c2 = mark +if eq get Ob n 46 +skipadd c1 c2 1 +else +walkone c0 c1 c2 depth +end +reset c0 +ret add k 1 +end + +note one non-dot entry: full path Ob[c0, c1), relative path Ob[c1, c2) +fn walkone c0 ulong c1 ulong c2 ulong depth ulong to void t = ftype c0 c1 if eq t 2 -if not obteq sub c2 len ExBab len ExBab ExBab +if obteq sub c2 len ExBab len ExBab ExBab +skipadd c1 c2 4 +else walk c0 c1 c1 c2 add depth 1 end end if eq t 1 addfile c1 c2 end -reset c0 -ret add k 1 +if eq t 3 +if eq and get Sb 17 240 160 +skipadd c1 c2 2 +else +skipadd c1 c2 3 +end +end +if eq t 0 +skipadd c1 c2 6 +end +end + +note skip table: relative path Sk0/Skl (pool), reason Skr: 1 dot entry, 2 symbolic link, +note 3 other non-regular file, 4 *.babel folder, 5 unreadable directory, 6 lstat failed +fn skipadd r0 ulong r1 ulong why ulong to void +n = get Nsk 0 +if ge n 2048 +put Cap 0 1 +ret +end +put Sk0 n psave r0 sub r1 r0 +put Skl n sub r1 r0 +put Skr n why +put Nsk 0 add n 1 +end + +note skip table in path order, like the file table +fn sksort to void +n = get Nsk 0 +i = ulong 1 +while lt i n bound 4096 +j = i +while gt j 0 bound 4096 +a = sub j 1 +if not pllt get Sk0 j get Skl j get Sk0 a get Skl a +break +end +skswap j a +j = a +end +i = add i 1 +end +end + +fn skswap i ulong j ulong to void +t = get Sk0 i +put Sk0 i get Sk0 j +put Sk0 j t +t = get Skl i +put Skl i get Skl j +put Skl j t +t = get Skr i +put Skr i get Skr j +put Skr j t end note lexicographic order of files by relative path (insertion sort over the table) diff --git a/src/50-diff.om b/src/50-diff.om index cc37684..a7203ef 100644 --- a/src/50-diff.om +++ b/src/50-diff.om @@ -9,6 +9,9 @@ global Brc ulong 1 global Trc ulong 1 global Tsr ulong 1 global Ubd ulong 1024 +note leg results of unit u at Ulg[3u + k], k 0 original C, 1 Omega, 2 target: +note 0 not required (the unit never reached the differential), 1 PASS, 2 FAIL, 3 NOT_RUN +global Ulg ulong 3072 text TnCc "cc" text TnCargo "cargo" text TnPy "python3" @@ -187,16 +190,12 @@ if eq get Tok 3 0 tfind 3 TnCpp2 end if getenv EvZig -put Tok 4 1 -put Tl0 4 get Gv0 0 -put Tln 4 get Gvn 0 +tenv 4 else tfind 4 TnZig end if getenv EvGo -put Tok 5 1 -put Tl0 5 get Gv0 0 -put Tln 5 get Gvn 0 +tenv 5 else tfind 5 TnGo end @@ -207,6 +206,20 @@ end end end +note tool slot s from an environment override (Gv0/Gvn): found only when the path is executable +fn tenv s ulong to void +m = mark +bpl get Gv0 0 get Gvn 0 +r = faccess Ob m sub mark m 1 +reset m +if ne r 0 +ret +end +put Tok s 1 +put Tl0 s get Gv0 0 +put Tln s get Gvn 0 +end + note first line of "<tool> --version" (zig/go: "version") into Tv0/Tvn fn tver s ulong to void m = mark @@ -729,6 +742,10 @@ bu rc ureasob u m end +fn legset u ulong k ulong v ulong to void +put Ulg add mul u 3 k v +end + note one exported unit through all three legs fn diffunit u ulong to void progress u @@ -739,12 +756,15 @@ ret end r = leg1 u if ne r 0 +legset u 0 2 setst u 4 8 r whyrcn u RsOrc RsOrc2 r ret end +legset u 0 1 r = leg2 u if ne r 0 +legset u 1 2 setst u 4 7 r whyrcn u RsOmd RsOmd2 r ret @@ -752,10 +772,12 @@ end k = mism u POut2 put Umo u k if gt k 0 +legset u 1 2 setst u 4 7 0 whymis u RsMo k ret end +legset u 1 1 legt u end @@ -767,12 +789,14 @@ ret end b = get Brc 0 if ne b 0 +legset u 2 2 setst u 4 6 b whyrc u RsTbd b ret end b = get Ubd u if ne b 0 +legset u 2 2 setst u 4 6 b whyrcn u RsTbdU RsTbdU2 b ret @@ -782,6 +806,7 @@ kenv ktarget u r = runvec u POut3 if ne r 0 +legset u 2 2 setst u 4 7 r whyrcn u RsTrn RsTrn2 r ret @@ -789,10 +814,12 @@ end k = mism u POut3 put Umt u k if gt k 0 +legset u 2 2 setst u 4 7 0 whymis u RsMt k ret end +legset u 2 1 setst u 1 7 0 end @@ -845,6 +872,9 @@ for u ulong get Nu 0 if not exported u continue end +legset u 0 3 +legset u 1 3 +legset u 2 3 if eq get Tok 0 0 setst u 5 8 0 ureason u RsNoCc diff --git a/src/60-report.om b/src/60-report.om index 9f060a7..9d09978 100644 --- a/src/60-report.om +++ b/src/60-report.om @@ -378,6 +378,7 @@ scount 4 TSum4 scount 5 TSum5 scount 6 TSum6 tstline +csline bs TRep bout bs TRepF @@ -525,7 +526,8 @@ text JH ", \"native_omc_sha256\": \"" text JI "\"},\n \"verdict_rule\": \"TRANSLATED = adapter exit 0, Omega check exit 0, and original C / Omega / target outputs byte-identical on every vector\",\n \"toolchains\": {" text JJ "},\n \"summary\": {" text JK "},\n \"generated_tests\": \"" -text JL "\",\n \"files\": [" +text JL "\",\n \"completion\": " +text JL2 ",\n \"files\": [" text JM "\n ],\n \"units\": [" text JN "\n ]\n}\n" text JQ "\": " @@ -654,6 +656,8 @@ bu get Cnt 6 bs JK btsr bs JL +cjson +bs JL2 end fn jfile f ulong to void @@ -748,7 +752,7 @@ text MNo "not found" text MK "\n## Result\n\n" text ML "\n\n**Verdicts.** TRANSLATED: the adapters exited 0, the lowered unit passed the pinned omc, and the original C function, the Omega unit and the generated target printed byte-identical results on every test vector. UNSUPPORTED(rc): an adapter refused the unit with exit code rc; the first line of its stderr is the detail. MISSING_IMPLEMENTATION: no adapter exists for this construct, file or language yet. FAIL: a tool broke or two legs disagreed. NOT_RUN: a required tool was missing, so no verdict was reached. ABSORBED: the `#include <stdint.h>` line, which babel supplies to every unit.\n\n**Renames.** The S1 adapters accept only the function names `calc` or `omega_*`. babel hands every other function to them as `omega_<name>` and packages the result under the original name; the adapter name of each unit is listed in report.json (`adapter_name`).\n\n**Vectors.** Every unit runs on the 9 boundary values {0, 1, 2, 2^32-1, 2^32, 2^63-1, 2^63, 2^64-2, 2^64-1} (all combinations up to 3 inputs, 81 rows above that) plus 64 splitmix64 vectors from seed 20261026. The inputs and all three outputs are kept under `diff/<name>/`.\n\n## Units\n\n| verdict | unit | where | kind | stage | detail |\n|---|---|---|---|---|---|\n" text MM "\n## Input files\n\n`input/` is a byte copy of these files; each sha256 below was computed while copying.\n\n| file | language | bytes | sha256 |\n|---|---|---|---|\n" -text MN "\n## Not walked\n\nDot entries (`.git`, `.cache`, ...), symbolic links, other non-regular files and `*.babel` folders are neither copied nor translated.\n" +text MN "\n## Not walked\n\nDot entries (`.git`, `.cache`, ...), symbolic links, other non-regular files, `*.babel` folders and unreadable directories are neither copied nor translated. Each one is counted in the completion record below and listed there as SKIPPED.\n" fn mtool s ulong nm view uchar * to void bs MTl @@ -850,6 +854,7 @@ for f ulong get Nf 0 mdfile f end bs MN +cmdsec end note ---------- omega/manifest.json ---------- diff --git a/src/65-exclude.om b/src/65-exclude.om new file mode 100644 index 0000000..37d182b --- /dev/null +++ b/src/65-exclude.om @@ -0,0 +1,365 @@ +note babel 75-exclude: the --exclude manifest. One "<path> <reason>" per line; blank lines and lines +note starting with # are ignored. <path> is relative to the walked root and is an exact path or a +note directory prefix (a trailing / is optional); globs are refused. A matched walked file or skipped +note entry stays in the completion denominator with verdict EXCLUDED and the manifest's reason. +note Source babel recognises (and so every split item) can never be excluded, hidden or symlinked or +note not. A line without a reason, an entry that matches nothing, a glob or an entry that names source +note is diagnosed with its line number, and babel exits 2 before writing anything. +global Ex0 ulong 1 +global Exn ulong 1 +global Exa0 ulong 1 +global Exan ulong 1 +global Exr0 ulong 1 +global Exrn ulong 1 +global Exh uchar 32 +note entries: path Me0/Men, reason Mr0/Mrn (pool), manifest line Mln, matches Mht +global Me0 ulong 256 +global Men ulong 256 +global Mr0 ulong 256 +global Mrn ulong 256 +global Mln ulong 256 +global Mht ulong 256 +global Nme ulong 1 +note per walked file / skipped entry: matching entry + 1 (0 none) +global Fex ulong 2048 +global Skx ulong 2048 +note the manifest itself when it lies in the walked tree: file index + 1, skipped index + 1 +global Mfi ulong 1 +global Msk ulong 1 +global Nexe ulong 1 +text EMh "babel: --exclude " +text EMl " line " +text EMc ": " +text EMa " -> " +text EMrd "cannot be read" +text EMcp "has more than 256 entries" +text EMnr "entry has no reason (each line is <path> <reason>): " +text EMgl "globs are not supported (an exact path or a dir/ prefix): " +text EMst "entry matches nothing in the walked tree (stale manifest): " +text EMsr "entry names source babel splits, which cannot be excluded: " + +note --exclude given: read, hash, parse and match the manifest against the walk of root Pl[d, d+dn); +note false after reporting every problem +fn exload d ulong dn ulong to bool +put Nexe 0 0 +if eq get Exn 0 0 +ret true +end +m = mark +absob get Ex0 0 get Exn 0 +put Exa0 0 psave m sub mark m +put Exan 0 sub mark m +e = mark +r = hfile m e +if ge r 0 +for i ulong 32 +put Exh i get Hash i +end +r = rfile m e +end +reset m +if lt r 0 +exdiag 0 EMrd 0 0 +ret false +end +exrel d dn +if not exparse +exdiag 0 EMcp 0 0 +ret false +end +exmatch +ret eq get Nexe 0 0 +end + +note the manifest's path relative to the walked root Pl[d, d+dn), when it lies inside it (else Exrn 0) +fn exrel d ulong dn ulong to void +put Exrn 0 0 +a = get Exa0 0 +an = get Exan 0 +if le an add dn 1 +ret +end +if not pleq a dn d dn +ret +end +if ne get Pl add a dn 47 +ret +end +put Exr0 0 add a add dn 1 +put Exrn 0 sub an add dn 1 +end + +note split Fb[0, Fn) into lines; false when the entry table is full +fn exparse to bool +put Nme 0 0 +n = get Fn 0 +s = ulong 0 +lno = ulong 1 +while lt s n bound 999999 +k = s +while lt k n bound 999999 +if eq get Fb k 10 +break +end +k = add k 1 +end +if not exline s k lno +ret false +end +s = add k 1 +lno = add lno 1 +end +ret true +end + +fn exws c uchar to bool +if eq c 32 +ret true +end +if eq c 9 +ret true +end +ret eq c 13 +end + +note one line Fb[a, b): trimmed, comment or blank skipped, else <path> and <reason> recorded +fn exline a ulong b ulong lno ulong to bool +s = a +while lt s b bound 999999 +if not exws get Fb s +break +end +s = add s 1 +end +e = b +while gt e s bound 999999 +if not exws get Fb sub e 1 +break +end +e = sub e 1 +end +if ge s e +ret true +end +if eq get Fb s 35 +ret true +end +p = s +while lt p e bound 999999 +if exws get Fb p +break +end +p = add p 1 +end +q = p +while lt q e bound 999999 +if not exws get Fb q +break +end +q = add q 1 +end +ret exadd s p q e lno +end + +note record entry path Fb[s, p) ("./" prefix and trailing "/" removed) and reason Fb[q, e) +fn exadd s ulong p ulong q ulong e ulong lno ulong to bool +i = get Nme 0 +if ge i 256 +ret false +end +a = s +if gt sub p a 2 +if eq get Fb a 46 +if eq get Fb add a 1 47 +a = add a 2 +end +end +end +z = p +while gt sub z a 1 bound 4096 +if ne get Fb sub z 1 47 +break +end +z = sub z 1 +end +m = mark +bfb a sub z a +put Me0 i psave m sub mark m +put Men i sub mark m +reset m +bfb q sub e q +put Mr0 i psave m sub mark m +put Mrn i sub mark m +reset m +put Mln i lno +put Mht i 0 +put Nme 0 add i 1 +ret true +end + +note match every entry against the walked files and the skipped entries +fn exmatch to void +put Mfi 0 0 +put Msk 0 0 +for f ulong get Nf 0 +put Fex f 0 +if gt get Exrn 0 0 +if pleq get F0 f get Fl f get Exr0 0 get Exrn 0 +put Mfi 0 add f 1 +end +end +end +for i ulong get Nsk 0 +put Skx i 0 +if gt get Exrn 0 0 +if pleq get Sk0 i get Skl i get Exr0 0 get Exrn 0 +put Msk 0 add i 1 +end +end +end +for e ulong get Nme 0 +exent e +end +end + +fn exent e ulong to void +if eq get Mrn e 0 +exdiag add e 1 EMnr 0 0 +ret +end +if exglob e +exdiag add e 1 EMgl 0 0 +ret +end +for f ulong get Nf 0 +if exhit e get F0 f get Fl f +exfile e f +end +end +for i ulong get Nsk 0 +if exhit e get Sk0 i get Skl i +exsk e i +end +end +if eq get Mht e 0 +exdiag add e 1 EMst 0 0 +end +end + +note entry e covers walked file f, unless f is source (diagnosed) or the manifest itself +fn exfile e ulong f ulong to void +put Mht e add get Mht e 1 +if ne get Flg f 0 +exdiag add e 1 EMsr get F0 f get Fl f +ret +end +if eq get Mfi 0 add f 1 +ret +end +if eq get Fex f 0 +put Fex f add e 1 +end +end + +note entry e covers skipped entry i, unless its name is source (hidden or symlinked source) +fn exsk e ulong i ulong to void +put Mht e add get Mht e 1 +if ne langof get Sk0 i get Skl i 0 +exdiag add e 1 EMsr get Sk0 i get Skl i +ret +end +if eq get Msk 0 add i 1 +ret +end +if eq get Skx i 0 +put Skx i add e 1 +end +end + +note path Pl[o, o+n) is the entry or lies below it +fn exhit e ulong o ulong n ulong to bool +a = get Me0 e +k = get Men e +if eq k 0 +ret false +end +if pleq o n a k +ret true +end +if le n k +ret false +end +if not pleq o k a k +ret false +end +ret eq get Pl add o k 47 +end + +fn exglob e ulong to bool +a = get Me0 e +for i ulong get Men e +c = get Pl add a i +if eq c 42 +ret true +end +if eq c 63 +ret true +end +if eq c 91 +ret true +end +end +ret false +end + +note "babel: --exclude FILE[ line N]: <msg>[<entry>][ -> <path>]" on stderr; ln1 = entry index + 1 (0: whole file) +fn exdiag ln1 ulong s view uchar * o ulong n ulong to void +m = mark +bs EMh +bpl get Ex0 0 get Exn 0 +if gt ln1 0 +bs EMl +bu get Mln sub ln1 1 +end +bs EMc +bs s +if gt ln1 0 +e = sub ln1 1 +bpl get Me0 e get Men e +end +if gt n 0 +bs EMa +bpl o n +end +bc 10 +flush 2 m +put Nexe 0 add get Nexe 0 1 +end + +note first k bytes of the manifest's sha256 in hex +fn exhex k ulong to void +for i ulong k +c = get Exh i +bhex ulong shr c 4 +bhex ulong and c 15 +end +end + +text CxA "{\"path\": " +text CxB ", \"sha256\": \"" +text CxC "\", \"walked_as\": " +text CxN "null" + +fn exjson to void +if eq get Exn 0 0 +bs CxN +ret +end +bs CxA +bjq get Ex0 0 get Exn 0 +bs CxB +exhex 32 +bs CxC +bqnull get Exr0 0 get Exrn 0 +bc 125 +end diff --git a/src/70-complete.om b/src/70-complete.om new file mode 100644 index 0000000..65d9aab --- /dev/null +++ b/src/70-complete.om @@ -0,0 +1,715 @@ +note babel 70-complete: the completion record (policy complete-v1). Its denominator is every walked file, +note every split item, every entry the walk skipped and every required check (three differential legs per +note unit that reached the differential, the generated target test where the target has one, and each +note toolchain the target needs). --complete turns its state into the exit status. +note State codes in Csv: 1 COMPLETE, 2 PARTIAL, 3 BLOCKED, 4 FAILED (the highest open severity wins). +global Cpl ulong 1 +global Cmd ulong 1 +global Cden ulong 1 +global Ccov ulong 1 +global Csv ulong 1 +global Cno ulong 1 +global Ccap ulong 1 +note staged strings of one open item: 0 kind, 1 item, 2 name, 3 verdict, 4 reason (pool offset, length) +global Xo ulong 5 +global Xn ulong 5 +global Cexc ulong 1 +global Xe ulong 1 +text CvExc "EXCLUDED" +text CpPol "complete-v1" +text CpS1 "COMPLETE" +text CpS2 "PARTIAL" +text CpS3 "BLOCKED" +text CpS4 "FAILED" +text CkFile "file" +text CkSkip "skipped" +text CkUnit "unit" +text CkCheck "check" +text CkTool "toolchain" +text CvSkip "SKIPPED" +text CiDot "." +text CiTst "diff/test.log" +text CiCap "babel capacity" +text CrOth "not a source language babel recognises (.c .h .rs .py .go .zig .cpp .cc .cxx .hpp): copied to input/ only, nothing translated" +text CrEmp "no files were walked: there is nothing to translate" +text CrSk1 "hidden (dot) entry: not walked, not copied, not translated" +text CrSk2 "symbolic link: not followed, not copied, not translated" +text CrSk3 "not a regular file or directory: not copied, not translated" +text CrSk4 "*.babel output folder: not walked" +text CrSk5 "directory could not be read: its entries were not walked" +text CrSk6 "could not be inspected (lstat failed): not walked" +text CrL0 "differential leg: original C (cc oracle)" +text CrL1 "differential leg: Omega unit (pinned omc)" +text CrL2 "differential leg: target " +text CrLf " failed" +text CrLn " did not run" +text CrSep ": " +text CrTf "generated target test failed (see diff/test.log), exit " +text CrTn "generated target test did not run (its toolchain is missing)" +text CrTl " was not found (on PATH, or at the ZIG or GO path given): every check that needs it is NOT_RUN" +text CrCap "an internal capacity was exceeded (2048 files or skipped entries, 1024 units, 8 MiB pool): items may be missing from this record" + +note ---------- the walk over every item ---------- +note mode md: 0 count (Cden, Ccov, Cexc, Csv), 1 report.json open list, 2 REPORT.md open rows, +note 3 report.json excluded list, 4 REPORT.md excluded rows +fn cwalk md ulong to void +put Cmd 0 md +put Cno 0 0 +if eq md 0 +put Cden 0 0 +put Ccov 0 0 +put Cexc 0 0 +put Csv 0 1 +put Ccap 0 get Cap 0 +end +if eq get Nf 0 0 +cempty +end +for f ulong get Nf 0 +cfile f +end +for i ulong get Nsk 0 +cskip i +end +for u ulong get Nu 0 +cunit u +end +for u ulong get Nu 0 +for k ulong 3 +cleg u k +end +end +ctest +ctool 0 +s = tslot +if ne s 0 +ctool s +end +if eq get Ccap 0 1 +ccap +end +end + +note one item with severity sv (0 covered, 1 EXCLUDED, 2 PARTIAL, 3 BLOCKED, 4 FAILED); true when it is to be printed +fn cbump sv ulong to bool +md = get Cmd 0 +if eq md 0 +put Cden 0 add get Cden 0 1 +if eq sv 0 +put Ccov 0 add get Ccov 0 1 +end +if eq sv 1 +put Cexc 0 add get Cexc 0 1 +end +if gt sv get Csv 0 +put Csv 0 sv +end +ret false +end +if gt md 2 +ret eq sv 1 +end +ret gt sv 1 +end + +note an EXCLUDED item: kind, item Pl[o, o+n) ("." when empty), manifest entry e1 - 1 +fn cexcl kd view uchar * o ulong n ulong e1 ulong to void +m = mark +bs kd +xput 0 m +if eq n 0 +bs CiDot +else +bpl o n +end +xput 1 m +put Xe 0 sub e1 1 +cemit +end + +note Ob[m, mark) into staged string k (empty: null in JSON, "-" in Markdown) +fn xput k ulong m ulong to void +put Xn k sub mark m +put Xo k psave m sub mark m +reset m +end + +fn cempty to void +if not cbump 2 +ret +end +m = mark +bs CkFile +xput 0 m +bs CiDot +xput 1 m +xput 2 m +bs VMi +xput 3 m +bs CrEmp +xput 4 m +cemit +end + +note a walked file is covered when its language is one babel recognises (its content is counted by its +note units) or when it is the --exclude manifest; EXCLUDED when a manifest entry matched it +fn cfile f ulong to void +sv = ulong 0 +if eq get Flg f 0 +sv = ulong 2 +if eq get Mfi 0 add f 1 +sv = ulong 0 +end +if ne get Fex f 0 +sv = ulong 1 +end +end +if not cbump sv +ret +end +if eq sv 1 +cexcl CkFile get F0 f get Fl f get Fex f +ret +end +m = mark +bs CkFile +xput 0 m +bpl get F0 f get Fl f +xput 1 m +xput 2 m +bs VMi +xput 3 m +bs CrOth +xput 4 m +cemit +end + +fn cskip i ulong to void +sv = ulong 2 +if eq get Msk 0 add i 1 +sv = ulong 0 +end +if ne get Skx i 0 +sv = ulong 1 +end +if not cbump sv +ret +end +if eq sv 1 +cexcl CkSkip get Sk0 i get Skl i get Skx i +ret +end +m = mark +bs CkSkip +xput 0 m +if eq get Skl i 0 +bs CiDot +else +bpl get Sk0 i get Skl i +end +xput 1 m +xput 2 m +bs CvSkip +xput 3 m +bskip get Skr i +xput 4 m +cemit +end + +fn bskip r ulong to void +if eq r 1 +bs CrSk1 +ret +end +if eq r 2 +bs CrSk2 +ret +end +if eq r 3 +bs CrSk3 +ret +end +if eq r 4 +bs CrSk4 +ret +end +if eq r 5 +bs CrSk5 +ret +end +bs CrSk6 +end + +note a split item is covered when TRANSLATED or ABSORBED +fn cunit u ulong to void +s = get Ust u +sv = ulong 3 +if eq s 1 +sv = ulong 0 +end +if eq s 6 +sv = ulong 0 +end +if eq s 2 +sv = ulong 2 +end +if eq s 3 +sv = ulong 2 +end +if eq s 4 +sv = ulong 4 +end +if not cbump sv +ret +end +m = mark +bs CkUnit +xput 0 m +bloc u +xput 1 m +bname u +xput 2 m +bverdict u +xput 3 m +bpl get Ur0 u get Urn u +xput 4 m +cemit +end + +note differential leg k of unit u, required once the unit reached the differential +fn cleg u ulong k ulong to void +v = get Ulg add mul u 3 k +if eq v 0 +ret +end +sv = ulong 0 +if eq v 2 +sv = ulong 4 +end +if eq v 3 +sv = ulong 3 +end +if not cbump sv +ret +end +m = mark +bs CkCheck +xput 0 m +bloc u +xput 1 m +bname u +xput 2 m +if eq v 2 +bs VFa +else +bs VNr +end +xput 3 m +if eq k 0 +bs CrL0 +end +if eq k 1 +bs CrL1 +end +if eq k 2 +bs CrL2 +blang get Lg 0 +end +if eq v 2 +bs CrLf +else +bs CrLn +end +if gt get Urn u 0 +bs CrSep +bpl get Ur0 u get Urn u +end +xput 4 m +cemit +end + +note the generated target test: required for rust and python once any oracle output exists +fn ctest to void +g = get Lg 0 +if lt g 2 +ret +end +if gt g 3 +ret +end +if not anycase +ret +end +t = get Tsr 0 +sv = ulong 0 +if ne t 0 +sv = ulong 4 +if eq t 999 +sv = ulong 3 +end +end +if not cbump sv +ret +end +m = mark +bs CkCheck +xput 0 m +bs CiTst +xput 1 m +xput 2 m +if eq sv 4 +bs VFa +xput 3 m +bs CrTf +bu t +else +bs VNr +xput 3 m +bs CrTn +end +xput 4 m +cemit +end + +note toolchain slot s: required (cc for the oracle, plus the target's own tool) +fn ctool s ulong to void +sv = ulong 0 +if eq get Tok s 0 +sv = ulong 3 +end +if not cbump sv +ret +end +m = mark +bs CkTool +xput 0 m +btool s +xput 1 m +xput 2 m +bs VNr +xput 3 m +btool s +bs CrTl +xput 4 m +cemit +end + +fn btool s ulong to void +if eq s 0 +bs TlNm0 +ret +end +if eq s 1 +bs TlNm1 +ret +end +if eq s 2 +bs TlNm2 +ret +end +if eq s 3 +bs TlNm3 +ret +end +if eq s 4 +bs TlNm4 +ret +end +bs TlNm5 +end + +fn ccap to void +if not cbump 3 +ret +end +m = mark +bs CkCheck +xput 0 m +bs CiCap +xput 1 m +xput 2 m +bs VNr +xput 3 m +bs CrCap +xput 4 m +cemit +end + +note ---------- output of one open item ---------- +text CjA "\n {\"kind\": \"" +text CjB "\", \"item\": " +text CjC ", \"name\": " +text CjD ", \"verdict\": \"" +text CjE "\", \"reason\": " +text CjF "}" + +fn cemit to void +md = get Cmd 0 +if eq md 1 +cemitj +ret +end +if eq md 3 +cemitx +ret +end +if eq md 4 +cemitxm +ret +end +cemitm +end + +text CxV ", \"verdict\": \"EXCLUDED\", \"reason\": " +text CxM ", \"matched_by\": " +text CxL ", \"line\": " + +note report.json excluded item: kind, item, verdict, the manifest's reason, entry and line +fn cemitx to void +if gt get Cno 0 0 +bc 44 +end +put Cno 0 add get Cno 0 1 +e = get Xe 0 +bs CjA +bpl get Xo 0 get Xn 0 +bs CjB +bjq get Xo 1 get Xn 1 +bs CxV +bjq get Mr0 e get Mrn e +bs CxM +bjq get Me0 e get Men e +bs CxL +bu get Mln e +bs CjF +end + +text CxLn " (line " + +note REPORT.md excluded row: | kind | item | EXCLUDED | entry (line N) | reason | +fn cemitxm to void +e = get Xe 0 +bs MTl +bpl get Xo 0 get Xn 0 +bs MTm +bc 96 +bmd get Xo 1 get Xn 1 +bc 96 +bs MTm +bs CvExc +bs MTm +bc 96 +bmd get Me0 e get Men e +bc 96 +bs CxLn +bu get Mln e +bc 41 +bs MTm +bmd get Mr0 e get Mrn e +bs MTn +end + +fn cemitj to void +if gt get Cno 0 0 +bc 44 +end +put Cno 0 add get Cno 0 1 +bs CjA +bpl get Xo 0 get Xn 0 +bs CjB +bjq get Xo 1 get Xn 1 +bs CjC +bqnull get Xo 2 get Xn 2 +bs CjD +bpl get Xo 3 get Xn 3 +bs CjE +bqnull get Xo 4 get Xn 4 +bs CjF +end + +fn cemitm to void +bs MTl +bpl get Xo 0 get Xn 0 +bs MTm +bc 96 +bmd get Xo 1 get Xn 1 +bc 96 +bs MTm +if eq get Xn 2 0 +bc 45 +else +bmd get Xo 2 get Xn 2 +end +bs MTm +bpl get Xo 3 get Xn 3 +bs MTm +bmd get Xo 4 get Xn 4 +bs MTn +end + +note ---------- state, exit status and the three renderings ---------- +fn bstate to void +s = get Csv 0 +if eq s 1 +bs CpS1 +ret +end +if eq s 2 +bs CpS2 +ret +end +if eq s 3 +bs CpS3 +ret +end +bs CpS4 +end + +note --complete: 0 COMPLETE, 1 FAILED, 3 PARTIAL, 4 BLOCKED +fn cexit to ulong +s = get Csv 0 +if eq s 1 +ret 0 +end +if eq s 2 +ret 3 +end +if eq s 3 +ret 4 +end +ret 1 +end + +text CjH "{\"policy\": \"" +text CjI "\", \"enforced\": " +text CjT "true" +text CjFl "false" +text CjJ ", \"state\": \"" +text CjK "\", \"denominator\": " +text CjL ", \"covered\": " +text CjM ", \"open\": [" +text CjN "\n ]" +text CjO "]" +text CjP ", \"excluded_count\": " +text CjQ ", \"excluded\": [" +text CjR ", \"manifest\": " + +fn cjson to void +bs CjH +bs CpPol +bs CjI +if eq get Cpl 0 1 +bs CjT +else +bs CjFl +end +bs CjJ +bstate +bs CjK +bu get Cden 0 +bs CjL +bu get Ccov 0 +bs CjM +cwalk 1 +if gt get Cno 0 0 +bs CjN +else +bs CjO +end +bs CjP +bu get Cexc 0 +bs CjQ +cwalk 3 +if gt get Cno 0 0 +bs CjN +else +bs CjO +end +bs CjR +exjson +bc 125 +end + +text CmA "\n## Completion\n\nPolicy `complete-v1`" +text CmB " (enforced: --complete was given, so the exit status follows this state)" +text CmC " (not enforced: with --complete the exit status follows this state)" +text CmD ". State: **" +text CmE "**, " +text CmF " of " +text CmG " items covered" +text CmE2 ", " +text CmGx " excluded by manifest `" +text CmGs "` (sha256 " +text CmGe ")" +text CmG2 ".\n\nThe denominator counts every walked file, every split item, every entry the walk skipped (hidden entries, symbolic links, other non-regular files, `*.babel` folders, unreadable directories) and every required check: the three differential legs of each unit that reached the differential, the generated target test where the target has one (rust, python), and each toolchain the target needs. An entry matched by the --exclude manifest stays in the denominator as EXCLUDED with the manifest's reason; source files and their split items cannot be excluded. COMPLETE: every item TRANSLATED, ABSORBED or EXCLUDED, nothing else skipped, every check ran and passed. FAILED: any FAIL. BLOCKED: no FAIL, but a required check did not run or a toolchain is missing. PARTIAL: no FAIL and no NOT_RUN, but UNSUPPORTED, MISSING_IMPLEMENTATION or skipped items remain.\n" +text CmX "\nExcluded by the manifest:\n\n| kind | item | verdict | manifest entry | reason |\n|---|---|---|---|---|\n" +text CmH "\n| kind | item | name | verdict | reason |\n|---|---|---|---|---|\n" +text CmI "\nNo open items.\n" + +fn cmdsec to void +bs CmA +if eq get Cpl 0 1 +bs CmB +else +bs CmC +end +bs CmD +bstate +bs CmE +bu get Ccov 0 +bs CmF +bu get Cden 0 +bs CmG +if gt get Exn 0 0 +bs CmE2 +bu get Cexc 0 +bs CmGx +bmd get Ex0 0 get Exn 0 +bs CmGs +exhex 32 +bs CmGe +end +bs CmG2 +if eq add get Ccov 0 get Cexc 0 get Cden 0 +bs CmI +else +bs CmH +cwalk 2 +end +if gt get Cexc 0 0 +bs CmX +cwalk 4 +end +end + +text CsA " completion " +text CsB " items covered (policy complete-v1" +text CsC ", enforced by --complete)\n" +text CsD "; --complete makes it the exit status)\n" +text CsE " items covered, " +text CsF " excluded by manifest " +text CsG " (policy complete-v1" + +fn csline to void +bs CsA +bstate +bc 32 +bc 32 +bu get Ccov 0 +bs CmF +bu get Cden 0 +if gt get Exn 0 0 +bs CsE +bu get Cexc 0 +bs CsF +exhex 4 +bs CsG +else +bs CsB +end +if eq get Cpl 0 1 +bs CsC +else +bs CsD +end +end diff --git a/src/90-main.om b/src/90-main.om index f43a39f..29e1641 100644 --- a/src/90-main.om +++ b/src/90-main.om @@ -5,14 +5,17 @@ global Psn ulong 1 global Rd0 ulong 1 global Rdn ulong 1 global Ln uchar 64 -text Usage "usage: babel <path> [--to rust|c|python|cpp|zig|go] [--json] [--no-color] [--adapters DIR]\n\nTranslate the C functions under <path> through Omega into the target language. The result goes\nnext to <path>, in <path>.babel/: input/ (a hashed copy), omega/ (the Omega units), <target>/\n(the generated project), diff/ (the differential test) and REPORT.md + report.json.\n\nOnly profile S1 is implemented (pure functions of 0-6 uint64_t inputs using + - * modulo 2^64).\nEverything else is reported, with the reason and location, and is never approximated.\n\n --to LANG target: rust, c, python, cpp, zig or go (asked interactively when omitted on a terminal)\n --json print report.json on stdout instead of the summary table\n --no-color no ANSI colour (also when NO_COLOR is set or stdout is not a terminal)\n --adapters DIR omega-mv checkout with built adapters (default: $BABEL_ADAPTERS)\n --version print the version and pins\n\nexit status: 0 no FAIL, 1 at least one FAIL, 2 usage or environment error, 64 no target and no terminal\n" +text Usage "usage: babel <path> [--to rust|c|python|cpp|zig|go] [--json] [--no-color] [--complete] [--exclude FILE] [--adapters DIR]\n\nTranslate the C functions under <path> through Omega into the target language. The result goes\nnext to <path>, in <path>.babel/: input/ (a hashed copy), omega/ (the Omega units), <target>/\n(the generated project), diff/ (the differential test) and REPORT.md + report.json.\n\nOnly profile S1 is implemented (pure functions of 0-6 uint64_t inputs using + - * modulo 2^64).\nEverything else is reported, with the reason and location, and is never approximated.\n\n --to LANG target: rust, c, python, cpp, zig or go (asked interactively when omitted on a terminal)\n --json print report.json on stdout instead of the summary table\n --no-color no ANSI colour (also when NO_COLOR is set or stdout is not a terminal)\n --complete strict completion policy complete-v1: exit 0 only when every walked file, split item,\n skipped entry and required check is covered or excluded (state COMPLETE)\n --exclude FILE exclusion manifest: one \"<path> <reason>\" per line, path relative to <path>, an exact\n path or a dir/ prefix (no globs); blank and # lines ignored. An excluded entry stays in\n the denominator as EXCLUDED. Source files and their split items cannot be excluded.\n A line without a reason, an entry that matches nothing or one that names source exits 2.\n --adapters DIR omega-mv checkout with built adapters (default: $BABEL_ADAPTERS)\n --version print the version and pins\n\nexit status: 0 no FAIL, 1 at least one FAIL, 2 usage, environment or exclusion-manifest error,\n64 no target and no terminal\nwith --complete: 0 COMPLETE, 1 FAILED, 3 PARTIAL, 4 BLOCKED (2 and 64 as above)\n" text VerL "babel 0.1.0\nbuilt with omega-mv seed/out/omc OM-2 (main 0b77e6ea2, sha256 2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f)\nadapters: aien-dev/omega-mv universal/624-g1-integration 2d4c6407, profile S1 c17-uint64-pure-v1\nadapter omc sha256 734f0a39319fbfa930bcc62cb30dbf06d47d78e126372b74f5baf478e6126b61\n" text OTo "--to" text OToE "--to=" text OJson "--json" text ONoc "--no-color" +text OCpl "--complete" text OAd "--adapters" text OAdE "--adapters=" +text OExc "--exclude" +text OExcE "--exclude=" text OHelp "--help" text OShort "-h" text OVer "--version" @@ -26,6 +29,7 @@ text EBadL "babel: unknown target language: " text ETwo "babel: more than one <path> given\n" text ENoP "babel: no <path> given (see babel --help)\n" text ENoA "babel: no adapters: pass --adapters DIR or set BABEL_ADAPTERS to an omega-mv checkout whose adapters were built (tools/adapters/build-g3.py, see README)\n" +text ENoEx "babel: --exclude needs a manifest FILE\n" text ENoIn "babel: input not found or not a regular file or directory: " text EPin1 "babel: the adapters' native omc at " text EPin2 " does not have the pinned sha256 734f0a39...6b61 (rebuild the adapters at the pinned revision; see README)\n" @@ -175,12 +179,19 @@ if argeq i ONoc put Nocol 0 1 ret 0 end +if argeq i OCpl +put Cpl 0 1 +ret 0 +end if argeq i OTo ret argto add i 1 end if argeq i OAd ret argad add i 1 end +if argeq i OExc +ret argex add i 1 +end ok = argpl i if not ok eputs EUnk @@ -202,6 +213,11 @@ put Ad0 0 add o len OAdE put Adn 0 sub n len OAdE ret 0 end +if plpre o n OExcE +put Ex0 0 add o len OExcE +put Exn 0 sub n len OExcE +ret 0 +end if gt n 0 if eq get Pl o 45 eputs EUnk @@ -246,6 +262,17 @@ put Adn 0 get Psn 0 ret 1000 end +fn argex i ulong to ulong +if ge i ulong argcnt +eputs ENoEx +ret 3 +end +ok = argpl i +put Ex0 0 get Ps0 0 +put Exn 0 get Psn 0 +ret 1000 +end + note a terminal: character device (st_mode byte 17) whose st_rdev major (bytes 32..33, note bits 8..19) is 4 (tty), 5 (/dev/tty, ptmx) or 136..143 (pts); /dev/null (major 1) is not fn istty fd int to bool @@ -323,12 +350,25 @@ end note absolute input path (cwd joined, "./" and trailing "/" removed) back into Rt0/Rtn fn absin to void -o = get Rt0 0 -n = get Rtn 0 m = mark +absob get Rt0 0 get Rtn 0 +while gt sub mark m 1 bound 4096 +if ne get Ob sub mark 1 47 +break +end +put Ol 0 sub mark 1 +end +put Rt0 0 psave m sub mark m +put Rtn 0 sub mark m +reset m +end + +note append the absolute form of the path Pl[o, o+n) to Ob: cwd joined, leading "./" removed +fn absob o ulong n ulong to void if eq get Pl o 47 bpl o n -else +ret +end r = cwd Ag 0 len Ag if gt r 1 for j ulong sub ulong r 1 @@ -350,16 +390,6 @@ bc 47 bpl add o k sub n k end end -while gt sub mark m 1 bound 4096 -if ne get Ob sub mark 1 47 -break -end -put Ol 0 sub mark 1 -end -put Rt0 0 psave m sub mark m -put Rtn 0 sub mark m -reset m -end note package name from the input's last path component: [a-z0-9_], not starting with a digit fn pkgname to void @@ -800,10 +830,14 @@ bc 10 flush 2 m ret 2 end +fsort +sksort +if not exload get Rd0 0 get Rdn 0 +ret 2 +end if not outdirs ret 2 end -fsort adhead tools ingest @@ -811,6 +845,7 @@ pipeline gentarget difftest progend +cwalk 0 reports if eq get Cap 0 1 eputs ECap @@ -820,6 +855,9 @@ jsonout else summary end +if eq get Cpl 0 1 +ret cexit +end if anyfail ret 1 end diff --git a/tests/.crumb b/tests/.crumb index 2bea760..b351093 100644 --- a/tests/.crumb +++ b/tests/.crumb @@ -3,14 +3,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-28T21:30:12Z", + "compiled_at": "2026-10-31T00:49:27Z", "compiler": "crumb-compile/1", - "digest": "sha256:dd282acfe6e92b7f93b9262d0eecf2cb2a354cbb4f5624f48434af0614fa1579", + "digest": "sha256:751a47ee52b040849dee910d04299ccf6c42d6e7136d1af368e4f083a0ec8787", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 1, - "generated_at_commit": "13ad42d9c3383774f34caf9087bf5f7d9d3d675c", - "source_tree": "sha256:1ae9bfdfa49bf1798586450733d9abd220145f722f735c8f1eb4fea5645b6c98" + "generated_at_commit": "d2d41505e266b7da02800bbb0422c14c73a582e1", + "source_tree": "sha256:f220a345137e22ed79d3cb8a4927714f8259d5092ea0123fa4801e6916b1c1c4" } }, "name": "babel-tests", diff --git a/tests/run.sh b/tests/run.sh index 8c36aab..569a65c 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -84,5 +84,213 @@ case "$v" in esac [ $r -eq 1 ] && ok "negative control: exit 1" || bad "negative control: exit $r, expected 1" +# 5. completion record (policy complete-v1) and --complete exit status. +# comp DIR prints "state denominator covered n_open" from DIR/report.json and validates the JSON; +# openl DIR prints one "kind|item|name|verdict|reason" line per open item. +comp() { + python3 -m json.tool "$1/report.json" > /dev/null || { echo "JSON-INVALID"; return; } + python3 -c 'import json,sys; c=json.load(open(sys.argv[1]))["completion"]; assert c["policy"]=="complete-v1"; print(c["state"],c["denominator"],c["covered"],len(c["open"]))' "$1/report.json" +} +openl() { + python3 -c 'import json,sys +for o in json.load(open(sys.argv[1]))["completion"]["open"]: print("|".join(str(o[k]) for k in ("kind","item","name","verdict","reason")))' "$1/report.json" +} +# (f) legacy: no --complete, the sample still exits 0; the record is computed but not enforced +rm -rf "$work/sample.babel" +(cd "$work" && "$B" sample --to c --adapters "$BABEL_ADAPTERS" > "$work/cf.out" 2>&1); r=$? +s=$(comp "$work/sample.babel") +e=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["completion"]["enforced"])' "$work/sample.babel/report.json") +[ $r -eq 0 ] && [ "${s%% *}" = PARTIAL ] && [ "$e" = False ] && ok "complete (f): sample without --complete exits 0, record $s, enforced $e" \ + || bad "complete (f): exit $r, record $s, enforced $e" +# (a) the sample under --complete is PARTIAL (exit 3) and names its open items +rm -rf "$work/sample.babel" +(cd "$work" && "$B" sample --to c --adapters "$BABEL_ADAPTERS" --complete > "$work/ca.out" 2>&1); r=$? +s=$(comp "$work/sample.babel") +openl "$work/sample.babel" > "$work/ca.open" +if [ $r -eq 3 ] && [ "${s%% *}" = PARTIAL ] && [ "${s##* }" -gt 0 ] \ + && grep -q '^unit|src/mix.c:15-17|zero|UNSUPPORTED(68)|' "$work/ca.open" \ + && grep -q '^unit|tools/report.py:1|None|MISSING_IMPLEMENTATION|' "$work/ca.open" \ + && grep -q '^file|README.txt|None|MISSING_IMPLEMENTATION|' "$work/ca.open" \ + && grep -q '^## Completion' "$work/sample.babel/REPORT.md" && grep -q 'State: \*\*PARTIAL\*\*' "$work/sample.babel/REPORT.md"; then + ok "complete (a): sample --complete exits 3, record $s (state den covered open), open list names zero, tools/report.py, README.txt" +else + bad "complete (a): exit $r, record $s"; cat "$work/ca.open" +fi +# (d) negative control: the mutated oracle under --complete is FAILED (exit 1) +rm -rf "$work/sample.babel" +(cd "$work" && PATH="$work/bin:$PATH" "$B" sample --to c --adapters "$BABEL_ADAPTERS" --complete > "$work/cd.out" 2>&1); r=$? +s=$(comp "$work/sample.babel") +openl "$work/sample.babel" > "$work/cd.open" +if [ $r -eq 1 ] && [ "${s%% *}" = FAILED ] && grep -q '^unit|src/hash.c:3-5|fold|FAIL|' "$work/cd.open" \ + && grep -q '^check|src/hash.c:3-5|fold|FAIL|differential leg: Omega' "$work/cd.open"; then + ok "complete (d) negative control: mutated oracle under --complete exits 1, record $s, fold unit and Omega leg FAIL" +else + bad "complete (d): exit $r, record $s"; cat "$work/cd.open" +fi +# (b) examples/complete (three S1 functions + the stdint include) is COMPLETE (exit 0) +cp -r "$here/examples/complete" "$work/complete" +for t in c rust; do + rm -rf "$work/complete.babel" + (cd "$work" && "$B" complete --to "$t" --adapters "$BABEL_ADAPTERS" --complete > "$work/cb.out" 2>&1); r=$? + s=$(comp "$work/complete.babel") + set -- $s + if [ $r -eq 0 ] && [ "$1" = COMPLETE ] && [ "$2" -eq "$3" ] && [ "$4" -eq 0 ] && grep -q 'State: \*\*COMPLETE\*\*' "$work/complete.babel/REPORT.md"; then + ok "complete (b) $t: examples/complete --complete exits 0, record $s, covered == denominator" + else + bad "complete (b) $t: exit $r, record $s"; openl "$work/complete.babel" + fi +done +# (c) negative controls: the same input plus one hidden file, or plus one symbolic link, is PARTIAL (exit 3) +for kind in hidden symlink; do + rm -rf "$work/cc" "$work/cc.babel" + cp -r "$here/examples/complete" "$work/cc" + if [ $kind = hidden ]; then + echo 'uint64_t ghost(uint64_t x) { return x; }' > "$work/cc/src/.ghost.c"; want='^skipped|src/.ghost.c|None|SKIPPED|hidden' + else + ln -s arith.c "$work/cc/src/alias.c"; want='^skipped|src/alias.c|None|SKIPPED|symbolic link' + fi + (cd "$work" && "$B" cc --to c --adapters "$BABEL_ADAPTERS" --complete > "$work/ccc.out" 2>&1); r=$? + s=$(comp "$work/cc.babel") + openl "$work/cc.babel" > "$work/cc.open" + if [ $r -eq 3 ] && [ "${s%% *}" = PARTIAL ] && [ "$(wc -l < "$work/cc.open")" -eq 1 ] && grep -q "$want" "$work/cc.open"; then + ok "complete (c) negative control ($kind): exits 3, record $s, the only open item: $(cut -d'|' -f2,4 "$work/cc.open")" + else + bad "complete (c) $kind: exit $r, record $s"; cat "$work/cc.open" + fi +done +# (e) a missing target toolchain is BLOCKED (exit 4) +rm -rf "$work/complete.babel" +(cd "$work" && ZIG=/nonexistent "$B" complete --to zig --adapters "$BABEL_ADAPTERS" --complete > "$work/ce.out" 2>&1); r=$? +s=$(comp "$work/complete.babel") +openl "$work/complete.babel" > "$work/ce.open" +if [ $r -eq 4 ] && [ "${s%% *}" = BLOCKED ] && grep -q '^toolchain|zig|None|NOT_RUN|' "$work/ce.open" \ + && grep -q '^check|src/arith.c:3-5|blend|NOT_RUN|differential leg: target zig did not run' "$work/ce.open"; then + ok "complete (e): ZIG=/nonexistent --to zig --complete exits 4, record $s" +else + bad "complete (e): exit $r, record $s"; cat "$work/ce.open" +fi + +# 6. --exclude manifest. exl DIR prints "excluded_count walked_as" and one "kind|item|reason|matched_by" +# line per excluded item. Manifests live in $work, outside the walked tree, unless a test says so. +exl() { + python3 -c 'import json,sys +c=json.load(open(sys.argv[1]))["completion"]; m=c["manifest"] +assert c["excluded_count"]==len(c["excluded"]) +print(c["excluded_count"], m["walked_as"] if m else "-") +for x in c["excluded"]: assert x["verdict"]=="EXCLUDED"; print("|".join(str(x[k]) for k in ("kind","item","reason","matched_by")))' "$1/report.json" +} +rm -rf "$work/cg" "$work/cg.babel" +cp -r "$here/examples/complete" "$work/cg" +echo 'notes for people' > "$work/cg/README.txt" +# (g) README.txt makes it PARTIAL (exit 3); a manifest excluding it with a reason makes it COMPLETE (exit 0) +(cd "$work" && "$B" cg --to c --adapters "$BABEL_ADAPTERS" --complete > "$work/cg0.out" 2>&1); r0=$? +s0=$(comp "$work/cg.babel") +printf '# documentation is not translated\n\nREADME.txt human notes, no code \n' > "$work/g.exclude" +(cd "$work" && "$B" cg --to c --adapters "$BABEL_ADAPTERS" --complete --exclude g.exclude --no-color > "$work/cg1.out" 2>&1); r1=$? +s1=$(comp "$work/cg.babel") +exl "$work/cg.babel" > "$work/cg1.exl" +sha8=$(sha256sum "$work/g.exclude" | cut -c1-8) +set -- $s0; d0=$2 +set -- $s1 +if [ $r0 -eq 3 ] && [ "${s0%% *}" = PARTIAL ] && [ $r1 -eq 0 ] && [ "$1" = COMPLETE ] && [ "$2" -eq "$d0" ] && [ "$4" -eq 0 ] \ + && [ "$(head -1 "$work/cg1.exl")" = "1 None" ] && grep -qx 'file|README.txt|human notes, no code|README.txt' "$work/cg1.exl" \ + && grep -q "COMPLETE $3 of $2 items covered, 1 excluded by manifest $sha8" "$work/cg1.out" \ + && grep -qF '| file | `README.txt` | EXCLUDED | `README.txt` (line 3) | human notes, no code |' "$work/cg.babel/REPORT.md"; then + ok "complete (g): +README.txt exits $r0 ($s0); --exclude README.txt exits 0, record $s1, denominator unchanged $d0, excluded_count 1, manifest $sha8" +else + bad "complete (g): exits $r0/$r1, records $s0 / $s1"; cat "$work/cg1.exl" "$work/cg1.out" +fi +# (g2) the manifest inside the walked tree is counted (covered); a hidden non-source entry may be excluded +printf 'x\n' > "$work/cg/.gitignore" +printf 'README.txt human notes\n.gitignore VCS metadata, no code\n' > "$work/cg/babel.exclude" +(cd "$work" && "$B" cg --to c --adapters "$BABEL_ADAPTERS" --complete --exclude cg/babel.exclude > "$work/cg2.out" 2>&1); r=$? +s=$(comp "$work/cg.babel") +exl "$work/cg.babel" > "$work/cg2.exl" +set -- $s +if [ $r -eq 0 ] && [ "$1" = COMPLETE ] && [ "$2" -eq $((d0 + 2)) ] && [ "$3" -eq "$d0" ] && [ "$(head -1 "$work/cg2.exl")" = "2 babel.exclude" ] \ + && grep -qx 'skipped|.gitignore|VCS metadata, no code|.gitignore' "$work/cg2.exl"; then + ok "complete (g2): in-tree manifest covered, .gitignore excluded: exits 0, record $s, excluded_count 2, walked_as babel.exclude" +else + bad "complete (g2): exit $r, record $s"; cat "$work/cg2.exl"; openl "$work/cg.babel" +fi +rm -f "$work/cg/.gitignore" "$work/cg/babel.exclude" +# (h)-(k) negative controls: each bad manifest exits 2 with a line diagnostic and writes no output folder +xneg() { # name manifest-text expected-stderr + rm -rf "$work/cg.babel" + printf "$2" > "$work/$1.exclude" + (cd "$work" && "$B" cg --to c --adapters "$BABEL_ADAPTERS" --complete --exclude "$1.exclude" > "$work/$1.out" 2>&1); r=$? + if [ $r -eq 2 ] && grep -qF "$3" "$work/$1.out" && [ ! -e "$work/cg.babel" ]; then + ok "complete ($1) negative control: exits 2, no output folder: $(grep -- '--exclude' "$work/$1.out" | head -1)" + else + bad "complete ($1): exit $r, expected 2 and /$3/"; cat "$work/$1.out" + fi +} +xneg h 'src/arith.c not wanted\n' "line 1: entry names source babel splits, which cannot be excluded: src/arith.c -> src/arith.c" +xneg h2 'src/ the whole tree\n' "line 1: entry names source babel splits, which cannot be excluded: src -> src/arith.c" +xneg i 'README.txt human notes\nnothere.txt gone\n' "line 2: entry matches nothing in the walked tree (stale manifest): nothere.txt" +xneg j '# no reason below\nREADME.txt\n' "line 2: entry has no reason (each line is <path> <reason>): README.txt" +xneg j2 'src/*.txt glob\n' "line 1: globs are not supported" +echo 'uint64_t ghost(uint64_t x) { return x; }' > "$work/cg/src/.ghost.c" +xneg k 'README.txt human notes\nsrc/.ghost.c hidden scratch\n' "line 2: entry names source babel splits, which cannot be excluded: src/.ghost.c -> src/.ghost.c" +rm -f "$work/cg/src/.ghost.c" +ln -s arith.c "$work/cg/src/alias.c" +xneg k2 'README.txt human notes\nsrc/alias.c a link\n' "line 2: entry names source babel splits, which cannot be excluded: src/alias.c -> src/alias.c" +rm -f "$work/cg/src/alias.c" + +# 7. completion gaps: other non-regular file, unreadable directory, missing cc, failing generated test +rm -rf "$work/cf" "$work/cf.babel" +cp -r "$here/examples/complete" "$work/cf" +mkfifo "$work/cf/src/pipe" +(cd "$work" && "$B" cf --to c --adapters "$BABEL_ADAPTERS" --complete > "$work/cf7.out" 2>&1); r=$? +s=$(comp "$work/cf.babel"); openl "$work/cf.babel" > "$work/cf7.open" +if [ $r -eq 3 ] && [ "${s%% *}" = PARTIAL ] && [ "$(wc -l < "$work/cf7.open")" -eq 1 ] && grep -q '^skipped|src/pipe|None|SKIPPED|not a regular file' "$work/cf7.open"; then + ok "complete gap (fifo): exits 3, record $s, the only open item: $(cut -d'|' -f2,4,5 "$work/cf7.open")" +else + bad "complete gap (fifo): exit $r, record $s"; cat "$work/cf7.open" +fi +rm -f "$work/cf/src/pipe" +if [ "$(id -u)" = 0 ]; then + echo "NOT_RUN (root) complete gap (unreadable directory): root reads a mode-000 directory" +else + mkdir "$work/cf/locked"; echo x > "$work/cf/locked/a.txt"; chmod 000 "$work/cf/locked" + trap 'chmod 755 "$work/cf/locked" 2>/dev/null; rm -rf "$work"' EXIT + (cd "$work" && "$B" cf --to c --adapters "$BABEL_ADAPTERS" --complete > "$work/cu.out" 2>&1); r=$? + chmod 755 "$work/cf/locked"; rm -rf "$work/cf/locked" + s=$(comp "$work/cf.babel"); openl "$work/cf.babel" > "$work/cu.open" + if [ $r -eq 3 ] && [ "${s%% *}" = PARTIAL ] && [ "$(wc -l < "$work/cu.open")" -eq 1 ] && grep -q '^skipped|locked|None|SKIPPED|directory could not be read' "$work/cu.open"; then + ok "complete gap (unreadable directory): exits 3, record $s, the only open item: $(cut -d'|' -f2,4,5 "$work/cu.open")" + else + bad "complete gap (unreadable directory): exit $r, record $s"; cat "$work/cu.open" + fi +fi +# a PATH with every tool but cc: the oracle cannot be built, so the run is BLOCKED (exit 4) +mkdir "$work/nocc" +for d in $(echo "$PATH" | tr ':' ' '); do + [ -d "$d" ] || continue + for f in "$d"/*; do + n=${f##*/}; [ "$n" = cc ] && continue; [ -e "$work/nocc/$n" ] || [ -L "$work/nocc/$n" ] || ln -s "$f" "$work/nocc/$n" + done +done +(cd "$work" && PATH="$work/nocc" "$B" cf --to python --adapters "$BABEL_ADAPTERS" --complete > "$work/cn.out" 2>&1); r=$? +s=$(comp "$work/cf.babel"); openl "$work/cf.babel" > "$work/cn.open" +if [ $r -eq 4 ] && [ "${s%% *}" = BLOCKED ] && grep -q '^toolchain|cc|None|NOT_RUN|cc was not found' "$work/cn.open" && ! grep -q '|FAIL|' "$work/cn.open"; then + ok "complete gap (no cc): exits 4, record $s, $(grep -c NOT_RUN "$work/cn.open") NOT_RUN items incl. toolchain cc" +else + bad "complete gap (no cc): exit $r, record $s"; cat "$work/cn.open" +fi +# a cargo that fails only "cargo test": the generated target test is the one FAIL (exit 1) +realcargo=$(command -v cargo) +mkdir "$work/cbin" +printf '#!/bin/sh\nif [ "$1" = test ]; then echo "shim: cargo test forced to fail" >&2; exit 101; fi\nexec "%s" "$@"\n' "$realcargo" > "$work/cbin/cargo" +chmod +x "$work/cbin/cargo" +(cd "$work" && PATH="$work/cbin:$PATH" "$B" cf --to rust --adapters "$BABEL_ADAPTERS" --complete > "$work/ct.out" 2>&1); r=$? +s=$(comp "$work/cf.babel"); openl "$work/cf.babel" > "$work/ct.open" +if [ $r -eq 1 ] && [ "${s%% *}" = FAILED ] && [ "$(wc -l < "$work/ct.open")" -eq 1 ] && grep -q '^check|diff/test.log|None|FAIL|generated target test failed (see diff/test.log), exit 101' "$work/ct.open"; then + ok "complete gap (generated test): cargo test fails, exits 1, record $s, the only open item: $(cut -d'|' -f2,4,5 "$work/ct.open")" +else + bad "complete gap (generated test): exit $r, record $s"; cat "$work/ct.open" +fi +echo "NOT_RUN complete gap (lstat failure, skip reason 6): no unprivileged way to make lstat fail on an entry getdents returned" + echo "failures: $fails" [ $fails -eq 0 ]