Skip to content

Commit

Permalink
Allowing soft disabling of IO tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Jan 23, 2023
1 parent 04a8ee7 commit 1f2e3bc
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 63 deletions.
47 changes: 38 additions & 9 deletions BitSliceIndexing/bsi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"math/rand"
"testing"
"time"
"fmt"
"os"
)

func TestSetAndGet(t *testing.T) {
Expand Down Expand Up @@ -263,23 +265,50 @@ func TestNewBSIRetainSet(t *testing.T) {
func TestLargeFile(t *testing.T) {

datEBM, err := ioutil.ReadFile("./testdata/age/EBM")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat1, err := ioutil.ReadFile("./testdata/age/1")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat2, err := ioutil.ReadFile("./testdata/age/2")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat3, err := ioutil.ReadFile("./testdata/age/3")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat4, err := ioutil.ReadFile("./testdata/age/4")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat5, err := ioutil.ReadFile("./testdata/age/5")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat6, err := ioutil.ReadFile("./testdata/age/6")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat7, err := ioutil.ReadFile("./testdata/age/7")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat8, err := ioutil.ReadFile("./testdata/age/8")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}

b := [][]byte{datEBM, dat1, dat2, dat3, dat4, dat5, dat6, dat7, dat8}

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ Note that the smat library requires Go 1.6 or better.

### Instructions for contributors

Using bash or other common shells:
```
$ git clone git@github.com:RoaringBitmap/roaring.git
$ GO111MODULE=on go mod tidy
$ export GO111MODULE=on
$ go mod tidy
$ go test -v
```

Expand Down
52 changes: 38 additions & 14 deletions roaring64/bsi64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"math/rand"
"testing"
"time"
"fmt"
"os"
)

func TestSetAndGet(t *testing.T) {
Expand Down Expand Up @@ -263,34 +265,56 @@ func TestNewBSIRetainSet(t *testing.T) {
func TestLargeFile(t *testing.T) {

datEBM, err := ioutil.ReadFile("./testdata/age/EBM")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat1, err := ioutil.ReadFile("./testdata/age/1")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat2, err := ioutil.ReadFile("./testdata/age/2")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat3, err := ioutil.ReadFile("./testdata/age/3")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat4, err := ioutil.ReadFile("./testdata/age/4")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat5, err := ioutil.ReadFile("./testdata/age/5")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat6, err := ioutil.ReadFile("./testdata/age/6")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat7, err := ioutil.ReadFile("./testdata/age/7")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
dat8, err := ioutil.ReadFile("./testdata/age/8")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}

b := [][]byte{datEBM, dat1, dat2, dat3, dat4, dat5, dat6, dat7, dat8}

bsi := NewDefaultBSI()
//bsi.RunOptimize()
err = bsi.UnmarshalBinary(b)
for i := 0; i < bsi.BitCount(); i++ {
//assert.True(t, bsi.bA[i].HasRunCompression())
//bsi.bA[i].RunOptimize()
}
//assert.True(t, bsi.eBM.HasRunCompression())
require.Nil(t, err)

resultA := bsi.CompareValue(0, EQ, 55, 0, nil)
Expand Down
21 changes: 13 additions & 8 deletions roaring64/roaring64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"strconv"
"testing"
"fmt"

"github.com/RoaringBitmap/roaring"
"github.com/bits-and-blooms/bitset"
Expand Down Expand Up @@ -2001,8 +2002,9 @@ func Test_tryReadFromRoaring32(t *testing.T) {

func Test_tryReadFromRoaring32_File(t *testing.T) {
tempDir, err := ioutil.TempDir("./", "testdata")
if err != nil {
t.Fail()
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
defer os.RemoveAll(tempDir)

Expand All @@ -2016,8 +2018,9 @@ func Test_tryReadFromRoaring32_File(t *testing.T) {
t.Fatal(err)
}
file, err := os.Open(name)
if err != nil {
t.Fatal(err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
defer file.Close()

Expand Down Expand Up @@ -2045,8 +2048,9 @@ func Test_tryReadFromRoaring32WithRoaring64(t *testing.T) {

func Test_tryReadFromRoaring32WithRoaring64_File(t *testing.T) {
tempDir, err := ioutil.TempDir("./", "testdata")
if err != nil {
t.Fail()
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
defer os.RemoveAll(tempDir)

Expand All @@ -2061,8 +2065,9 @@ func Test_tryReadFromRoaring32WithRoaring64_File(t *testing.T) {
t.Fatal(err)
}
file, err := os.Open(name)
if err != nil {
t.Fatal(err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}
defer file.Close()

Expand Down
17 changes: 10 additions & 7 deletions roaring64/serialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,31 @@ func TestSerializationToFile038(t *testing.T) {
fname := "myfile.bin"
fout, err := os.OpenFile(fname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0660)
if(err != nil) {
fmt.Println("IMPORTANT: For testing file IO, the roaring library requires disk access.")
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}

require.NoError(t, err)

var l int64
l, err = rb.WriteTo(fout)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}

require.NoError(t, err)
assert.EqualValues(t, l, rb.GetSerializedSizeInBytes())

fout.Close()

newrb := NewBitmap()
fin, err := os.Open(fname)

require.NoError(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "IMPORTANT: For testing file IO, the roaring library requires disk access.")
return
}

defer func() {
fin.Close()
require.NoError(t, os.Remove(fname))
_ = os.Remove(fname)
}()

_, _ = newrb.ReadFrom(fin)
Expand Down

0 comments on commit 1f2e3bc

Please sign in to comment.