Skip to content

Commit 6710bc5

Browse files
committed
all: split golden images based on GOARCH
1 parent 30c70fd commit 6710bc5

37 files changed

+1657
-21
lines changed

cmpimg/checkplot.go

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ func goldenPath(path string) string {
2929
// For image.Image formats, a base64 encoded png representation is output to
3030
// the testing log when a difference is identified.
3131
func CheckPlot(ExampleFunc func(), t *testing.T, filenames ...string) {
32+
t.Helper()
33+
3234
CheckPlotApprox(ExampleFunc, t, 0, filenames...)
3335
}
3436

plot_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"image/color"
1111
"math"
1212
"os"
13+
"runtime"
1314
"testing"
1415
"time"
1516

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

185-
err = os.WriteFile("testdata/glyphbox.png", buf.Bytes(), 0644)
186+
err = os.WriteFile("testdata/glyphbox_"+runtime.GOARCH+".png", buf.Bytes(), 0644)
186187
if err != nil {
187188
t.Fatalf("could not save plot: %+v", err)
188189
}
189-
}, t, "glyphbox.png")
190+
}, t, "glyphbox_"+runtime.GOARCH+".png")
190191
}

plotter/barchart_example_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package plotter_test
77
import (
88
"image/color"
99
"log"
10+
"runtime"
1011

1112
"golang.org/x/exp/rand"
1213

@@ -43,7 +44,7 @@ func ExampleBarChart() {
4344
}
4445
p2.Add(horizontalBarChart)
4546
p2.NominalY(horizontalLabels...)
46-
err = p2.Save(100, 100, "testdata/horizontalBarChart.png")
47+
err = p2.Save(100, 100, "testdata/horizontalBarChart_"+runtime.GOARCH+".png")
4748
if err != nil {
4849
log.Panic(err)
4950
}

plotter/barchart_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
package plotter_test
66

77
import (
8+
"runtime"
89
"testing"
910

1011
"gonum.org/v1/plot/cmpimg"
1112
)
1213

1314
func TestBarChart(t *testing.T) {
1415
cmpimg.CheckPlot(ExampleBarChart, t, "verticalBarChart.png",
15-
"horizontalBarChart.png", "barChart2.png",
16+
"horizontalBarChart_"+runtime.GOARCH+".png", "barChart2.png",
1617
"stackedBarChart.png")
1718
}
1819

plotter/contour_example_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package plotter_test
77
import (
88
"log"
99
"math"
10+
"runtime"
1011
"testing"
1112

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

5253
p.Add(c)
5354

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

7980
func TestContour(t *testing.T) {
80-
cmpimg.CheckPlotApprox(ExampleContour, t, 0.01, "contour.png")
81+
cmpimg.CheckPlotApprox(ExampleContour, t, 0.01, "contour_"+runtime.GOARCH+".png")
8182
}

plotter/labels_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package plotter_test
66

77
import (
88
"image/color"
9+
"runtime"
910
"testing"
1011

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

148-
err = p.Save(10*vg.Centimeter, 10*vg.Centimeter, "testdata/labels_glyphboxes.png")
149+
err = p.Save(10*vg.Centimeter, 10*vg.Centimeter, "testdata/labels_glyphboxes_"+runtime.GOARCH+".png")
149150
if err != nil {
150-
t.Fatalf("could save plot: %+v", err)
151+
t.Fatalf("could not save plot: %+v", err)
151152
}
152153
},
153-
t, "labels_glyphboxes.png",
154+
t, "labels_glyphboxes_"+runtime.GOARCH+".png",
154155
)
155156
}

plotter/precision_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package plotter_test
66

