mirror of
https://github.com/FiloSottile/age.git
synced 2025-12-23 05:25:14 +00:00
cmd/age: fix testscript setup races
This commit is contained in:
committed by
Filippo Valsorda
parent
ed44098807
commit
ad7bb569eb
@@ -8,6 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"filippo.io/age"
|
"filippo.io/age"
|
||||||
@@ -50,21 +51,25 @@ func (testPlugin) Unwrap(ss []*age.Stanza) ([]byte, error) {
|
|||||||
return nil, age.ErrIncorrectIdentity
|
return nil, age.ErrIncorrectIdentity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var buildExtraCommands = sync.OnceValue(func() error {
|
||||||
|
bindir := filepath.SplitList(os.Getenv("PATH"))[0]
|
||||||
|
// Build age-keygen and age-plugin-pq into the test binary directory.
|
||||||
|
cmd := exec.Command("go", "build", "-o", bindir)
|
||||||
|
if testing.CoverMode() != "" {
|
||||||
|
cmd.Args = append(cmd.Args, "-cover")
|
||||||
|
}
|
||||||
|
cmd.Args = append(cmd.Args, "filippo.io/age/cmd/age-keygen")
|
||||||
|
cmd.Args = append(cmd.Args, "filippo.io/age/cmd/age-plugin-pq")
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
return cmd.Run()
|
||||||
|
})
|
||||||
|
|
||||||
func TestScript(t *testing.T) {
|
func TestScript(t *testing.T) {
|
||||||
testscript.Run(t, testscript.Params{
|
testscript.Run(t, testscript.Params{
|
||||||
Dir: "testdata",
|
Dir: "testdata",
|
||||||
Setup: func(e *testscript.Env) error {
|
Setup: func(e *testscript.Env) error {
|
||||||
bindir := filepath.SplitList(os.Getenv("PATH"))[0]
|
return buildExtraCommands()
|
||||||
// Build age-keygen and age-plugin-pq into the test binary directory
|
|
||||||
cmd := exec.Command("go", "build", "-o", bindir)
|
|
||||||
if testing.CoverMode() != "" {
|
|
||||||
cmd.Args = append(cmd.Args, "-cover")
|
|
||||||
}
|
|
||||||
cmd.Args = append(cmd.Args, "filippo.io/age/cmd/age-keygen")
|
|
||||||
cmd.Args = append(cmd.Args, "filippo.io/age/cmd/age-plugin-pq")
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
return cmd.Run()
|
|
||||||
},
|
},
|
||||||
// TODO: enable AGEDEBUG=plugin without breaking stderr checks.
|
// TODO: enable AGEDEBUG=plugin without breaking stderr checks.
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user