depot/go/nix/nixdrv/nixdrvhash_test.go

28 lines
6.4 KiB
Go
Raw Normal View History

2023-08-23 23:00:44 +00:00
package nixdrv
import (
"bufio"
"path"
"strings"
"testing"
"github.com/google/go-cmp/cmp"
)
2024-11-16 15:30:41 +00:00
const testData = `Derive([("out","/nix/store/prcng4aaimpjmnn7w0r8p4yfsqknmd64-golib-nixbuild","","")],[("/nix/store/0d0g9c5311rsll1vbw1nckf8xci5px78-golib-golang.org_x_crypto_ssh.drv",["out"]),("/nix/store/2yf7xmgj0pdx1mxk8dxaf2nxkw5gb0h0-golib-github.com_numtide_go-nix_nixbase32.drv",["out"]),("/nix/store/a5r8sb3xk6p0is4z6pw7jflc97v623k0-golib-golang.org_x_crypto_chacha20.drv",["out"]),("/nix/store/dv6n6shvw8qdk7bc00ygyjqwk26jv7lh-golib-golang.org_x_crypto_blowfish.drv",["out"]),("/nix/store/dwfjpdgw8by8f4aidinqaxfkxwg7cz02-golib-golang.org_x_crypto_curve25519.drv",["out"]),("/nix/store/flrv8lx2775bgdmxhbspbzc7jh3fg2x7-golib-golang.org_x_crypto_ed25519.drv",["out"]),("/nix/store/ghdqkh5fgfscd4n2yzsv2z03v23vymxa-golib-github.com_mattn_go-sqlite3.drv",["out"]),("/nix/store/ix0pi11lhgm9m8nqi99gzfn07vjnhk6l-golib-golang.org_x_crypto_poly1305.drv",["out"]),("/nix/store/jfi4am6v5qhqk0gjq5ycrpb6y8754qxf-bash-5.2-p15.drv",["out"]),("/nix/store/jwz0c3yq7rwn8xjq5hb19awach94d559-golib-narinfo.drv",["out"]),("/nix/store/nvf2z167xbgr57jmyi4ywnd3pn73wsli-golib-nixstore.drv",["out"]),("/nix/store/q2kpxbf93znb9raraxj5kjfa20amfry0-golib-nixdrv.drv",["out"]),("/nix/store/q653yq6f7dxwir77q9ryi1gvbcdcs9b0-golib-golang.org_x_crypto_ssh_internal_bcrypt_pbkdf.drv",["out"]),("/nix/store/qym7bn0pqh3381c079dr5yv4fi6nlmkj-go-1.19.12.drv",["out"]),("/nix/store/s7y5gb05ka3rcpazvkax3hm1bz64d8f8-golib-nixwire.drv",["out"]),("/nix/store/sw37l040k8zh7v02xvfc3db6yyim8wcy-stdenv-linux.drv",["out"]),("/nix/store/walxgj9piwz01f03ldk6x4fn1l5hmx7f-golib-golang.org_x_crypto_internal_subtle.drv",["out"]),("/nix/store/zb4czqkdd83asjdmf2984djz47n2wph6-golib-nixpool.drv",["out"])],["/nix/store/4n7mpxfsgjv0mjssiagldv26m7255d5z-nixbuild.go","/nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh","/nix/store/96bcb71plkmp73gwinl9awb4kx0kx41b-peerresolver.go","/nix/store/m3x8b8mqliy6gw1ka4gcg83qgbcl0irz-state.go","/nix/store/mmnbiyvnd1bvxw4p1vdhlvkph4q28q29-workitem.go","/nix/store/qs17yzkmv8imp1h93723b4j79j043l18-httpresolver.go","/nix/store/s22qhmbxm275lxbpxxxk1i4s2nan27pl-config.go","/nix/store/zms41ag0wqm1x40g6z740c5w3pgpc0a4-coordinator.go"],"x86_64-linux","/nix/store/ir0j7zqlw9dc49grmwplppc7gh0s40yf-bash-5.2-p15/bin/bash",["-e","/nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh"],[("__structuredAttrs",""),("buildCommand","mkdir -p $out/git.lukegb.com/lukegb/depot/go/nix/nixbuild\nEXTRAGO=\"\"\ncp /nix/store/s22qhmbxm275lxbpxxxk1i4s2nan27pl-config.go $out/git.lukegb.com/lukegb/depot/go/nix/nixbuild/config.go\ncp /nix/store/zms41ag0wqm1x40g6z740c5w3pgpc0a4-coordinator.go $out/git.lukegb.com/lukegb/depot/go/nix/nixbuild/coordinator.go\ncp /nix/store/qs17yzkmv8imp1h93723b4j79j043l18-httpresolver.go $out/git.lukegb.com/lukegb/depot/go/nix/nixbuild/httpresolver.go\ncp /nix/store/4n7mpxfsgjv0mjssiagldv26m7255d5z-nixbuild.go $out/git.lukegb.com/lukegb/depot/go/nix/nixbuild/nixbuild.go\ncp /nix/store/96bcb71plkmp73gwinl9awb4kx0kx41b-peerresolver.go $out/git.lukegb.com/lukegb/depot/go/nix/nixbuild/peerresolver.go\ncp /nix/store/m3x8b8mqliy6gw1ka4gcg83qgbcl0irz-state.go $out/git.lukegb.com/lukegb/depot/go/nix/nixbuild/state.go\ncp /nix/store/mmnbiyvnd1bvxw4p1vdhlvkph4q28q29-workitem.go $out/git.lukegb.com/lukegb/depot/go/nix/nixbuild/workitem.go\n\n\n/nix/store/71wgdw4snmvcbqkvly4lb5kham3nk5l9-go-1.19.12/bin/go tool compile -pack -o $out/git.lukegb.com/lukegb/depot/go/nix/nixbuild.a -trimpath=$PWD -trimpath=/nix/store/71wgdw4snmvcbqkvly4lb5kham3nk5l9-go-1.19.12 -trimpath=$out/git.lukegb.com/lukegb/depot/go/nix/nixbuild -p git.lukegb.com/lukegb/depot/go/nix/nixbuild -I /nix/store/rkna1n7ky45szab5lypfdmk0sjb8msqs-golib-nixstore -I /nix/store/d2w6m90zp0lpfd1h6mry95260ilgfs8h-golib-nixpool -I /nix/store/4r1c7qrgbj4h62srinpz7aps02amz7jd-golib-narinfo -I /nix/store/2icy6ahd2mbfim6s4r6yxpq95i4rlvgg-golib-nixwire -I /nix/store/0crllg0pzndv8p74scdvv41jy182b7mj-golib-github.com_mattn_go-sqlite3 -I /nix/store/wzb7f00nwkjwf1bya6wq7zswji3vcyis-golib-golang.org_x_crypto_ssh -I /nix/store/130v52aarlilgxdyjp6mmlpjiq4gw7df-golib-github.com_numtide_go-nix_nixbase32 -
2023-08-23 23:00:44 +00:00
const testPath = "/nix/store/c8xiwx5mlflhs0gxqa8v335w99izsbbj-golib-nixbuild.drv"
func TestHash(t *testing.T) {
drv, err := Load(bufio.NewReader(strings.NewReader(testData)))
if err != nil {
t.Fatalf("Load: %v", err)
}
if diff := cmp.Diff(testData, drv.String()); diff != "" {
t.Fatal(diff)
}
if got := drv.StorePath("golib-nixbuild", path.Dir(testPath)); got != testPath {
t.Fatalf("%q != %q", got, testPath)
}
}