From 45c81452c564d4caf73f05390792af478f896b14 Mon Sep 17 00:00:00 2001 From: James Mills <1290234+prologic@users.noreply.github.com> Date: Sun, 26 Jan 2020 07:31:58 +1000 Subject: [PATCH] Added test harness logic to skip some tests on Windows (#129) --- bitcask_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bitcask_test.go b/bitcask_test.go index b345e2a..3cbd148 100644 --- a/bitcask_test.go +++ b/bitcask_test.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "reflect" + "runtime" "sort" "strings" "sync" @@ -50,6 +51,12 @@ func SortByteArrays(src [][]byte) [][]byte { return sorted } +func skipIfWindows(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Skipping this test on Windows") + } +} + func TestAll(t *testing.T) { var ( db *Bitcask @@ -154,7 +161,7 @@ func TestDeleteAll(t *testing.T) { func TestReopen1(t *testing.T) { assert := assert.New(t) - for i := 0; i < 10; i ++ { + for i := 0; i < 10; i++ { testdir, _ := ioutil.TempDir("", "bitcask") db, _ := Open(testdir, WithMaxDatafileSize(1)) _ = db.Put([]byte("foo"), []byte("bar")) @@ -616,6 +623,10 @@ func TestStatsError(t *testing.T) { assert.Equal(stats.Datafiles, 0) assert.Equal(stats.Keys, 1) }) + }) + + t.Run("Test", func(t *testing.T) { + skipIfWindows(t) t.Run("FabricatedDestruction", func(t *testing.T) { // This would never happen in reality :D @@ -997,6 +1008,8 @@ func TestMergeErrors(t *testing.T) { assert := assert.New(t) t.Run("RemoveDatabaseDirectory", func(t *testing.T) { + skipIfWindows(t) + testdir, err := ioutil.TempDir("", "bitcask") assert.NoError(err) defer os.RemoveAll(testdir)