on master help sign in
all tests pass again
commit0f030d075c9eff722146739623c58376a2f99911 authorAgentM <agentm@themactionfaction.com> dateWed 20 Jul 2016, 21:20 (10 years ago) parent3b67141
7 files changed+42−9
ProjectM36/RelationalExpression.hs+2−2 ProjectM36/TransactionGraph.hs+1−2 ProjectM36/TransactionGraph/Persist.hs+1−1 ProjectM36/Tuple.hs+2−2 project-m36.cabal+15 test/TransactionGraph/Merge.hs−1 test/TutorialD/Interpreter.hs+21−1
ProjectM36/RelationalExpression.hs+2−2
@@ -18,7 +18,7 @@ import Data.Char (isUpper)
1818import qualified Data.Text as T
1919import qualified Data.Vector as V
2020import qualified ProjectM36.TypeConstructorDef as TCD
21−--import Debug.Trace
21+import Debug.Trace
2222
2323--relvar state is needed in evaluation of relational expression but only as read-only in order to extract current relvar values
2424evalRelationalExpr :: RelationalExpr -> DatabaseState (Either RelationalError Relation)
@@ -528,7 +528,7 @@ evalTupleExpr context attrs (TupleExpr tupMap) = do
528528 tConss = typeConstructorMapping context
529529 finalAttrs = fromMaybe tupAttrs attrs
530530 --verify that the attributes match
531− when (not $ A.attributesEqual finalAttrs tupAttrs) (Left (TupleAttributeTypeMismatchError tupAttrs))
531+ when (A.attributeNameSet finalAttrs /= A.attributeNameSet tupAttrs) (traceShow (finalAttrs,tupAttrs) $ Left (TupleAttributeTypeMismatchError tupAttrs))
532532 tup' <- resolveTypesInTuple finalAttrs (reorderTuple finalAttrs tup)
533533 _ <- validateTuple tup' tConss
534534 pure tup'
ProjectM36/TransactionGraph.hs+1−2
@@ -7,7 +7,6 @@ import ProjectM36.Relation
77import ProjectM36.TupleSet
88import ProjectM36.Tuple
99import ProjectM36.DataTypes.Primitive
10−import ProjectM36.TransactionGraph.Show.Dot
1110import qualified Data.Vector as V
1211import qualified ProjectM36.Attribute as A
1312import qualified Data.UUID as U
@@ -19,7 +18,7 @@ import GHC.Generics
1918import Data.Binary
2019import ProjectM36.TransactionGraph.Merge
2120import Data.Either (lefts, rights, isRight)
22−import Debug.Trace
21+--import Debug.Trace
2322
2423--operators which manipulate a transaction graph
2524data TransactionGraphOperator = JumpToHead HeadName |
ProjectM36/TransactionGraph/Persist.hs+1−1
@@ -138,7 +138,7 @@ writeGraphUUIDFile sync destDirectory (TransactionGraph _ transSet) = writeFileS
138138 graphFile = destDirectory </> "m36v1"
139139 uuidInfo = intercalate "\n" graphLines
140140 graphLines = S.toList $ S.map graphLine transSet
141− graphLine trans = U.toString (transactionUUID trans) ++ " " ++ intercalate " " (S.toList (S.map U.toString $ transactionParentUUIDs trans))
141+ graphLine trans = U.toString (transactionUUID trans) ++ " " ++ intercalate " " (S.toList (S.map U.toString $ transactionParentIds trans))
142142
143143readGraphUUIDFile :: FilePath -> IO (Either PersistenceError [(U.UUID, [U.UUID])])
144144readGraphUUIDFile dbdir = do
ProjectM36/Tuple.hs+2−2
@@ -56,7 +56,7 @@ vectorIndicesForAttributeNames attrNameVec attrs = if not $ V.null unknownAttrNa
5656 where
5757 unknownAttrNames = V.filter ((flip V.notElem) (attributeNames attrs)) attrNameVec
5858 mapper attrName = case V.elemIndex attrName (V.map attributeName attrs) of
59− Nothing -> undefined
59+ Nothing -> error "logic failure in vectorIndicesForAttributeNames"
6060 Just index -> index
6161
6262relationForAttributeName :: AttributeName -> RelationTuple -> Either RelationalError Relation
@@ -198,6 +198,6 @@ reorderTuple attrs tupIn = if tupleAttributes tupIn == attrs then
198198 RelationTuple attrs (V.map mapper attrs)
199199 where
200200 mapper attr = case atomForAttributeName (attributeName attr) tupIn of
201− Left _ -> undefined
201+ Left _ -> error "logic failure in reorderTuple"
202202 Right atom -> atom
203203
project-m36.cabal+15
@@ -257,6 +257,7 @@ Executable project-m36-server
257257 list-t,
258258 base64-bytestring
259259 Main-Is: ProjectM36/Server/project-m36-server.hs
260+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
260261 GHC-Options: -Wall -threaded -rtsopts
261262 GHC-Prof-Options: -fprof-auto -rtsopts -threaded -Wall
262263 Default-Language: Haskell2010
@@ -345,6 +346,7 @@ Executable bigrel
345346 TutorialD.Interpreter.Types
346347 main-is: benchmark/bigrel.hs
347348 GHC-Options: -Wall -threaded -rtsopts
349+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
348350 GHC-Prof-Options: -fprof-auto -rtsopts -threaded -Wall
349351 if os(windows)
350352 Build-Depends: Win32 >= 2.3 && < 2.4
@@ -360,6 +362,7 @@ Test-Suite test-tutoriald
360362 main-is: test/TutorialD/Interpreter.hs
361363 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, stm-containers, list-t
362364 GHC-Options: -Wall
365+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
363366 if os(windows)
364367 Build-Depends: Win32 >= 2.3 && < 2.4
365368 Other-Modules: ProjectM36.Win32Handle
@@ -374,6 +377,7 @@ Test-Suite test-relation
374377 main-is: test/Relation/Basic.hs
375378 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, stm-containers
376379 GHC-Options: -Wall
380+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
377381
378382Test-Suite test-static-optimizer
379383 Default-Language: Haskell2010
@@ -381,6 +385,7 @@ Test-Suite test-static-optimizer
381385 main-is: test/Relation/StaticOptimizer.hs
382386 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, stm-containers
383387 GHC-Options: -Wall
388+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
384389
385390Test-Suite test-transactiongraph-persist
386391 Default-Language: Haskell2010
@@ -388,6 +393,7 @@ Test-Suite test-transactiongraph-persist
388393 main-is: test/TransactionGraph/Persist.hs
389394 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, stm-containers
390395 GHC-Options: -Wall
396+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
391397 if os(windows)
392398 Build-Depends: Win32 >= 2.3 && < 2.4
393399 Other-Modules: ProjectM36.Win32Handle
@@ -402,6 +408,7 @@ Test-Suite test-relation-import-csv
402408 main-is: test/Relation/Import/CSV.hs
403409 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, stm-containers
404410 GHC-Options: -Wall
411+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
405412
406413Test-Suite test-tutoriald-import-tutoriald
407414 Default-Language: Haskell2010
@@ -409,6 +416,7 @@ Test-Suite test-tutoriald-import-tutoriald
409416 main-is: test/TutorialD/Interpreter/Import/TutorialD.hs
410417 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, stm-containers
411418 GHC-Options: -Wall
419+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
412420
413421Test-Suite test-relation-export-csv
414422 Default-Language: Haskell2010
@@ -416,6 +424,7 @@ Test-Suite test-relation-export-csv
416424 main-is: test/Relation/Export/CSV.hs
417425 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, stm-containers
418426 GHC-Options: -Wall
427+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
419428
420429Test-Suite test-persistent-driver
421430 Default-Language: Haskell2010
@@ -423,6 +432,7 @@ Test-Suite test-persistent-driver
423432 main-is: test/persistent-driver/test.hs
424433 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, template-haskell, transformers, aeson, persistent-template, conduit, persistent >= 2.2 && < 2.3, either, path-pieces, http-api-data, stm-containers, list-t
425434 GHC-Options: -Wall
435+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
426436 if os(windows)
427437 Build-Depends: Win32 >= 2.3 && < 2.4
428438 Other-Modules: ProjectM36.Win32Handle
@@ -438,6 +448,7 @@ Test-Suite test-transactiongraph-merge
438448 main-is: test/TransactionGraph/Merge.hs
439449 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, unix, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, template-haskell, transformers, aeson, persistent-template, conduit, persistent, either, path-pieces, http-api-data, stm-containers, list-t
440450 GHC-Options: -Wall
451+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
441452 C-sources: ProjectM36/DirectoryFsync.c
442453
443454benchmark bench
@@ -446,6 +457,7 @@ benchmark bench
446457 main-is: benchmark/Relation.hs
447458 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, criterion, stm-containers
448459 GHC-Options: -Wall -rtsopts
460+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
449461
450462Test-Suite test-server
451463 Default-Language: Haskell2010
@@ -453,6 +465,7 @@ Test-Suite test-server
453465 main-is: test/Server/Main.hs
454466 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t
455467 GHC-Options: -Wall
468+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
456469 if os(windows)
457470 Build-Depends: Win32 >= 2.3 && < 2.4
458471 Other-Modules: ProjectM36.Win32Handle
@@ -467,6 +480,7 @@ Executable Example-SimpleClient
467480 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t
468481 Main-Is: examples/SimpleClient.hs
469482 GHC-Options: -Wall
483+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
470484 Other-Modules: ProjectM36.Atom,
471485 ProjectM36.AtomFunction,
472486 ProjectM36.AtomFunctions.Basic,
@@ -517,6 +531,7 @@ Executable Example-PersistClient
517531 Build-Depends: base, HUnit, Cabal, containers, hashable, unordered-containers, mtl, vector, vector-binary-instances, time, hashable-time, bytestring, network-transport-tcp, distributed-process, distributed-process-extras, distributed-process-client-server, uuid, stm, deepseq, deepseq-generics, binary, parallel, cassava, attoparsec, gnuplot, directory, temporary, haskeline, parsec, text, base64-bytestring, data-interval, filepath, transformers, stm-containers, list-t, persistent, aeson, path-pieces, either, conduit, http-api-data, template-haskell, persistent-template
518532 Main-Is: examples/PersistClient.hs
519533 GHC-Options: -Wall
534+ CPP-Options: -DPROJECTM36_VERSION="v0.1"
520535 Other-Modules: Database.Persist.ProjectM36,
521536 ProjectM36.Atom,
522537 ProjectM36.AtomFunction,
test/TransactionGraph/Merge.hs−1
@@ -176,7 +176,6 @@ testUnionPreferMergeStrategy = TestCase $ do
176176 Right (DisconnectedTransaction _ mergeContext, _) -> do
177177 assertEqual "branchB relvar preferred in conflict" (Just branchBRelVar) (M.lookup conflictRelVarName (relationVariables mergeContext))
178178
179−
180179-- try various individual component conflicts and check for merge failure
181180testUnionMergeStrategy :: Test
182181testUnionMergeStrategy = TestCase $ do
test/TutorialD/Interpreter.hs+21−1
@@ -33,7 +33,7 @@ main = do
3333 tcounts <- runTestTT (TestList tests)
3434 if errors tcounts + failures tcounts > 0 then exitFailure else exitSuccess
3535 where
36− tests = map (\(tutd, expected) -> TestCase $ assertTutdEqual basicDatabaseContext expected tutd) simpleRelTests ++ map (\(tutd, expected) -> TestCase $ assertTutdEqual dateExamples expected tutd) dateExampleRelTests ++ [transactionGraphBasicTest, transactionGraphAddCommitTest, transactionRollbackTest, transactionJumpTest, transactionBranchTest, simpleJoinTest, testNotification, testTypeConstructors]
36+ tests = map (\(tutd, expected) -> TestCase $ assertTutdEqual basicDatabaseContext expected tutd) simpleRelTests ++ map (\(tutd, expected) -> TestCase $ assertTutdEqual dateExamples expected tutd) dateExampleRelTests ++ [transactionGraphBasicTest, transactionGraphAddCommitTest, transactionRollbackTest, transactionJumpTest, transactionBranchTest, simpleJoinTest, testNotification, testTypeConstructors, testMergeTransactions]
3737 simpleRelTests = [("x:=true", Right relationTrue),
3838 ("x:=false", Right relationFalse),
3939 ("x:=true union false", Right relationTrue),
@@ -297,3 +297,23 @@ testTypeConstructors = TestCase $ do
297297 executeTutorialD sessionId dbconn "data Tree a = Node a (Tree a) (Tree a) | EmptyNode"
298298 executeTutorialD sessionId dbconn "y:=relation{a Tree Int}{tuple{a Node 3 (Node 4 EmptyNode EmptyNode) EmptyNode},tuple{a Node 4 EmptyNode EmptyNode}}"
299299
300+testMergeTransactions :: Test
301+testMergeTransactions = TestCase $ do
302+ (sessionId, dbconn) <- dateExamplesConnection emptyNotificationCallback
303+ mapM_ (executeTutorialD sessionId dbconn) [
304+ ":branch branchA",
305+ "conflictrv := relation{conflict Int}{tuple{conflict 1}}",
306+ ":commit",
307+ ":jumphead master",
308+ ":branch branchB",
309+ "conflictrv := relation{conflict Int}{tuple{conflict 2}}",
310+ ":commit",
311+ ":mergetrans union branchA branchB"
312+ ]
313+ case mkRelationFromList (attributesFromList [Attribute "conflict" intAtomType]) [[intAtom 1],[intAtom 2]] of
314+ Left err -> assertFailure (show err)
315+ Right conflictCheck -> do
316+ eRv <- executeRelationalExpr sessionId dbconn (RelationVariable "conflictrv")
317+ case eRv of
318+ Left err -> assertFailure (show err)
319+ Right conflictrv -> assertEqual "conflict union merge relvar" conflictCheck conflictrv