77
import (
88
"log"
9+
"runtime"
910
"testing"
1011

1112
"gonum.org/v1/plot"
@@ -14,7 +15,7 @@ import (
1415
)
1516

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

1920
cmpimg.CheckPlot(func() {
2021
p := plot.New()

plotter/rotation_example_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"image/color"
99
"log"
1010
"math"
11+
"runtime"
1112

1213
"gonum.org/v1/plot"
1314
"gonum.org/v1/plot/plotter"
@@ -92,7 +93,7 @@ func Example_rotation() {
9293
p.Y.Tick.Label.XAlign = draw.XCenter
9394
p.Y.Tick.Label.YAlign = draw.YBottom
9495

95-
err = p.Save(200, 150, "testdata/rotation.png")
96+
err = p.Save(200, 150, "testdata/rotation_"+runtime.GOARCH+".png")
9697
if err != nil {
9798
log.Panic(err)
9899
}

plotter/rotation_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
package plotter_test
66

77
import (
8+
"runtime"
89
"testing"
910

1011
"gonum.org/v1/plot/cmpimg"
1112
)
1213

1314
func TestRotation(t *testing.T) {
14-
cmpimg.CheckPlot(Example_rotation, t, "rotation.png")
15+
cmpimg.CheckPlot(Example_rotation, t, "rotation_"+runtime.GOARCH+".png")
1516
}

plotter/sankey_example_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"image/color"
1010
"log"
1111
"os"
12+
"runtime"
1213

1314
"gonum.org/v1/plot"
1415
"gonum.org/v1/plot/plotter"
@@ -396,7 +397,7 @@ func ExampleSankey_grouped() {
396397

397398
p.Draw(dc)
398399
pngimg := vgimg.PngCanvas{Canvas: c}
399-
f, err := os.Create("testdata/sankeyGrouped.png")
400+
f, err := os.Create("testdata/sankeyGrouped_" + runtime.GOARCH + ".png")
400401
if err != nil {
401402
log.Panic(err)
402403
}

plotter/sankey_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package plotter_test
66

77
import (
8+
"runtime"
89
"testing"
910

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

2223
func TestSankey_grouped(t *testing.T) {
23-
cmpimg.CheckPlot(ExampleSankey_grouped, t, "sankeyGrouped.png")
24+
cmpimg.CheckPlot(ExampleSankey_grouped, t, "sankeyGrouped_"+runtime.GOARCH+".png")
2425
}
2526

2627
// This test checks whether the Sankey plotter makes any changes to
85.9 KB
Loading
87.3 KB
Loading

plotter/testdata/contour_golden.png

-86 KB
Binary file not shown.
Loading
Loading
6.93 KB
Loading
23.4 KB
Loading
Loading
File renamed without changes.

testdata/glyphbox_arm64_golden.png

15.7 KB
Loading

text/latex_example_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"image/color"
99
"log"
1010
"math"
11+
"runtime"
1112
"testing"
1213

1314
"gonum.org/v1/plot"
@@ -74,12 +75,12 @@ func ExampleLatex() {
7475
p.Add(plotter.NewGlyphBoxes())
7576
p.Add(plotter.NewGrid())
7677

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

8384
func TestLatex(t *testing.T) {
84-
cmpimg.CheckPlot(ExampleLatex, t, "latex.png")
85+
cmpimg.CheckPlot(ExampleLatex, t, "latex_"+runtime.GOARCH+".png")
8586
}
File renamed without changes.

text/testdata/latex_arm64_golden.png

13.5 KB
Loading

vg/vgtex/canvas_example_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"image/color"
99
"log"
1010
"os"
11+
"runtime"
1112

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

55-
f, err := os.Create("testdata/scatter.tex")
56+
f, err := os.Create("testdata/scatter_" + runtime.GOARCH + ".tex")
5657
if err != nil {
5758
log.Fatal(err)
5859
}

vg/vgtex/canvas_test.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package vgtex_test
66

77
import (
88
"image/color"
9+
"runtime"
910
"testing"
1011

1112
"gonum.org/v1/plot"
@@ -15,7 +16,7 @@ import (
1516
)
1617

1718
func TestTexCanvas(t *testing.T) {
18-
cmpimg.CheckPlot(Example, t, "scatter.tex")
19+
cmpimg.CheckPlot(Example, t, "scatter_"+runtime.GOARCH+".tex")
1920
}
2021

2122
func TestLineLatex(t *testing.T) {
@@ -58,7 +59,7 @@ func TestLineLatex(t *testing.T) {
5859
}
5960
}
6061
}
61-
cmpimg.CheckPlot(test("testdata/linestyle.tex"), t, "linestyle.tex")
62+
cmpimg.CheckPlot(test("testdata/linestyle_"+runtime.GOARCH+".tex"), t, "linestyle_"+runtime.GOARCH+".tex")
6263
cmpimg.CheckPlot(test("testdata/linestyle.png"), t, "linestyle.png")
6364
}
6465

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

8788
const size = 5 * vg.Centimeter
88-
err = p.Save(size, size, "testdata/fillstyle.tex")
89+
err = p.Save(size, size, "testdata/fillstyle_"+runtime.GOARCH+".tex")
8990
if err != nil {
9091
t.Fatalf("error: %+v", err)
9192
}
92-
}, t, "fillstyle.tex")
93+
}, t, "fillstyle_"+runtime.GOARCH+".tex")
9394
}

0 commit comments

Comments
 (0)