diff --git a/.travis.yml b/.travis.yml index ba01644..16f237a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,22 @@ +os: + - linux + +sudo: false + language: go go: - - tip - - 1.6 + - 1.9.x + +install: + - make deps script: - - go get github.com/whyrusleeping/gx - - go get github.com/whyrusleeping/gx-go - - gx --verbose install - - gx-go rewrite - - go test ./... - # - go test -race -cpu=5 ./... + - bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh) + +cache: + directories: + - $GOPATH/src/gx + +notifications: + email: false diff --git a/Makefile b/Makefile index 03b2d8a..5c99609 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,13 @@ +all: deps -build: deps - go build ./... - -test: deps - go test ./... - -test_race: deps - go test -race -cpu 5 ./... - -gx-bins: +gx: go get github.com/whyrusleeping/gx go get github.com/whyrusleeping/gx-go -deps: gx-bins +deps: gx gx --verbose install --global gx-go rewrite -clean: gx-bins +publish: gx-go rewrite --undo + diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..5f88a9e --- /dev/null +++ b/codecov.yml @@ -0,0 +1,3 @@ +coverage: + range: "50...100" +comment: off diff --git a/suite/suite_test.go b/suite/suite_test.go deleted file mode 100644 index ba5d025..0000000 --- a/suite/suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package test_all - -import ( - "testing" - - multiplex "github.com/whyrusleeping/go-smux-multiplex" - multistream "github.com/whyrusleeping/go-smux-multistream" - muxado "github.com/whyrusleeping/go-smux-muxado" - spdy "github.com/whyrusleeping/go-smux-spdystream" - yamux "github.com/whyrusleeping/go-smux-yamux" - - ttest "github.com/libp2p/go-stream-muxer/test" -) - -func TestYamux(t *testing.T) { - ttest.SubtestAll(t, yamux.DefaultTransport) -} - -func TestMultistream(t *testing.T) { - tpt := multistream.NewBlankTransport() - tpt.AddTransport("/yamux", yamux.DefaultTransport) - ttest.SubtestAll(t, tpt) -} - -func TestMuxado(t *testing.T) { - ttest.SubtestAll(t, muxado.Transport) -} - -func TestMultiplex(t *testing.T) { - ttest.SubtestAll(t, multiplex.DefaultTransport) -} - -func TestSpdystream(t *testing.T) { - ttest.SubtestAll(t, spdy.Transport) -} diff --git a/test/ttest.go b/test/ttest.go index 07ffc54..f77756f 100644 --- a/test/ttest.go +++ b/test/ttest.go @@ -151,7 +151,7 @@ func SubtestSimpleWrite(t *testing.T, tr smux.Transport) { checkErr(t, err) if string(buf2) != string(buf1) { - t.Error("buf1 and buf2 not equal: %s != %s", string(buf1), string(buf2)) + t.Errorf("buf1 and buf2 not equal: %s != %s", string(buf1), string(buf2)) } log("done") } @@ -508,33 +508,33 @@ func SubtestStress1Conn100Stream100Msg10MB(t *testing.T, tr smux.Transport) { }) } -func SubtestAll(t *testing.T, tr smux.Transport) { +// Subtests are all the subtests run by SubtestAll +var Subtests = []TransportTest{ + SubtestSimpleWrite, + SubtestWriteAfterClose, + SubtestStress1Conn1Stream1Msg, + SubtestStress1Conn1Stream100Msg, + SubtestStress1Conn100Stream100Msg, + SubtestStress50Conn10Stream50Msg, + SubtestStress1Conn1000Stream10Msg, + SubtestStress1Conn100Stream100Msg10MB, + SubtestStreamOpenStress, + SubtestStreamReset, +} - tests := []TransportTest{ - SubtestSimpleWrite, - SubtestWriteAfterClose, - SubtestStress1Conn1Stream1Msg, - SubtestStress1Conn1Stream100Msg, - SubtestStress1Conn100Stream100Msg, - SubtestStress50Conn10Stream50Msg, - SubtestStress1Conn1000Stream10Msg, - SubtestStress1Conn100Stream100Msg10MB, - SubtestStreamOpenStress, - SubtestStreamReset, - } +func getFunctionName(i interface{}) string { + return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name() +} - for _, f := range tests { - if testing.Verbose() { - fmt.Fprintf(os.Stderr, "==== RUN %s\n", GetFunctionName(f)) - } - f(t, tr) +// SubtestAll runs all the stream multiplexer tests against the target +// transport. +func SubtestAll(t *testing.T, tr smux.Transport) { + for _, f := range Subtests { + t.Run(getFunctionName(f), func(t *testing.T) { + f(t, tr) + }) } } +// TransportTest is a stream multiplex transport test case type TransportTest func(t *testing.T, tr smux.Transport) - -func TestNoOp(t *testing.T) {} - -func GetFunctionName(i interface{}) string { - return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name() -}