From 9e04858a9db6ae319133f2ff365c4a1c6a959df2 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Sun, 28 Apr 2024 14:38:09 +0100 Subject: [PATCH 1/2] Fix CI Size() reports different sizes on different systems. In particular, it reports larger sizes on Windows, so it would fail there. --- .github/workflows/test.yml | 12 ++++-------- go.mod | 2 +- go.sum | 4 ++-- toml_test.go | 17 +++++++++-------- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ec368b6..abf6360 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,31 +1,27 @@ { "name": "go test", - "on": ["push", "pull_request"], + "on": ["push"], "jobs": { "test": { "strategy": { "matrix": { - "go-version": ["1.18.x", "1.21.x"], + "go-version": ["1.18.x", "1.22.x"], "os": ["ubuntu-latest", "macos-latest", "windows-latest"] } }, "runs-on": "${{ matrix.os }}", "steps": [ { - "name": "Install Go", - "uses": "actions/setup-go@v2", + "uses": "actions/setup-go@v5", "with": {"go-version": "${{ matrix.go-version }}"} }, { - "name": "Checkout code", - "uses": "actions/checkout@v2" + "uses": "actions/checkout@v4" }, { - "name": "Test", "run": "go test -v ./..." }, { - "name": "Install", "run": "go install -v ./cmd/toml-test" } ] diff --git a/go.mod b/go.mod index c46ceff..6d589bd 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/toml-lang/toml-test go 1.18 require ( - github.com/BurntSushi/toml v1.3.3-0.20231207130039-4223137ff1f9 + github.com/BurntSushi/toml v1.3.3-0.20240103001115-0e879cbdab10 // no_term branch, which doesn't depend on x/term and x/sys zgo.at/zli v0.0.0-20231011155724-865ee344d4b3 ) diff --git a/go.sum b/go.sum index 1121976..2f20b8c 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ -github.com/BurntSushi/toml v1.3.3-0.20231207130039-4223137ff1f9 h1:lcDxyXwPxaYMIsFHL6UR/fzQouvVdaKpZh8zZRN+KlA= -github.com/BurntSushi/toml v1.3.3-0.20231207130039-4223137ff1f9/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/BurntSushi/toml v1.3.3-0.20240103001115-0e879cbdab10 h1:HfOzWIEwtJGprgjAGJdf0WSvoTaSU+tb4nIjGn4SKlA= +github.com/BurntSushi/toml v1.3.3-0.20240103001115-0e879cbdab10/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= zgo.at/zli v0.0.0-20231011155724-865ee344d4b3 h1:c6mOqJByLZGs0hmCK0Pr+XuDU6XoNcccUROX/8nPP6g= zgo.at/zli v0.0.0-20231011155724-865ee344d4b3/go.mod h1:HLAc12TjNGT+VRXr76JnsNE3pbooQtwKWhX+RlDjQ2Y= diff --git a/toml_test.go b/toml_test.go index 9aa6fa8..04108cf 100644 --- a/toml_test.go +++ b/toml_test.go @@ -123,12 +123,7 @@ func TestSize(t *testing.T) { if err != nil { return err } - - inf, err := d.Info() - if err != nil { - return err - } - if inf.IsDir() { + if d.IsDir() { return nil } if strings.Contains(path, "/spec-") || strings.Contains(path, "/spec/") { @@ -138,8 +133,14 @@ func TestSize(t *testing.T) { return nil } - if inf.Size() > 1024 { - t.Errorf("larger than 1K: %s (%fK)", path, float64(inf.Size())/1024) + // Don't use FileInfo.Size() as that reports inconsistent results on + // different platforms. + data, err := fs.ReadFile(EmbeddedTests(), path) + if err != nil { + return err + } + if l := len(data); l > 1024 { + t.Errorf("larger than 1K: %s (%fK)", path, float64(l)/1024) } return nil }) From c851219e1fc8c3a47a884d8140846e2cbe556b91 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Sun, 28 Apr 2024 15:05:59 +0100 Subject: [PATCH 2/2] Or not ... the fuck? --- toml_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toml_test.go b/toml_test.go index 04108cf..7554141 100644 --- a/toml_test.go +++ b/toml_test.go @@ -140,7 +140,8 @@ func TestSize(t *testing.T) { return err } if l := len(data); l > 1024 { - t.Errorf("larger than 1K: %s (%fK)", path, float64(l)/1024) + data, _ := fs.ReadFile(EmbeddedTests(), path) + t.Errorf("larger than 1K: %s (%fK)\n%v", path, float64(l)/1024, data) } return nil })