From 7712a0e111c7a37571f3fb796fe29dd9f44e5cfa Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 20 Aug 2018 10:44:54 +0100 Subject: [PATCH] fs/asyncreader: skip some tests to work around race detector bug The race detector currently detects a race with len(chan) against close(chan). See: https://github.com/golang/go/issues/27070 Skip the tests which trip this bug under the race detector. --- fs/asyncreader/asyncreader_test.go | 4 ++++ lib/israce/israce.go | 9 +++++++++ lib/israce/norace.go | 9 +++++++++ 3 files changed, 22 insertions(+) create mode 100644 lib/israce/israce.go create mode 100644 lib/israce/norace.go diff --git a/fs/asyncreader/asyncreader_test.go b/fs/asyncreader/asyncreader_test.go index 43e6c6de3..93dc471cb 100644 --- a/fs/asyncreader/asyncreader_test.go +++ b/fs/asyncreader/asyncreader_test.go @@ -13,6 +13,7 @@ import ( "testing/iotest" "time" + "github.com/ncw/rclone/lib/israce" "github.com/ncw/rclone/lib/readers" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -303,6 +304,9 @@ func TestAsyncReaderSkipBytes(t *testing.T) { 8000, len(data), BufferSize, 2 * BufferSize} for buffers := 1; buffers <= 5; buffers++ { + if israce.Enabled && buffers > 1 { + t.Skip("FIXME Skipping further tests with race detector until https://github.com/golang/go/issues/27070 is fixed.") + } t.Run(fmt.Sprintf("%d", buffers), func(t *testing.T) { for _, initialRead := range initialReads { t.Run(fmt.Sprintf("%d", initialRead), func(t *testing.T) { diff --git a/lib/israce/israce.go b/lib/israce/israce.go new file mode 100644 index 000000000..82f296590 --- /dev/null +++ b/lib/israce/israce.go @@ -0,0 +1,9 @@ +// +build race + +// Package israce reports if the Go race detector is enabled. +// +// From https://stackoverflow.com/questions/44944959/how-can-i-check-if-the-race-detector-is-enabled-at-runtime +package israce + +// Enabled reports if the race detector is enabled. +const Enabled = true diff --git a/lib/israce/norace.go b/lib/israce/norace.go new file mode 100644 index 000000000..559b56715 --- /dev/null +++ b/lib/israce/norace.go @@ -0,0 +1,9 @@ +// +build !race + +// Package israce reports if the Go race detector is enabled. +// +// From https://stackoverflow.com/questions/44944959/how-can-i-check-if-the-race-detector-is-enabled-at-runtime +package israce + +// Enabled reports if the race detector is enabled. +const Enabled = false