Skip to content

Commit 7cf88a0

Browse files
authored
Add regression test for go install compatibility #2587 (#2591)
1 parent 41adc1a commit 7cf88a0

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ require (
2020
github.com/yuin/gopher-lua v1.1.1
2121
github.com/zclconf/go-cty v1.17.0
2222
go.yaml.in/yaml/v4 v4.0.0-rc.3
23+
golang.org/x/mod v0.31.0
2324
golang.org/x/net v0.49.0
2425
golang.org/x/text v0.33.0
2526
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
@@ -33,7 +34,6 @@ require (
3334
github.com/mattn/go-colorable v0.1.14 // indirect
3435
github.com/mattn/go-isatty v0.0.20 // indirect
3536
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
36-
golang.org/x/mod v0.31.0 // indirect
3737
golang.org/x/sync v0.19.0 // indirect
3838
golang.org/x/sys v0.40.0 // indirect
3939
golang.org/x/tools v0.40.0 // indirect

go_install_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package main
2+
3+
import (
4+
"io"
5+
"testing"
6+
7+
"golang.org/x/mod/module"
8+
"golang.org/x/mod/zip"
9+
)
10+
11+
// TestGoInstallCompatibility ensures the module can be zipped for go install.
12+
// This is an integration test that uses the same zip.CreateFromDir function
13+
// that go install uses internally. If this test fails, go install will fail.
14+
// See: https://github.com/mikefarah/yq/issues/2587
15+
func TestGoInstallCompatibility(t *testing.T) {
16+
mod := module.Version{
17+
Path: "github.com/mikefarah/yq/v4",
18+
Version: "v4.0.0", // the actual version doesn't matter for validation
19+
}
20+
21+
if err := zip.CreateFromDir(io.Discard, mod, "."); err != nil {
22+
t.Fatalf("Module cannot be zipped for go install: %v", err)
23+
}
24+
}

0 commit comments

Comments
 (0)