Skip to content

Commit

Permalink
Replace CI test console logging with TestMain
Browse files Browse the repository at this point in the history
  • Loading branch information
tonimelisma committed Dec 21, 2020
1 parent fd39df8 commit 5af43e7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 30 deletions.
3 changes: 2 additions & 1 deletion vips/foreign_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package vips

import (
"github.com/stretchr/testify/assert"
"io/ioutil"
"testing"

"github.com/stretchr/testify/assert"
)

func Test_DetermineImageType__JPEG(t *testing.T) {
Expand Down
7 changes: 0 additions & 7 deletions vips/image_golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package vips

import (
"io/ioutil"
"os"
"os/exec"
"runtime"
"strings"
Expand All @@ -12,12 +11,6 @@ import (
"github.com/stretchr/testify/require"
)

func init() {
if os.Getenv("CI") != "" {
consoleLogging()
}
}

func TestImage_Resize_Downscale(t *testing.T) {
goldenTest(t, resources+"jpg-24bit.jpg",
func(img *ImageRef) error {
Expand Down
8 changes: 4 additions & 4 deletions vips/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
"github.com/stretchr/testify/require"
)

func init() {
if os.Getenv("CI") != "" {
consoleLogging()
}
func TestMain(m *testing.M) {
ret := m.Run()
Shutdown()
os.Exit(ret)
}

func TestImageRef_WebP(t *testing.T) {
Expand Down
18 changes: 0 additions & 18 deletions vips/logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ func captureOutput(f func()) string {

func Test_DefaultLogging(t *testing.T) {
Startup(nil)
if os.Getenv("CI") != "" {
enableLogging()
}
LoggingSettings(nil, LogLevelInfo)

output := captureOutput(func() {
Expand All @@ -31,16 +28,10 @@ func Test_DefaultLogging(t *testing.T) {
dateRegexp := regexp.MustCompile(`[0-9\/\:]+ `)
output = dateRegexp.ReplaceAllString(output, "")
assert.Equal(t, "[test.info] abcde12345\n", output)
if os.Getenv("CI") != "" {
consoleLogging()
}
}

func Test_LoggingVerbosity(t *testing.T) {
Startup(nil)
if os.Getenv("CI") != "" {
enableLogging()
}
LoggingSettings(nil, LogLevelMessage)

output := captureOutput(func() {
Expand All @@ -54,16 +45,10 @@ func Test_LoggingVerbosity(t *testing.T) {
govipsLog("test", LogLevelInfo, "fghji67890")
})
assert.Equal(t, "", output2)
if os.Getenv("CI") != "" {
consoleLogging()
}
}

func Test_LoggingHandler(t *testing.T) {
Startup(nil)
if os.Getenv("CI") != "" {
enableLogging()
}

var testDomain string
var testVerbosity LogLevel
Expand All @@ -79,7 +64,4 @@ func Test_LoggingHandler(t *testing.T) {
assert.Equal(t, "domain", testDomain)
assert.Equal(t, LogLevelCritical, testVerbosity)
assert.Equal(t, "abcde12345", testMessage)
if os.Getenv("CI") != "" {
consoleLogging()
}
}

0 comments on commit 5af43e7

Please sign in to comment.