feat(install): add -S install with --dry-run and --noconfirm flags
Create full install pipeline (plan task 21): - src/tofu/recipeparse.d: light .recipe Lua parser (parseRecipeFile) - src/tofu/commands/install.d: installCommand with delegate seams - 8 unit tests covering: happy path, not-found, dep cycle, build failure, install failure, --dry-run, --noconfirm, user abort - All 21 modules pass dub test, dub build passes - Evidence: .omo/evidence/task-21-tofu-core.log
This commit is contained in:
@@ -58,3 +58,31 @@ DMD 2.112's `core.sys.posix.signal.signal` requires the handler to be `@nogc`.
|
||||
Similarly, `_exit(130)` from `core.sys.posix.unistd` is used instead of `core.stdc.stdlib.exit` — `_exit` does NOT run atexit handlers or flush stdio buffers, making it safe in a signal-handler context.
|
||||
|
||||
---
|
||||
|
||||
### Task 21: Module-level Config for `resolveDepTree` function pointer seam
|
||||
|
||||
`resolveDepTree` uses `Recipe function(string) @safe` (function pointer, not delegate) because the production caller (`installCommand`) needs to capture `Config cfg`. D function pointers cannot carry state, so a module-level `_installCfg` variable bridges the gap.
|
||||
|
||||
**Pattern**: Set `_installCfg = cfg` before calling `resolveDepTree`, clear via `scope(exit) _installCfg = Config.init;`. The `_recipeForDeps` function pointer reads `_installCfg` for cache-path access and recipe fetching.
|
||||
|
||||
**Rationale**: Tofu is single-threaded (lock-file based). Module-level state is safe within a single command run. The `scope(exit)` ensures cleanup on all exit paths (return, exception, goto).
|
||||
|
||||
### Task 21: Light recipe parser in `tofu.recipeparse` — double-quote only
|
||||
|
||||
The `extractKeyValue` scanner (ported from `tofu.fetch`) only recognizes double-quoted string values (`"value"`). Single-quoted values (`'value'`) are silently ignored, producing empty fields.
|
||||
|
||||
**Decision**: Document this limitation rather than adding single-quote support. ZUUR `.recipe` files use double quotes per Lua convention. The parser is explicitly documented as a LIGHT scanner, not a full Lua parser.
|
||||
|
||||
### Task 21: Confirmation prompt via `readln()` — `@trusted` wrapper
|
||||
|
||||
`std.stdio.stdin`, `stdout`, and `readln()` are all `@system` in DMD 2.112. The confirmation prompt wraps stdout write/flush and stdin read in `@trusted` helpers (`trustedReadLine()`), keeping the public `installCommand` `@safe`.
|
||||
|
||||
**Rationale**: Same pattern used in all tofu modules (`tofu.log`, `tofu.build`, `tofu.install`). No new `@trusted` philosophy — just the standard I/O seam.
|
||||
|
||||
### Task 21: Fake makepkg/zeta scripts for unit tests
|
||||
|
||||
Rather than adding build/install delegate seams to `installCommand`, the tests reuse the fake-script pattern from `build.d` and `install.d`: create executable bash scripts in temp directories, point `cfg.zetaToolchainPath` and `cfg.zetaPath` at them.
|
||||
|
||||
**Rationale**: Keeps `installCommand`'s API surface minimal (only index/binary seams). The fake scripts exercise the full production code path through `buildAll` and `installAll`, providing higher-fidelity integration tests.
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user