Commit 1db30943 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Add phylo2dot2json determinism test

Apparently `dot` has a long lasting bug (recently fixed) which is the
root of the non-determinism:

https://gitlab.com/graphviz/graphviz/-/issues/2510
parent ace74e56
......@@ -45,6 +45,7 @@ data-files:
test-data/phylo/GarganText_DocsList-nodeId-187481.csv
test-data/phylo/GarganText_NgramsList-nodeId-187482.csv
test-data/phylo/187481.json
test-data/phylo/phylo2dot2json.golden.json
test-data/stemming/lancaster.txt
test-data/test_config.ini
gargantext-cors-settings.toml
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -66,6 +66,9 @@ tests = testGroup "Phylo" [
testProperty "returns expected data" testSmallPhyloWithoutLinkExpectedOutput
, testProperty "phyloCleopatre returns expected data" testCleopatreWithoutLinkExpectedOutput
]
, testGroup "phylo2dot2json" [
testCase "is deterministic" testPhylo2dot2json
]
, testGroup "toPhylo" [
--testProperty "returns expected data" testSmallPhyloExpectedOutput
testCase "is deterministic" testToPhyloDeterminism
......@@ -98,6 +101,18 @@ testSmallPhyloWithoutLinkExpectedOutput = monadicIO $ do
expected <- run $ readPhylo =<< getDataFileName "test-data/phylo/small-phylo.golden.json"
pure $ counterexample (show $ ansiWlEditExpr $ ediff' expected actual) (expected === actual)
testPhylo2dot2json :: Assertion
testPhylo2dot2json = do
expected_e <- JSON.eitherDecodeFileStrict' =<< getDataFileName "test-data/phylo/phylo2dot2json.golden.json"
case expected_e of
Left err -> fail err
Right (jsonBlob :: JSON.Value) -> do
actualBlob <- phylo2dot2json Cleopatre.phyloCleopatre
let prettyConfig = JSON.defConfig { JSON.confCompare = compare }
let actualJSON = TE.decodeUtf8 (BL.toStrict $ JSON.encodePretty' prettyConfig $ jsonBlob)
let expectedJSON = TE.decodeUtf8 (BL.toStrict $ JSON.encodePretty' prettyConfig $ actualBlob)
assertBool ("JSON mismatch!" <> show (ansiWlEditExpr $ ediff' expectedJSON actualJSON)) (expectedJSON == actualJSON)
testSmallPhyloExpectedOutput :: Property
testSmallPhyloExpectedOutput = monadicIO $ do
issue290PhyloSmall <- run $ setConfig phyloConfig <$> (readPhylo =<< getDataFileName "bench-data/phylo/issue-290-small.json")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment