Skip to content

Commit

Permalink
all: split golden images based on GOARCH
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed Jun 16, 2024
1 parent caf665d commit 4e82ce6
Show file tree
Hide file tree
Showing 38 changed files with 1,657 additions and 21 deletions.
2 changes: 2 additions & 0 deletions cmpimg/checkplot.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ func goldenPath(path string) string {
// For image.Image formats, a base64 encoded png representation is output to
// the testing log when a difference is identified.
func CheckPlot(ExampleFunc func(), t *testing.T, filenames ...string) {
t.Helper()

CheckPlotApprox(ExampleFunc, t, 0, filenames...)
}

Expand Down
5 changes: 3 additions & 2 deletions plot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"image/color"
"math"
"os"
"runtime"
"testing"
"time"

Expand Down Expand Up @@ -182,9 +183,9 @@ func TestDrawGlyphBoxes(t *testing.T) {
t.Fatalf("error: %+v", err)
}

err = os.WriteFile("testdata/glyphbox.png", buf.Bytes(), 0644)
err = os.WriteFile("testdata/glyphbox_"+runtime.GOARCH+".png", buf.Bytes(), 0644)
if err != nil {
t.Fatalf("could not save plot: %+v", err)
}
}, t, "glyphbox.png")
}, t, "glyphbox_"+runtime.GOARCH+".png")
}
3 changes: 2 additions & 1 deletion plotter/barchart_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package plotter_test
import (
"image/color"
"log"
"runtime"

"golang.org/x/exp/rand"

Expand Down Expand Up @@ -43,7 +44,7 @@ func ExampleBarChart() {
}
p2.Add(horizontalBarChart)
p2.NominalY(horizontalLabels...)
err = p2.Save(100, 100, "testdata/horizontalBarChart.png")
err = p2.Save(100, 100, "testdata/horizontalBarChart_"+runtime.GOARCH+".png")
if err != nil {
log.Panic(err)
}
Expand Down
3 changes: 2 additions & 1 deletion plotter/barchart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
package plotter_test

import (
"runtime"
"testing"

"gonum.org/v1/plot/cmpimg"
)

func TestBarChart(t *testing.T) {
cmpimg.CheckPlot(ExampleBarChart, t, "verticalBarChart.png",
"horizontalBarChart.png", "barChart2.png",
"horizontalBarChart_"+runtime.GOARCH+".png", "barChart2.png",
"stackedBarChart.png")
}

Expand Down
5 changes: 3 additions & 2 deletions plotter/contour_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package plotter_test
import (
"log"
"math"
"runtime"
"testing"

"golang.org/x/exp/rand"
Expand Down Expand Up @@ -51,7 +52,7 @@ func ExampleContour() {

p.Add(c)

err := p.Save(10*vg.Centimeter, 10*vg.Centimeter, "testdata/contour.png")
err := p.Save(10*vg.Centimeter, 10*vg.Centimeter, "testdata/contour_"+runtime.GOARCH+".png")
if err != nil {
log.Fatalf("could not save plot: %+v", err)
}
Expand All @@ -77,5 +78,5 @@ func (g unitGrid) Y(r int) float64 {
}

func TestContour(t *testing.T) {
cmpimg.CheckPlotApprox(ExampleContour, t, 0.01, "contour.png")
cmpimg.CheckPlotApprox(ExampleContour, t, 0.01, "contour_"+runtime.GOARCH+".png")
}
7 changes: 4 additions & 3 deletions plotter/labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package plotter_test

import (
"image/color"
"runtime"
"testing"

"gonum.org/v1/plot"
Expand Down Expand Up @@ -145,11 +146,11 @@ func TestLabelsWithGlyphBoxes(t *testing.T) {
p.Add(plotter.NewGrid())
p.Add(plotter.NewGlyphBoxes())

err = p.Save(10*vg.Centimeter, 10*vg.Centimeter, "testdata/labels_glyphboxes.png")
err = p.Save(10*vg.Centimeter, 10*vg.Centimeter, "testdata/labels_glyphboxes_"+runtime.GOARCH+".png")
if err != nil {
t.Fatalf("could save plot: %+v", err)
t.Fatalf("could not save plot: %+v", err)
}
},
t, "labels_glyphboxes.png",
t, "labels_glyphboxes_"+runtime.GOARCH+".png",
)
}
3 changes: 2 additions & 1 deletion plotter/precision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package plotter_test

import (
"log"
"runtime"
"testing"

"gonum.org/v1/plot"
Expand All @@ -14,7 +15,7 @@ import (
)

func TestFloatPrecision(t *testing.T) {
const fname = "precision.png"
const fname = "precision_" + runtime.GOARCH + ".png"

cmpimg.CheckPlot(func() {
p := plot.New()
Expand Down
3 changes: 2 additions & 1 deletion plotter/rotation_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"image/color"
"log"
"math"
"runtime"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
Expand Down Expand Up @@ -92,7 +93,7 @@ func Example_rotation() {
p.Y.Tick.Label.XAlign = draw.XCenter
p.Y.Tick.Label.YAlign = draw.YBottom

err = p.Save(200, 150, "testdata/rotation.png")
err = p.Save(200, 150, "testdata/rotation_"+runtime.GOARCH+".png")
if err != nil {
log.Panic(err)
}
Expand Down
3 changes: 2 additions & 1 deletion plotter/rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
package plotter_test

import (
"runtime"
"testing"

"gonum.org/v1/plot/cmpimg"
)

func TestRotation(t *testing.T) {
cmpimg.CheckPlot(Example_rotation, t, "rotation.png")
cmpimg.CheckPlot(Example_rotation, t, "rotation_"+runtime.GOARCH+".png")
}
3 changes: 2 additions & 1 deletion plotter/sankey_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"image/color"
"log"
"os"
"runtime"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
Expand Down Expand Up @@ -396,7 +397,7 @@ func ExampleSankey_grouped() {

p.Draw(dc)
pngimg := vgimg.PngCanvas{Canvas: c}
f, err := os.Create("testdata/sankeyGrouped.png")
f, err := os.Create("testdata/sankeyGrouped_" + runtime.GOARCH + ".png")
if err != nil {
log.Panic(err)
}
Expand Down
3 changes: 2 additions & 1 deletion plotter/sankey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package plotter_test

import (
"runtime"
"testing"

"gonum.org/v1/plot"
Expand All @@ -20,7 +21,7 @@ func TestSankey_simple(t *testing.T) {
}

func TestSankey_grouped(t *testing.T) {
cmpimg.CheckPlot(ExampleSankey_grouped, t, "sankeyGrouped.png")
cmpimg.CheckPlot(ExampleSankey_grouped, t, "sankeyGrouped_"+runtime.GOARCH+".png")
}

// This test checks whether the Sankey plotter makes any changes to
Expand Down
Binary file added plotter/testdata/contour_amd64_golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plotter/testdata/contour_arm64_golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed plotter/testdata/contour_golden.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added plotter/testdata/precision_arm64_golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added plotter/testdata/rotation_arm64_golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added testdata/glyphbox_arm64_golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions text/latex_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"image/color"
"log"
"math"
"runtime"
"testing"

"gonum.org/v1/plot"
Expand Down Expand Up @@ -74,12 +75,12 @@ func ExampleLatex() {
p.Add(plotter.NewGlyphBoxes())
p.Add(plotter.NewGrid())

err = p.Save(10*vg.Centimeter, 5*vg.Centimeter, "testdata/latex.png")
err = p.Save(10*vg.Centimeter, 5*vg.Centimeter, "testdata/latex_"+runtime.GOARCH+".png")
if err != nil {
log.Fatalf("could not save plot: %+v", err)
}
}

func TestLatex(t *testing.T) {
cmpimg.CheckPlot(ExampleLatex, t, "latex.png")
cmpimg.CheckPlot(ExampleLatex, t, "latex_"+runtime.GOARCH+".png")
}
File renamed without changes
Binary file added text/testdata/latex_arm64_golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vg/vggio/testdata/func_golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion vg/vgtex/canvas_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"image/color"
"log"
"os"
"runtime"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
Expand Down Expand Up @@ -52,7 +53,7 @@ func Example() {
c.SetColor(color.Black)
c.FillString(txtFont, vg.Point{X: 2.5 * vg.Centimeter, Y: 2.5 * vg.Centimeter}, "x")

f, err := os.Create("testdata/scatter.tex")
f, err := os.Create("testdata/scatter_" + runtime.GOARCH + ".tex")
if err != nil {
log.Fatal(err)
}
Expand Down
9 changes: 5 additions & 4 deletions vg/vgtex/canvas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package vgtex_test

import (
"image/color"
"runtime"
"testing"

"gonum.org/v1/plot"
Expand All @@ -15,7 +16,7 @@ import (
)

func TestTexCanvas(t *testing.T) {
cmpimg.CheckPlot(Example, t, "scatter.tex")
cmpimg.CheckPlot(Example, t, "scatter_"+runtime.GOARCH+".tex")
}

func TestLineLatex(t *testing.T) {
Expand Down Expand Up @@ -58,7 +59,7 @@ func TestLineLatex(t *testing.T) {
}
}
}
cmpimg.CheckPlot(test("testdata/linestyle.tex"), t, "linestyle.tex")
cmpimg.CheckPlot(test("testdata/linestyle_"+runtime.GOARCH+".tex"), t, "linestyle_"+runtime.GOARCH+".tex")
cmpimg.CheckPlot(test("testdata/linestyle.png"), t, "linestyle.png")
}

Expand All @@ -85,9 +86,9 @@ func TestFillStyle(t *testing.T) {
p.Legend.Add("h", h)

const size = 5 * vg.Centimeter
err = p.Save(size, size, "testdata/fillstyle.tex")
err = p.Save(size, size, "testdata/fillstyle_"+runtime.GOARCH+".tex")
if err != nil {
t.Fatalf("error: %+v", err)
}
}, t, "fillstyle.tex")
}, t, "fillstyle_"+runtime.GOARCH+".tex")
}
File renamed without changes.
Loading

0 comments on commit 4e82ce6

Please sign in to comment.