66158d7cb9d9

fix install to prefer exact pname match over first search result; add G-05 install/remove/try test; v3.0.6

time
2026-05-30 00:52 UTC · 4 months ago
machine
koh2
parent
83a0d325270c
3 files build.zig.zon+1 −1src/commands.zig+9 −1test/vm/tests/install.sh+30 −0
build.zig.zon+1 −1
@@ -9,7 +9,7 @@99     .name = .nina,1010     // This is a [Semantic Version](https://semver.org/).1111     // In a future version of Zig it will be used for package deduplication.12-    .version = "3.0.5",12+    .version = "3.0.6",1313     // Together with name, this represents a globally unique package1414     // identifier. This field is generated by the Zig toolchain when the1515     // package is first created, and then *never changes*. This allows

view file

src/commands.zig+9 −1
@@ -311,7 +311,15 @@311311         return error.PackageNotFound;312312     }313313 314-    const found = pkgs[0];314+    // Prefer an exact name match over the first search result — `install ripgrep`315+    // must pick "ripgrep", not the alphabetically-first match like "repgrep".316+    var found = pkgs[0];317+    for (pkgs) |p| {318+        if (std.mem.eql(u8, p.pname, pkg_name)) {319+            found = p;320+            break;321+        }322+    }315323     output.installSelectPrompt(found.pname, found.version);316324 317325     var choice_buf: [8]u8 = undefined;

view file

test/vm/tests/install.sh+30 −0
@@ -0,0 +1,30 @@1+#!/usr/bin/env sh2+# G-05 install/remove/try. nina install reads a profile/system choice from stdin3+# and defaults to PROFILE install on EOF, so `</dev/null` drives it4+# non-interactively. install runs `nix search` first (memory-heavy → needs5+# MEM_MB>=6144). Uses ripgrep (already in the system closure → no rebuild) and6+# hello (tiny); firefox/etc. would work but are slow under TCG. The 's' system7+# path opens an editor and is intentionally not exercised.8+set -u9+N=/root/nina10+11+echo "KILN_G05_BEGIN"12+13+echo "### T-071 nina install ripgrep (profile; stdin EOF -> default profile)"14+$N install ripgrep </dev/null; echo "INSTALL_RG_RC=$?"15+echo "rg in profile: $(ls /root/.nix-profile/bin/rg 2>/dev/null || echo MISSING)"16+17+echo "### nina profile list (expect ripgrep present)"18+$N profile list </dev/null; echo "PROFLIST_RC=$?"19+20+echo "### T-074 nina remove ripgrep (profile)"21+$N remove ripgrep </dev/null; echo "REMOVE_RC=$?"22+echo "rg after remove: $(ls /root/.nix-profile/bin/rg 2>/dev/null || echo GONE)"23+24+echo "### T-076 nina try hello (nix shell; stdin EOF exits the shell)"25+$N try hello </dev/null; echo "TRY_RC=$?"26+27+echo "### T-072 nina install nonexistent (expect 'not found', exit 1)"28+$N install xyzzy-nope-abc123 </dev/null; echo "INSTALL_NONE_RC=$?"29+30+echo "KILN_G05_END"

view file