Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: make tests work on Windows, add Windows to CI #405

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/testdata/fuzz/** binary
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ name: Test
jobs:
test:
strategy:
fail-fast: false
matrix:
go-version: [1.17.x, 1.18.x]
# TODO(mvdan): fix and enable windows
# TODO(mvdan): mac seems to timeout too often
# os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
Expand Down
3 changes: 3 additions & 0 deletions schema/dmt/roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package schemadmt_test
import (
"bytes"
"io/ioutil"
"regexp"
"strings"
"testing"

Expand Down Expand Up @@ -30,6 +31,8 @@ func TestRoundtripSchemaSchema(t *testing.T) {
func testRoundtrip(t *testing.T, want string, updateFn func(string)) {
t.Helper()

crre := regexp.MustCompile(`\r?\n`)
want = crre.ReplaceAllString(want, "\n")
nb := schemadmt.Type.Schema.Representation().NewBuilder()
err := ipldjson.Decode(nb, strings.NewReader(want))
qt.Assert(t, err, qt.IsNil)
Expand Down
9 changes: 6 additions & 3 deletions schema/dsl/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"io/ioutil"
"path/filepath"
"regexp"
"strings"
"testing"

Expand Down Expand Up @@ -76,9 +77,7 @@ func TestParse(t *testing.T) {
err = yaml.Unmarshal(data, &fixt)
qt.Assert(t, err, qt.IsNil)

inJSON := strings.Replace(fixt.Expected, " ", "\t", -1)

testParse(t, fixt.Schema, inJSON, func(updated string) {
testParse(t, fixt.Schema, fixt.Expected, func(updated string) {
updated = strings.Replace(updated, "\t", " ", -1)
fixt.Expected = updated

Expand All @@ -97,6 +96,10 @@ func TestParse(t *testing.T) {
func testParse(t *testing.T, inSchema, inJSON string, updateFn func(string)) {
t.Helper()

inJSON = strings.Replace(inJSON, " ", "\t", -1) // fix non-tab indenting
crre := regexp.MustCompile(`\r?\n`)
inJSON = crre.ReplaceAllString(inJSON, "\n") // fix windows carriage-return

sch, err := schemadsl.ParseBytes([]byte(inSchema))
qt.Assert(t, err, qt.IsNil)

Expand Down
2 changes: 1 addition & 1 deletion schema/gen/go/externUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"go/ast"
"go/parser"
"go/token"
"path"
path "path/filepath"
"strings"
)

Expand Down
4 changes: 2 additions & 2 deletions schema/gen/go/testEngine_disabled_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build skipgenbehavtests
// +build skipgenbehavtests
//go:build skipgenbehavtests || windows
// +build skipgenbehavtests windows

package gengo

Expand Down
4 changes: 2 additions & 2 deletions schema/gen/go/testEngine_plugin_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build cgo && !skipgenbehavtests
// +build cgo,!skipgenbehavtests
//go:build cgo && !skipgenbehavtests && !windows
// +build cgo,!skipgenbehavtests,!windows

package gengo

Expand Down
8 changes: 7 additions & 1 deletion traversal/selector/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package selector_test
import (
"bytes"
"io"
"io/ioutil"
"os"
"regexp"
"testing"

qt "github.com/frankban/quicktest"
Expand All @@ -25,7 +27,11 @@ func TestSpecFixtures(t *testing.T) {
}

func testOneSpecFixtureFile(t *testing.T, filename string) {
doc, err := testmark.ReadFile(filename)
data, err := ioutil.ReadFile(filename)
crre := regexp.MustCompile(`\r?\n`)
data = []byte(crre.ReplaceAllString(string(data), "\n")) // fix windows carriage-return

doc, err := testmark.Parse(data)
if os.IsNotExist(err) {
t.Skipf("not running spec suite: %s (did you clone the submodule with the data?)", err)
}
Expand Down