diff --git a/go.mod b/go.mod index eaaefd5..7f5a6b8 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( // Test dependencies. require ( + c2sp.org/CCTV/age v0.0.0-20221230231406-5ea85644bd03 github.com/creack/pty v1.1.18 // indirect github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e // indirect github.com/rogpeppe/go-internal v1.8.1 diff --git a/go.sum b/go.sum index 3f691a9..ec52009 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +c2sp.org/CCTV/age v0.0.0-20221230231406-5ea85644bd03 h1:0e2QjhWG02SgzlUOvNYaFraf04OBsUPOLxf+K+Ae/yM= +c2sp.org/CCTV/age v0.0.0-20221230231406-5ea85644bd03/go.mod h1:FomMrUJ2Lxt5jCLmZkG3FHa72zUprnhd3v/Z18Snm4w= filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= github.com/FiloSottile/go-internal v1.8.2-0.20220728122003-0ced171a3e0e h1:hLDldUUKSNgXte+2H8yZzPVStWa7697IJer9wwfW/dg= diff --git a/testkit_test.go b/testkit_test.go index e4480b4..ab315e5 100644 --- a/testkit_test.go +++ b/testkit_test.go @@ -11,50 +11,29 @@ import ( "bytes" "crypto/sha256" "encoding/hex" - "encoding/json" "errors" "io" - "os" - "os/exec" - "path/filepath" + "io/fs" "strings" "testing" "filippo.io/age" "filippo.io/age/armor" + + agetest "c2sp.org/CCTV/age" ) func TestVectors(t *testing.T) { - if _, err := exec.LookPath("go"); err != nil { - t.Skipf("skipping test because 'go' command is unavailable: %v", err) - } - - // Download the testkit files from CCTV using `go mod download -json` so the - // cached source of the testdata can be reused. - path := "c2sp.org/CCTV/age@v0.0.0-20221027185432-cfaa74dc42af" - cmd := exec.Command("go", "mod", "download", "-json", path) - output, err := cmd.Output() - if err != nil { - t.Fatalf("failed to run `go mod download -json %s`, output: %s", path, output) - } - var dm struct { - Dir string // absolute path to cached source root directory - } - if err := json.Unmarshal(output, &dm); err != nil { - t.Fatal(err) - } - testkitDir := filepath.Join(dm.Dir, "testdata") - - tests, err := filepath.Glob(testkitDir + "/*") + tests, err := fs.ReadDir(agetest.Vectors, ".") if err != nil { t.Fatal(err) } for _, test := range tests { - contents, err := os.ReadFile(test) + name := test.Name() + contents, err := fs.ReadFile(agetest.Vectors, name) if err != nil { t.Fatal(err) } - name := filepath.Base(test) t.Run(name, func(t *testing.T) { testVector(t, contents) })