Skip to content

Commit 006d71e

Browse files
committed
Run Class-based tests with both the ordinary and compact index
1 parent c1338d5 commit 006d71e

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

test/Test/Database/LSMTree/Class.hs

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Database.LSMTree.Common (mkSnapshotName)
2424
import Database.LSMTree.Extras.Generators ()
2525
import qualified Database.LSMTree.Model.IO as ModelIO
2626
import qualified System.FS.API as FS
27+
import Test.Database.LSMTree.StateMachine ()
2728
import Test.QuickCheck.Monadic (monadicIO, monitor, run)
2829
import Test.Tasty (TestName, TestTree, testGroup)
2930
import qualified Test.Tasty.QuickCheck as QC
@@ -36,19 +37,17 @@ tests = testGroup "Test.Database.LSMTree.Class"
3637
, testGroup "Real" $ zipWith ($) (props tbl2) expectFailures2
3738
]
3839
where
39-
tbl1 :: Proxy ModelIO.Table
40-
tbl1 = Setup {
41-
testTableConfig = ModelIO.TableConfig
40+
tbl1 :: RunSetup ModelIO.Table IO
41+
tbl1 = RunSetup $ \conf -> Setup {
42+
testTableConfig = conf
4243
, testWithSessionArgs = \action -> action ModelIO.NoSessionArgs
4344
}
4445

4546
expectFailures1 = repeat False
4647

47-
tbl2 :: Proxy R.Table
48-
tbl2 = Setup {
49-
testTableConfig = R.defaultTableConfig {
50-
R.confWriteBufferAlloc = R.AllocNumEntries (R.NumEntries 3)
51-
}
48+
tbl2 :: RunSetup R.Table IO
49+
tbl2 = RunSetup $ \conf -> Setup {
50+
testTableConfig = conf
5251
, testWithSessionArgs = \action ->
5352
FS.withTempIOHasBlockIO "R" $ \hfs hbio ->
5453
action (SessionArgs hfs hbio (FS.mkFsPath []))
@@ -83,33 +82,33 @@ tests = testGroup "Test.Database.LSMTree.Class"
8382
, True -- merge
8483
] ++ repeat False
8584

86-
props tbl =
87-
[ testProperty' "lookup-insert" $ prop_lookupInsert tbl
88-
, testProperty' "lookup-insert-else" $ prop_lookupInsertElse tbl
89-
, testProperty' "lookup-insert-blob" $ prop_lookupInsertBlob tbl
90-
, testProperty' "lookup-delete" $ prop_lookupDelete tbl
91-
, testProperty' "lookup-delete-else" $ prop_lookupDeleteElse tbl
92-
, testProperty' "insert-insert" $ prop_insertInsert tbl
93-
, testProperty' "insert-insert-blob" $ prop_insertInsertBlob tbl
94-
, testProperty' "insert-commutes" $ prop_insertCommutes tbl
95-
, testProperty' "insert-commutes-blob" $ prop_insertCommutesBlob tbl
96-
, testProperty' "invalidated-blob-references" $ prop_updatesMayInvalidateBlobRefs tbl
97-
, testProperty' "dup-insert-insert" $ prop_dupInsertInsert tbl
98-
, testProperty' "dup-insert-comm" $ prop_dupInsertCommutes tbl
99-
, testProperty' "dup-nochanges" $ prop_dupNoChanges tbl
100-
, testProperty' "lookupRange-like-lookups" $ prop_lookupRangeLikeLookups tbl
101-
, testProperty' "lookupRange-insert" $ prop_insertLookupRange tbl
102-
, testProperty' "readCursor-sorted" $ prop_readCursorSorted tbl
103-
, testProperty' "readCursor-num-results" $ prop_readCursorNumResults tbl
104-
, testProperty' "readCursor-insert" $ prop_readCursorInsert tbl
105-
, testProperty' "readCursor-delete" $ prop_readCursorDelete tbl
106-
, testProperty' "readCursor-delete-else" $ prop_readCursorDeleteElse tbl
107-
, testProperty' "readCursor-stable-view" $ prop_readCursorStableView tbl
108-
, testProperty' "readCursor-offset" $ prop_readCursorOffset tbl
109-
, testProperty' "snapshot-nochanges" $ prop_snapshotNoChanges tbl
110-
, testProperty' "snapshot-nochanges2" $ prop_snapshotNoChanges2 tbl
111-
, testProperty' "lookup-mupsert" $ prop_lookupUpdate tbl
112-
, testProperty' "union" $ prop_union tbl
85+
props RunSetup {..} =
86+
[ testProperty' "lookup-insert" $ prop_lookupInsert . runSetup
87+
, testProperty' "lookup-insert-else" $ prop_lookupInsertElse . runSetup
88+
, testProperty' "lookup-insert-blob" $ prop_lookupInsertBlob . runSetup
89+
, testProperty' "lookup-delete" $ prop_lookupDelete . runSetup
90+
, testProperty' "lookup-delete-else" $ prop_lookupDeleteElse . runSetup
91+
, testProperty' "insert-insert" $ prop_insertInsert . runSetup
92+
, testProperty' "insert-insert-blob" $ prop_insertInsertBlob . runSetup
93+
, testProperty' "insert-commutes" $ prop_insertCommutes . runSetup
94+
, testProperty' "insert-commutes-blob" $ prop_insertCommutesBlob . runSetup
95+
, testProperty' "invalidated-blob-references" $ prop_updatesMayInvalidateBlobRefs . runSetup
96+
, testProperty' "dup-insert-insert" $ prop_dupInsertInsert . runSetup
97+
, testProperty' "dup-insert-comm" $ prop_dupInsertCommutes . runSetup
98+
, testProperty' "dup-nochanges" $ prop_dupNoChanges . runSetup
99+
, testProperty' "lookupRange-like-lookups" $ prop_lookupRangeLikeLookups . runSetup
100+
, testProperty' "lookupRange-insert" $ prop_insertLookupRange . runSetup
101+
, testProperty' "readCursor-sorted" $ prop_readCursorSorted . runSetup
102+
, testProperty' "readCursor-num-results" $ prop_readCursorNumResults . runSetup
103+
, testProperty' "readCursor-insert" $ prop_readCursorInsert . runSetup
104+
, testProperty' "readCursor-delete" $ prop_readCursorDelete . runSetup
105+
, testProperty' "readCursor-delete-else" $ prop_readCursorDeleteElse . runSetup
106+
, testProperty' "readCursor-stable-view" $ prop_readCursorStableView . runSetup
107+
, testProperty' "readCursor-offset" $ prop_readCursorOffset . runSetup
108+
, testProperty' "snapshot-nochanges" $ prop_snapshotNoChanges . runSetup
109+
, testProperty' "snapshot-nochanges2" $ prop_snapshotNoChanges2 . runSetup
110+
, testProperty' "lookup-mupsert" $ prop_lookupUpdate . runSetup
111+
, testProperty' "union" $ prop_union . runSetup
113112
]
114113

115114
testProperty' :: forall a. Testable a => TestName -> a -> Bool -> TestTree
@@ -138,6 +137,10 @@ label = SnapshotLabel "Word64 ByteString ByteString"
138137

139138
type Proxy h = Setup h IO
140139

140+
newtype RunSetup h m = RunSetup {
141+
runSetup :: TableConfig h -> Setup h m
142+
}
143+
141144
data Setup h m = Setup {
142145
testTableConfig :: TableConfig h
143146
, testWithSessionArgs :: forall a. (SessionArgs (Session h) m -> m a) -> m a

0 commit comments

Comments
 (0)