mnix: Nix binary-cache client PoC in MoonBit (install hello from cache.nixos.org) (#1)
This commit was merged in pull request #1.
This commit is contained in:
1 parent
4e7ce11973
commit
fa70164336
48 files changed
+3112
-2
No files matched your search
@@ -0,0 +1,50 @@
|
||||
///|
|
||||
test "manifest roundtrip" {
|
||||
let es : Array[Entry] = [
|
||||
{ name: "hello", path: "/s/aaa-hello-2.8", bins: ["hello"], },
|
||||
{ name: "coreutils", path: "/s/bbb-coreutils-9", bins: ["ls", "cat"], },
|
||||
]
|
||||
assert_eq(parse_manifest(serialize_manifest(es)), es)
|
||||
assert_true(@store.raises(() => parse_manifest("only\ttwo\n")))
|
||||
}
|
||||
|
||||
///|
|
||||
test "conflict detection" {
|
||||
let es : Array[Entry] = [{ name: "a", path: "/p", bins: ["x", "y"], }]
|
||||
assert_eq(find_conflict(es, "b", ["y"]), Some(("a", "y")))
|
||||
assert_eq(find_conflict(es, "a", ["y"]), None) // upgrade of same name is fine
|
||||
assert_eq(find_conflict(es, "b", ["z"]), None)
|
||||
}
|
||||
|
||||
///|
|
||||
async test "add / list / remove with real symlinks" {
|
||||
let root = @fs.tmpdir(prefix="mnix-prof-")
|
||||
let pkg = "\{root}/store/8padfyi6z9ipfq35j86krpvpvx3j3r3v-demo-1"
|
||||
@fs.mkdir("\{pkg}/bin", recursive=true)
|
||||
@fs.write_file("\{pkg}/bin/demo", "#!/bin/sh\n", permission=0o755)
|
||||
let p : Profile = { dir: "\{root}/profile", }
|
||||
let e = p.add("demo", pkg)
|
||||
assert_eq(e.bins, ["demo"])
|
||||
assert_true(
|
||||
@fs.kind("\{root}/profile/bin/demo", follow_symlink=false) is SymLink,
|
||||
)
|
||||
assert_eq(p.list().length(), 1)
|
||||
// re-add is idempotent
|
||||
ignore(p.add("demo", pkg))
|
||||
assert_eq(p.list().length(), 1)
|
||||
// conflicting package
|
||||
let pkg2 = "\{root}/store/9padfyi6z9ipfq35j86krpvpvx3j3r3v-other-1"
|
||||
@fs.mkdir("\{pkg2}/bin", recursive=true)
|
||||
@fs.write_file("\{pkg2}/bin/demo", "x", permission=0o755)
|
||||
let mut failed = false
|
||||
try p.add("other", pkg2) catch {
|
||||
_ => failed = true
|
||||
} noraise {
|
||||
_ => ()
|
||||
}
|
||||
assert_true(failed)
|
||||
ignore(p.remove("demo"))
|
||||
assert_eq(p.list().length(), 0)
|
||||
assert_true(!@installer.lexists("\{root}/profile/bin/demo"))
|
||||
@installer.remove_tree(root)
|
||||
}
|
||||
Reference in new issue
Block a user