mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
parent
bb33419beb
commit
bad7984962
@ -3,6 +3,7 @@ package build
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@ -209,13 +210,18 @@ func TestRunPipeFailingHooks(t *testing.T) {
|
||||
ctx := testctx.NewWithCfg(cfg, testctx.WithCurrentTag("2.4.5"))
|
||||
ctx.Config.Builds[0].Hooks.Pre = []config.Hook{{Cmd: "exit 1"}}
|
||||
ctx.Config.Builds[0].Hooks.Post = []config.Hook{{Cmd: "echo post"}}
|
||||
require.EqualError(t, Pipe{}.Run(ctx), "pre hook failed: failed to run 'exit 1': exec: \"exit\": executable file not found in $PATH")
|
||||
|
||||
err := Pipe{}.Run(ctx)
|
||||
require.ErrorIs(t, err, exec.ErrNotFound)
|
||||
require.Contains(t, err.Error(), "pre hook failed")
|
||||
})
|
||||
t.Run("post-hook", func(t *testing.T) {
|
||||
ctx := testctx.NewWithCfg(cfg, testctx.WithCurrentTag("2.4.5"))
|
||||
ctx.Config.Builds[0].Hooks.Pre = []config.Hook{{Cmd: "echo pre"}}
|
||||
ctx.Config.Builds[0].Hooks.Post = []config.Hook{{Cmd: "exit 1"}}
|
||||
require.EqualError(t, Pipe{}.Run(ctx), `post hook failed: failed to run 'exit 1': exec: "exit": executable file not found in $PATH`)
|
||||
err := Pipe{}.Run(ctx)
|
||||
require.ErrorIs(t, err, exec.ErrNotFound)
|
||||
require.Contains(t, err.Error(), "post hook failed")
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ func process(ctx *context.Context, docker config.Docker, artifacts []*artifact.A
|
||||
if err := imagers[docker.Use].Build(ctx, tmp, images, buildFlags); err != nil {
|
||||
if isFileNotFoundError(err.Error()) {
|
||||
var files []string
|
||||
_ = filepath.Walk(tmp, func(path string, info fs.FileInfo, err error) error {
|
||||
_ = filepath.Walk(tmp, func(_ string, info fs.FileInfo, _ error) error {
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ func TestSignArtifacts(t *testing.T) {
|
||||
user string
|
||||
}{
|
||||
{
|
||||
desc: "sign cmd not found",
|
||||
expectedErrMsg: `sign: not-a-valid-cmd failed: exec: "not-a-valid-cmd": executable file not found in $PATH: `,
|
||||
desc: "sign cmd not found",
|
||||
expectedErrIs: exec.ErrNotFound,
|
||||
ctx: testctx.NewWithCfg(config.Project{
|
||||
Signs: []config.Sign{
|
||||
{
|
||||
|
@ -290,14 +290,18 @@ func TestRun(t *testing.T) {
|
||||
ctx := ctx5
|
||||
ctx.Config.UniversalBinaries[0].Hooks.Pre = []config.Hook{{Cmd: "exit 1"}}
|
||||
ctx.Config.UniversalBinaries[0].Hooks.Post = []config.Hook{{Cmd: "echo post"}}
|
||||
require.EqualError(t, Pipe{}.Run(ctx), "pre hook failed: failed to run 'exit 1': exec: \"exit\": executable file not found in $PATH")
|
||||
err := Pipe{}.Run(ctx)
|
||||
require.ErrorIs(t, err, exec.ErrNotFound)
|
||||
require.Contains(t, err.Error(), "pre hook failed")
|
||||
})
|
||||
|
||||
t.Run("failing post-hook", func(t *testing.T) {
|
||||
ctx := ctx5
|
||||
ctx.Config.UniversalBinaries[0].Hooks.Pre = []config.Hook{{Cmd: "echo pre"}}
|
||||
ctx.Config.UniversalBinaries[0].Hooks.Post = []config.Hook{{Cmd: "exit 1"}}
|
||||
require.EqualError(t, Pipe{}.Run(ctx), "post hook failed: failed to run 'exit 1': exec: \"exit\": executable file not found in $PATH")
|
||||
err := Pipe{}.Run(ctx)
|
||||
require.ErrorIs(t, err, exec.ErrNotFound)
|
||||
require.Contains(t, err.Error(), "post hook failed")
|
||||
})
|
||||
|
||||
t.Run("hook with env tmpl", func(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user