Skip to content

Commit

Permalink
ci: make acceptance test logs more readable (#208)
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
  • Loading branch information
caarlos0 authored Aug 16, 2020
1 parent 511a167 commit abb576b
Showing 1 changed file with 13 additions and 38 deletions.
51 changes: 13 additions & 38 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package acceptance

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand All @@ -25,7 +24,6 @@ func TestSimple(t *testing.T) {
for _, format := range formats {
format := format
t.Run(fmt.Sprintf("amd64-%s", format), func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("simple_%s", format),
Conf: "simple.yaml",
Expand All @@ -34,7 +32,6 @@ func TestSimple(t *testing.T) {
})
})
t.Run(fmt.Sprintf("i386-%s", format), func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("simple_%s_386", format),
Conf: "simple.386.yaml",
Expand All @@ -44,7 +41,6 @@ func TestSimple(t *testing.T) {
})
t.Run(fmt.Sprintf("ppc64le-%s", format), func(t *testing.T) {
t.Skip("for some reason travis fails to run those")
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("simple_%s_ppc64le", format),
Conf: "simple.ppc64le.yaml",
Expand All @@ -53,7 +49,6 @@ func TestSimple(t *testing.T) {
})
})
t.Run(fmt.Sprintf("arm64-%s", format), func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("simple_%s_arm64", format),
Conf: "simple.arm64.yaml",
Expand All @@ -68,7 +63,6 @@ func TestComplex(t *testing.T) {
for _, format := range formats {
format := format
t.Run(fmt.Sprintf("amd64-%s", format), func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("complex_%s", format),
Conf: "complex.yaml",
Expand All @@ -77,7 +71,6 @@ func TestComplex(t *testing.T) {
})
})
t.Run(fmt.Sprintf("i386-%s", format), func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("complex_%s_386", format),
Conf: "complex.386.yaml",
Expand Down Expand Up @@ -108,7 +101,6 @@ func TestConfigNoReplace(t *testing.T) {
require.NoError(t, pkg.Package(nfpm.WithDefaults(info), f))

t.Run("noreplace-rpm", func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: "noreplace_rpm",
Conf: "config-noreplace.yaml",
Expand All @@ -122,7 +114,6 @@ func TestEnvVarVersion(t *testing.T) {
for _, format := range formats {
format := format
t.Run(fmt.Sprintf("amd64-%s", format), func(t *testing.T) {
t.Parallel()
os.Setenv("SEMVER", "v1.0.0-0.1.b1+git.abcdefgh")
accept(t, acceptParms{
Name: fmt.Sprintf("env-var-version_%s", format),
Expand All @@ -138,7 +129,6 @@ func TestComplexOverrides(t *testing.T) {
for _, format := range formats {
format := format
t.Run(fmt.Sprintf("amd64-%s", format), func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("overrides_%s", format),
Conf: "overrides.yaml",
Expand All @@ -153,7 +143,6 @@ func TestMin(t *testing.T) {
for _, format := range formats {
format := format
t.Run(fmt.Sprintf("amd64-%s", format), func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("min_%s", format),
Conf: "min.yaml",
Expand All @@ -168,7 +157,6 @@ func TestMeta(t *testing.T) {
for _, format := range formats {
format := format
t.Run(fmt.Sprintf("amd64-%s", format), func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("meta_%s", format),
Conf: "meta.yaml",
Expand All @@ -184,7 +172,6 @@ func TestRPMCompression(t *testing.T) {
for _, format := range compressFormats {
format := format
t.Run(format, func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("%s_compression_rpm", format),
Conf: fmt.Sprintf("%s.compression.yaml", format),
Expand Down Expand Up @@ -217,7 +204,6 @@ func TestChangelog(t *testing.T) {
for _, format := range formats {
format := format
t.Run(fmt.Sprintf("changelog-%s", format), func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("changelog_%s", format),
Conf: "withchangelog.yaml",
Expand All @@ -230,7 +216,6 @@ func TestChangelog(t *testing.T) {

func TestDebTriggers(t *testing.T) {
t.Run("triggers-deb", func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: "triggers-deb",
Conf: "triggers.yaml",
Expand All @@ -244,7 +229,6 @@ func TestSymlink(t *testing.T) {
for _, format := range formats {
format := format
t.Run(fmt.Sprintf("symlink-%s", format), func(t *testing.T) {
t.Parallel()
accept(t, acceptParms{
Name: fmt.Sprintf("symlink_%s", format),
Conf: "symlink.yaml",
Expand All @@ -262,6 +246,15 @@ type acceptParms struct {
Dockerfile string
}

type testWriter struct {
t *testing.T
}

func (t testWriter) Write(p []byte) (n int, err error) {
t.t.Logf(string(p))
return len(p), nil
}

func accept(t *testing.T, params acceptParms) {
var configFile = filepath.Join("./testdata", params.Conf)
tmp, err := filepath.Abs("./testdata/tmp")
Expand Down Expand Up @@ -293,27 +286,9 @@ func accept(t *testing.T, params acceptParms) {
".",
)
cmd.Dir = "./testdata"
stdout, err := cmd.StdoutPipe()
require.NoError(t, err)
stderr, err := cmd.StderrPipe()
require.NoError(t, err)
t.Log("will exec:", cmd.Args)
err = cmd.Start()
require.NoError(t, err)
cmd.Stderr = testWriter{t}
cmd.Stdout = cmd.Stderr

var slurp []byte
slurp, err = ioutil.ReadAll(stderr)
if len(slurp) > 0 {
t.Log("stderr:", string(slurp))
}
require.NoError(t, err)

slurp, err = ioutil.ReadAll(stdout)
if len(slurp) > 0 {
t.Log("stdout:", string(slurp))
}
require.NoError(t, err)

err = cmd.Wait()
require.NoError(t, err)
t.Log("will exec:", cmd.Args)
require.NoError(t, cmd.Run())
}

1 comment on commit abb576b

@vercel
Copy link

@vercel vercel bot commented on abb576b Aug 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.