From 44b3dd371b5f158a524ff4f09e320abfff3cefca Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Sat, 10 Feb 2024 17:11:41 -0800 Subject: [PATCH 1/2] ci: Test against Windows, Go 1.21, 1.22 Upgrade to Go 1.21, 1.22 since those are the two latest versions. Plus Fx supports Windows and has tests against it, so Dig should test against it too. --- .github/workflows/go.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6778b23e..5a900a71 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -13,11 +13,12 @@ permissions: jobs: build: - runs-on: ubuntu-latest - name: Test (Go ${{ matrix.go }}) + runs-on: ${{ matrix.os }} + name: Test (Go ${{ matrix.go }} / ${{ matrix.os }}) strategy: matrix: - go: ["1.20.x", "1.21.x"] + os: ["ubuntu-latest", "windows-latest"] + go: ["1.21.x", "1.22.x"] steps: - name: Setup Go @@ -48,7 +49,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: 1.22.x cache: false # managed by golangci-lint - uses: golangci/golangci-lint-action@v3 From 115ec1cac7117828ceb71c441b4036553e5fceb8 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Mon, 26 Feb 2024 05:16:56 -0800 Subject: [PATCH 2/2] Normalize line endings before comparison --- visualize_golden_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/visualize_golden_test.go b/visualize_golden_test.go index 99dcac35..c1b8faf9 100644 --- a/visualize_golden_test.go +++ b/visualize_golden_test.go @@ -36,20 +36,21 @@ var generate = flag.Bool("generate", false, "generates output to testdata/ if se func VerifyVisualization(t *testing.T, testname string, c *Container, opts ...VisualizeOption) { var b bytes.Buffer require.NoError(t, Visualize(c, &b, opts...)) + got := b.Bytes() + got = bytes.ReplaceAll(got, []byte("\r\n"), []byte("\n")) // normalize line endings dotFile := filepath.Join("testdata", testname+".dot") if *generate { - err := os.WriteFile(dotFile, b.Bytes(), 0o644) + err := os.WriteFile(dotFile, got, 0o644) require.NoError(t, err) return } - wantBytes, err := os.ReadFile(dotFile) + want, err := os.ReadFile(dotFile) require.NoError(t, err) + want = bytes.ReplaceAll(want, []byte("\r\n"), []byte("\n")) // normalize line endings - got := b.String() - want := string(wantBytes) - assert.Equal(t, want, got, + assert.Equal(t, string(want), string(got), "Output did not match. Make sure you updated the testdata by running 'go test -generate'") }