From fb2d1452c7da698cf768c804a2e1885e25bd8f79 Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:03:45 -0500 Subject: [PATCH 01/13] Add coveralls support to travis. --- .travis.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 816a977..f10894c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,18 @@ go: - 1.8 - tip -script: go test -v -test.run='BCD|Parse' ./... +install: + - go get golang.org/x/tools/cmd/cover + - go get github.com/mattn/goveralls + +script: + - go test -v -covermode=count -coverprofile=coverage.out -test.run='BCD|Parse' ./... + - $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN addons: apt: packages: libusb-1.0-0-dev + +# COVERALLS_TOKEN +secure: "jXueELysh+Zq1YZAIlHdorCANZKQL/6hRTaSLDJGeLwKnZPwKvLsn7FucNsPZ7KAL1DM8Ij7YciQOirgrKng2+KMCTgoB05erFn/Fq/cYxtIkHHE1yy0m4Iqy6q2Ttq/Lhw16Hni03Om4whX0q3W5Yk+aZTeOjKWOMoSrGTrrw7y2tqLUwBLOpl54yYk5dSJ3apPdawLFhi+DfPK4ss6qbEzN4n+g9hJJYmKSXynpcHdVCKZkVJdgVz9mm6vPRlyDVoQNfzCm015eikRigQFagSN/tYs6NtOKIPeiM820GhGsda7TXYjuqYxB3XRZkfq+o0IexPbsaSnNPDjKyB9CUAOndhJtGotRu9BnXBxLXwn3/tUzCT98cB9Sv8S826askalGTXeKr5Wv+oRjkcMUJlrh4xoXJR9gFRcLA4vOnS0fbf5snFwFwskiKNh5grKJoG5QJATTfubMAZHHApNLFcK94Zt7n4TdsE+Ui6uKkrARjIHEonCu6h8xVJA2DUfOKKtayn12b6rn3AhDCiab5YnOh8EI87McAfqYIsFse6k+PvCHIqSj6N6am1AY+Sjs9K/SbXJcwE15MwRP/Q76dsnLCsUuSOVmjbPe+Uix1PBnwd1zXIFrMxxjpLBaf5YGVH1ZfBGR6TmNJZmeCryXdpLGxGij3h1ooHMYhtdtE8=" From 5af7134a365455c6a7d7d7e65688657ebe070b2a Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:09:05 -0500 Subject: [PATCH 02/13] move the coveralls token to env --- .travis.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index f10894c..8c4db16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,20 @@ language: go dist: trusty +env: + # COVERALLS_TOKEN + secure: "jXueELysh+Zq1YZAIlHdorCANZKQL/6hRTaSLDJGeLwKnZPwKvLsn7FucNsPZ7KAL1DM8Ij7YciQOirgrKng2+KMCTgoB05erFn/Fq/cYxtIkHHE1yy0m4Iqy6q2Ttq/Lhw16Hni03Om4whX0q3W5Yk+aZTeOjKWOMoSrGTrrw7y2tqLUwBLOpl54yYk5dSJ3apPdawLFhi+DfPK4ss6qbEzN4n+g9hJJYmKSXynpcHdVCKZkVJdgVz9mm6vPRlyDVoQNfzCm015eikRigQFagSN/tYs6NtOKIPeiM820GhGsda7TXYjuqYxB3XRZkfq+o0IexPbsaSnNPDjKyB9CUAOndhJtGotRu9BnXBxLXwn3/tUzCT98cB9Sv8S826askalGTXeKr5Wv+oRjkcMUJlrh4xoXJR9gFRcLA4vOnS0fbf5snFwFwskiKNh5grKJoG5QJATTfubMAZHHApNLFcK94Zt7n4TdsE+Ui6uKkrARjIHEonCu6h8xVJA2DUfOKKtayn12b6rn3AhDCiab5YnOh8EI87McAfqYIsFse6k+PvCHIqSj6N6am1AY+Sjs9K/SbXJcwE15MwRP/Q76dsnLCsUuSOVmjbPe+Uix1PBnwd1zXIFrMxxjpLBaf5YGVH1ZfBGR6TmNJZmeCryXdpLGxGij3h1ooHMYhtdtE8=" + go: - 1.7 - 1.8 - tip +addons: + apt: + packages: + libusb-1.0-0-dev + install: - go get golang.org/x/tools/cmd/cover - go get github.com/mattn/goveralls @@ -14,10 +23,3 @@ script: - go test -v -covermode=count -coverprofile=coverage.out -test.run='BCD|Parse' ./... - $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN -addons: - apt: - packages: - libusb-1.0-0-dev - -# COVERALLS_TOKEN -secure: "jXueELysh+Zq1YZAIlHdorCANZKQL/6hRTaSLDJGeLwKnZPwKvLsn7FucNsPZ7KAL1DM8Ij7YciQOirgrKng2+KMCTgoB05erFn/Fq/cYxtIkHHE1yy0m4Iqy6q2Ttq/Lhw16Hni03Om4whX0q3W5Yk+aZTeOjKWOMoSrGTrrw7y2tqLUwBLOpl54yYk5dSJ3apPdawLFhi+DfPK4ss6qbEzN4n+g9hJJYmKSXynpcHdVCKZkVJdgVz9mm6vPRlyDVoQNfzCm015eikRigQFagSN/tYs6NtOKIPeiM820GhGsda7TXYjuqYxB3XRZkfq+o0IexPbsaSnNPDjKyB9CUAOndhJtGotRu9BnXBxLXwn3/tUzCT98cB9Sv8S826askalGTXeKr5Wv+oRjkcMUJlrh4xoXJR9gFRcLA4vOnS0fbf5snFwFwskiKNh5grKJoG5QJATTfubMAZHHApNLFcK94Zt7n4TdsE+Ui6uKkrARjIHEonCu6h8xVJA2DUfOKKtayn12b6rn3AhDCiab5YnOh8EI87McAfqYIsFse6k+PvCHIqSj6N6am1AY+Sjs9K/SbXJcwE15MwRP/Q76dsnLCsUuSOVmjbPe+Uix1PBnwd1zXIFrMxxjpLBaf5YGVH1ZfBGR6TmNJZmeCryXdpLGxGij3h1ooHMYhtdtE8=" From 13a23edf37a29df35399471f270444268cc6c494 Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:17:50 -0500 Subject: [PATCH 03/13] go does not support coverage when testing multiple packages. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8c4db16..ac428cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,6 @@ install: - go get github.com/mattn/goveralls script: - - go test -v -covermode=count -coverprofile=coverage.out -test.run='BCD|Parse' ./... - - $HOME/gopath/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN - + # a workaround for go test not supporting coverage for multiple packages in a single invocation + - echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c 'go test -covermode=count -coverprofile=coverage.tmp -test.run="BCD|Parse" {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp + - $HOME/gopath/bin/goveralls -coverprofile=coverage.merged -service=travis-ci -repotoken $COVERALLS_TOKEN From da066a3744788918cc99d23777ee306ada4d98ce Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:20:34 -0500 Subject: [PATCH 04/13] different escaping --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ac428cb..4d64e4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,5 +21,5 @@ install: script: # a workaround for go test not supporting coverage for multiple packages in a single invocation - - echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c 'go test -covermode=count -coverprofile=coverage.tmp -test.run="BCD|Parse" {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp + - sh -c "echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c 'go test -covermode=count -coverprofile=coverage.tmp -test.run=BCD\|Parse {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp" - $HOME/gopath/bin/goveralls -coverprofile=coverage.merged -service=travis-ci -repotoken $COVERALLS_TOKEN From 9f8cb55a00645ff0790f531ad4fb3b78ff95e919 Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:26:29 -0500 Subject: [PATCH 05/13] yet another way to escape... --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4d64e4f..be79fc2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,5 +21,6 @@ install: script: # a workaround for go test not supporting coverage for multiple packages in a single invocation - - sh -c "echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c 'go test -covermode=count -coverprofile=coverage.tmp -test.run=BCD\|Parse {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp" + - |- + echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c 'go test -covermode=count -coverprofile=coverage.tmp -test.run="BCD|Parse" {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp - $HOME/gopath/bin/goveralls -coverprofile=coverage.merged -service=travis-ci -repotoken $COVERALLS_TOKEN From d6f93e15ab9a8f740e48c71b90040b04d4dd0a2b Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:28:58 -0500 Subject: [PATCH 06/13] always create the tmp file --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index be79fc2..41ef5cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,5 +22,5 @@ install: script: # a workaround for go test not supporting coverage for multiple packages in a single invocation - |- - echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c 'go test -covermode=count -coverprofile=coverage.tmp -test.run="BCD|Parse" {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp + echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c ': > coverage.tmp; go test -covermode=count -coverprofile=coverage.tmp -test.run="BCD|Parse" {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp - $HOME/gopath/bin/goveralls -coverprofile=coverage.merged -service=travis-ci -repotoken $COVERALLS_TOKEN From 40d328967b8e1c3b407dc9f7077760facf582f0d Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:31:14 -0500 Subject: [PATCH 07/13] Run all tests. I'll mark the always-failing tests as skipped. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 41ef5cf..87ec5cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,5 +22,5 @@ install: script: # a workaround for go test not supporting coverage for multiple packages in a single invocation - |- - echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c ': > coverage.tmp; go test -covermode=count -coverprofile=coverage.tmp -test.run="BCD|Parse" {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp + echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c ': > coverage.tmp; go test -covermode=count -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp - $HOME/gopath/bin/goveralls -coverprofile=coverage.merged -service=travis-ci -repotoken $COVERALLS_TOKEN From 76721213eb2a9f3207b3e1751a3343703c07810d Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:34:49 -0500 Subject: [PATCH 08/13] Skip descriptor test on Travis. --- usb/device_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usb/device_test.go b/usb/device_test.go index 2fcd725..d6c0708 100644 --- a/usb/device_test.go +++ b/usb/device_test.go @@ -16,12 +16,16 @@ package usb_test import ( + "os" "testing" . "github.com/kylelemons/gousb/usb" ) func TestGetStringDescriptorAscii(t *testing.T) { + if os.Getenv("TRAVIS") == "true" { + t.Skip("This test is known to fail under TravisCI") + } c := NewContext() defer c.Close() c.Debug(0) From a675c1b487dbea890ff4c6d10f5e87dfc1a04720 Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:41:25 -0500 Subject: [PATCH 09/13] more tests failing on travis --- usb/usb_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/usb/usb_test.go b/usb/usb_test.go index 2e18019..9067ea4 100644 --- a/usb/usb_test.go +++ b/usb/usb_test.go @@ -26,12 +26,18 @@ import ( ) func TestNoop(t *testing.T) { + if os.Getenv("TRAVIS") == "true" { + t.Skip("test known to fail on Travis") + } c := NewContext() defer c.Close() c.Debug(0) } func TestEnum(t *testing.T) { + if os.Getenv("TRAVIS") == "true" { + t.Skip("test known to fail on Travis") + } c := NewContext() defer c.Close() c.Debug(0) From aaec52a9c3490f7715bf393641f6ac2747f6d66e Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:43:08 -0500 Subject: [PATCH 10/13] more tests failing on travis --- usb/usb_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/usb/usb_test.go b/usb/usb_test.go index 9067ea4..262ae12 100644 --- a/usb/usb_test.go +++ b/usb/usb_test.go @@ -89,6 +89,9 @@ func TestEnum(t *testing.T) { } func TestOpenDeviceWithVidPid(t *testing.T) { + if os.Getenv("TRAVIS") == "true" { + t.Skip("test known to fail on Travis") + } c := NewContext() defer c.Close() c.Debug(0) @@ -129,6 +132,9 @@ func TestOpenDeviceWithVidPid(t *testing.T) { } func TestMultipleContexts(t *testing.T) { + if os.Getenv("TRAVIS") == "true" { + t.Skip("test known to fail on Travis") + } var buf bytes.Buffer log.SetOutput(&buf) for i := 0; i < 2; i++ { From dcc298126ab752231bf62cc9a512a7a71070a57e Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:52:54 -0500 Subject: [PATCH 11/13] "-v" for the tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 87ec5cc..6c0e292 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,5 +22,5 @@ install: script: # a workaround for go test not supporting coverage for multiple packages in a single invocation - |- - echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c ': > coverage.tmp; go test -covermode=count -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp + echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c ': > coverage.tmp; go test -v -covermode=count -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp - $HOME/gopath/bin/goveralls -coverprofile=coverage.merged -service=travis-ci -repotoken $COVERALLS_TOKEN From 3b0b2f1a6b608817c59de0724ef82c65fd8e1103 Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 12:56:46 -0500 Subject: [PATCH 12/13] consistent skip message --- usb/device_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usb/device_test.go b/usb/device_test.go index d6c0708..a8db5fc 100644 --- a/usb/device_test.go +++ b/usb/device_test.go @@ -24,7 +24,7 @@ import ( func TestGetStringDescriptorAscii(t *testing.T) { if os.Getenv("TRAVIS") == "true" { - t.Skip("This test is known to fail under TravisCI") + t.Skip("test known to fail on Travis") } c := NewContext() defer c.Close() From feddade9bf0e2be55494e92cf908beeb5fb7e50b Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Thu, 9 Mar 2017 19:32:46 -0500 Subject: [PATCH 13/13] add coverage badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fc65fa7..93ec816 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Introduction [![Build Status][ciimg]][ci] [![GoDoc][docimg]][doc] +[![Coverage Status](https://coveralls.io/repos/github/kylelemons/gousb/badge.svg?branch=coverage)](https://coveralls.io/github/kylelemons/gousb?branch=coverage) The gousb package is an attempt at wrapping the libusb library into a Go-like binding.