diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-08-20 18:43:09 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-08-20 22:32:20 +0200 |
commit | ec37420468157284651ef6b04b30420b249179e2 (patch) | |
tree | f2f09b5e943faabb450926fb127897b0980e86d6 /hugolib | |
parent | ae63c2b5c94f68fbabd5dbd821630e747e8959a4 (diff) |
Improve stderr logging for PostCSS and simlilar
Fixes #7584
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/resource_chain_babel_test.go | 14 | ||||
-rw-r--r-- | hugolib/resource_chain_test.go | 18 |
2 files changed, 20 insertions, 12 deletions
diff --git a/hugolib/resource_chain_babel_test.go b/hugolib/resource_chain_babel_test.go index d3351dfd4..e6e4ed8d3 100644 --- a/hugolib/resource_chain_babel_test.go +++ b/hugolib/resource_chain_babel_test.go @@ -14,12 +14,15 @@ package hugolib import ( + "bytes" "os" "os/exec" "path/filepath" "runtime" "testing" + jww "github.com/spf13/jwalterweatherman" + "github.com/gohugoio/hugo/htesting" "github.com/spf13/viper" @@ -80,10 +83,13 @@ class Car { c.Assert(err, qt.IsNil) defer clean() + var logBuf bytes.Buffer + logger := loggers.NewBasicLoggerForWriter(jww.LevelInfo, &logBuf) + v := viper.New() v.Set("workingDir", workDir) v.Set("disableKinds", []string{"taxonomy", "term", "page"}) - b := newTestSitesBuilder(t).WithLogger(loggers.NewWarningLogger()) + b := newTestSitesBuilder(t).WithLogger(logger) // Need to use OS fs for this. b.Fs = hugofs.NewDefault(v) @@ -108,12 +114,10 @@ Transpiled: {{ $transpiled.Content | safeJS }} _, err = exec.Command("npm", "install").CombinedOutput() b.Assert(err, qt.IsNil) - out, err := captureStderr(func() error { - return b.BuildE(BuildCfg{}) + b.Build(BuildCfg{}) - }) // Make sure Node sees this. - b.Assert(out, qt.Contains, "Hugo Environment: production") + b.Assert(logBuf.String(), qt.Contains, "babel: Hugo Environment: production") b.Assert(err, qt.IsNil) b.AssertFileContent("public/index.html", ` diff --git a/hugolib/resource_chain_test.go b/hugolib/resource_chain_test.go index c687ca342..64484f1f4 100644 --- a/hugolib/resource_chain_test.go +++ b/hugolib/resource_chain_test.go @@ -14,10 +14,15 @@ package hugolib import ( + "bytes" + + jww "github.com/spf13/jwalterweatherman" + "fmt" "io" "math/rand" "os" + "os/exec" "path/filepath" "runtime" @@ -893,10 +898,13 @@ h1 { c.Assert(err, qt.IsNil) defer clean() + var logBuf bytes.Buffer + newTestBuilder := func(v *viper.Viper) *sitesBuilder { v.Set("workingDir", workDir) v.Set("disableKinds", []string{"taxonomy", "term", "page"}) - b := newTestSitesBuilder(t).WithLogger(loggers.NewWarningLogger()) + logger := loggers.NewBasicLoggerForWriter(jww.LevelInfo, &logBuf) + b := newTestSitesBuilder(t).WithLogger(logger) // Need to use OS fs for this. b.Fs = hugofs.NewDefault(v) b.WithWorkingDir(workDir) @@ -942,14 +950,10 @@ class-in-b { b.Assert(os.Chdir(workDir), qt.IsNil) _, err = exec.Command("npm", "install").CombinedOutput() b.Assert(err, qt.IsNil) - - out, _ := captureStderr(func() error { - b.Build(BuildCfg{}) - return nil - }) + b.Build(BuildCfg{}) // Make sure Node sees this. - b.Assert(out, qt.Contains, "Hugo Environment: production") + b.Assert(logBuf.String(), qt.Contains, "Hugo Environment: production") b.AssertFileContent("public/index.html", ` Styles RelPermalink: /css/styles.css |