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 13, 2024
1 parent 30c70fd commit d164eca
Show file tree
Hide file tree
Showing 26 changed files with 23 additions and 14 deletions.
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")
}
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.
Binary file removed plotter/testdata/horizontalBarChart_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.
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.

0 comments on commit d164eca

Please sign in to comment.