Skip to content

Commit

Permalink
Merge pull request RoaringBitmap#379 from RoaringBitmap/dlemire/allow…
Browse files Browse the repository at this point in the history
…ing_soft_disabling_of_io

Allowing soft disabling of IO tests.
  • Loading branch information
lemire authored Jan 23, 2023
2 parents 04a8ee7 + fa87a0a commit ed7ebc9
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 69 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, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat1, err := ioutil.ReadFile("./testdata/age/1")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat2, err := ioutil.ReadFile("./testdata/age/2")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat3, err := ioutil.ReadFile("./testdata/age/3")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat4, err := ioutil.ReadFile("./testdata/age/4")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat5, err := ioutil.ReadFile("./testdata/age/5")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat6, err := ioutil.ReadFile("./testdata/age/6")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat7, err := ioutil.ReadFile("./testdata/age/7")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat8, err := ioutil.ReadFile("./testdata/age/8")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
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 [email protected]: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, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat1, err := ioutil.ReadFile("./testdata/age/1")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat2, err := ioutil.ReadFile("./testdata/age/2")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat3, err := ioutil.ReadFile("./testdata/age/3")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat4, err := ioutil.ReadFile("./testdata/age/4")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat5, err := ioutil.ReadFile("./testdata/age/5")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat6, err := ioutil.ReadFile("./testdata/age/6")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat7, err := ioutil.ReadFile("./testdata/age/7")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
dat8, err := ioutil.ReadFile("./testdata/age/8")
require.Nil(t, err)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
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, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
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, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
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, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
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, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
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, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}

require.NoError(t, err)

var l int64
l, err = rb.WriteTo(fout)
if(err != nil) {
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
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, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}

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

_, _ = newrb.ReadFrom(fin)
Expand Down
20 changes: 14 additions & 6 deletions serialization_frozen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"io/ioutil"
"reflect"
"testing"
"os"
"fmt"
)

func TestFrozenFormat(t *testing.T) {
Expand Down Expand Up @@ -47,11 +49,13 @@ func TestFrozenFormat(t *testing.T) {

frozenBuf, err := ioutil.ReadFile(fpath)
if err != nil {
t.Fatalf("failed to open %s: %s", fpath, err)
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
portableBuf, err := ioutil.ReadFile(ppath)
if err != nil {
t.Fatalf("failed to open %s: %s", ppath, err)
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}

frozen, portable := New(), New()
Expand All @@ -71,11 +75,13 @@ func TestFrozenFormat(t *testing.T) {

frozenBuf, err := ioutil.ReadFile(fpath)
if err != nil {
t.Fatalf("failed to open %s: %s", fpath, err)
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
portableBuf, err := ioutil.ReadFile(ppath)
if err != nil {
t.Fatalf("failed to open %s: %s", ppath, err)
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}

portable := New()
Expand All @@ -100,11 +106,13 @@ func TestFrozenFormat(t *testing.T) {

frozenBuf, err := ioutil.ReadFile(fpath)
if err != nil {
t.Fatalf("failed to open %s: %s", fpath, err)
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}
portableBuf, err := ioutil.ReadFile(ppath)
if err != nil {
t.Fatalf("failed to open %s: %s", ppath, err)
fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
return
}

portable := New()
Expand Down
Loading

0 comments on commit ed7ebc9

Please sign in to comment.