From b4ccdc75114bb5204e35eeb7ee131a4e08d6384c Mon Sep 17 00:00:00 2001 From: dmullis Date: Tue, 18 Jun 2024 21:38:15 -0700 Subject: [PATCH] Regression testing: Clarify source code and CLI text Bump required Go version to 1.21 for access to functions min() and max(). --- .github/workflows/test.yml | 2 +- examples_test.go | 44 ++++++++++++++++++++++++-------------- go.mod | 2 +- pre-push.sh | 2 ++ 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9d5ecbc..b92e1e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: build: strategy: matrix: - go-version: [1.20.x] + go-version: [1.21.x] os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: diff --git a/examples_test.go b/examples_test.go index 1ac709a..17e56a4 100644 --- a/examples_test.go +++ b/examples_test.go @@ -14,7 +14,8 @@ import ( ) var ( - write = flag.Bool("write", false, "write examples to disk") // XX rename: more descriptive + write = flag.Bool("write", + false, "write reference SVG output files") svgColorLightScheme = flag.String("svg-color-light-scheme", "#000000", `See help for cmd/goat`) svgColorDarkScheme = flag.String("svg-color-dark-scheme", "#FFFFFF", @@ -50,7 +51,7 @@ func TestExamples(t *testing.T) { var buff *bytes.Buffer if write == nil { - t.Logf("Verifying output of current build against earlier .svg files in examples/.\n") + t.Logf("Verifying equality of current SVG with examples/ references.\n") } var failures int for _, name := range filenames { @@ -83,15 +84,26 @@ func TestExamples(t *testing.T) { if err != nil { t.Log(err) } - if buff.String() != golden { - // XX Skip this if the modification timestamp of the .txt file - // source is fresher than the .svg? - t.Log(buff.Len(), len(golden)) - t.Logf("Content mismatch for %s", toSVGFilename(name)) + if newStr := buff.String(); newStr != golden { + // Skip complaint if the modification timestamp of the .txt file + // source is fresher than that of the .svg? + // => NO, Any .txt difference might be an editing mistake. + + t.Logf("Content mismatch for %s. Length was %d, expected %d", + toSVGFilename(name), buff.Len(), len(golden)) + for i:=0; iREADME.md $(git-ls-files examples | tac) + +printf "\nTo install in local GOPATH:\n\t%s\n" "go install ./cmd/goat"