Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
149
Issues
149
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
3eebda86
Commit
3eebda86
authored
Oct 23, 2024
by
Alfredo Di Napoli
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Phylo tests using tasty-golden properly
parent
893b4cf8
Pipeline
#6874
failed with stages
in 45 minutes and 9 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4753 additions
and
7 deletions
+4753
-7
README.md
README.md
+31
-0
cleopatre.golden.json
test-data/phylo/cleopatre.golden.json
+4708
-1
Phylo.hs
test/Test/Offline/Phylo.hs
+14
-6
No files found.
README.md
View file @
3eebda86
...
...
@@ -416,3 +416,34 @@ with `ghcup`:
ghcup compile hls
--version
2.7.0.0
--ghc
9.4.7
```
https://haskell-language-server.readthedocs.io/en/latest/installation.html
## Running the tests
Running the tests can be done via the following command:
```
hs
cabal
v2
-
test
--test-show-details=streaming --flags 'test-crypto no-phylo-debug-logs'
```
The flags have the following meaning:
*
`test-crypto`
: Switch to use very fast (but not production-secure) cryptography, so that tests runs
faster;
*
`no-phylo-debug-logs`
: Suppresses the debugging logs which would normally be present in phylo pure (!) code.
In order for some tests to run (like the phylo ones) is
**required**
to install the
`gargantext-cli`
via:
```
hs
cabal
v2
-
install
gargantext
:
exe
:
gargantext
-
cli
```
### Modifying a golden test to accept a new (expected) output
Some tests, like the Phylo one, use golden testing to ensure that the JSON Phylo we generate is
the same as an expected one. This allows us to catch regressions in the serialisation or in the algorithm.
Sometimes, however, we genuinely want to modify the output so that it's the new reference (i.e. the new
golden reference). To do so, it's enough to run the testsuite passing the
`--accept`
flag, for example:
```
hs
cabal
v2
-
test
garg
-
test
-
tasty
--test-show-details=streaming --flags 'test-crypto no-phylo-debug-logs' --test-option=--pattern='/Phylo/' --test-option=--accept"
```
test-data/phylo/cleopatre.golden.json
View file @
3eebda86
This source diff could not be displayed because it is too large. You can
view the blob
instead.
test/Test/Offline/Phylo.hs
View file @
3eebda86
...
...
@@ -7,21 +7,24 @@ module Test.Offline.Phylo (tests) where
import
CLI.Phylo.Common
import
Data.Aeson
as
JSON
import
Data.Aeson.Types
qualified
as
JSON
import
Data.Aeson.Encode.Pretty
qualified
as
JSON
import
Data.ByteString.Lazy
qualified
as
BL
import
Data.GraphViz.Attributes.Complete
qualified
as
Graphviz
import
Data.Text.Lazy
as
TL
import
Data.TreeDiff
import
Data.Vector
qualified
as
V
import
Gargantext.Core.Text.List.Formats.TSV
import
Gargantext.Core.Types.Phylo
hiding
(
Phylo
(
..
))
import
Gargantext.Core.Viz.Phylo
hiding
(
EdgeType
(
..
))
import
Gargantext.Core.Viz.Phylo.API.Tools
(
readPhylo
,
phylo2dot2json
)
import
Gargantext.Core.Viz.Phylo.Example
qualified
as
Cleopatre
import
Gargantext.Core.Viz.Phylo
hiding
(
EdgeType
(
..
))
import
Gargantext.Core.Viz.Phylo.PhyloExport
import
Gargantext.Core.Viz.Phylo.PhyloMaker
(
toPhylo
,
toPhyloWithoutLink
)
import
Gargantext.Core.Viz.Phylo.PhyloTools
import
Paths_gargantext
import
Prelude
import
Test.Tasty
import
Test.Tasty.Golden
(
goldenVsStringDiff
)
import
Test.Tasty.HUnit
phyloTestConfig
::
PhyloConfig
...
...
@@ -48,6 +51,12 @@ phyloTestConfig = PhyloConfig {
,
exportFilter
=
[
ByBranchSize
{
_branch_size
=
3.0
}]
}
phyloGolden
::
TestName
->
(
FilePath
,
IO
BL
.
ByteString
)
->
TestTree
phyloGolden
testName
(
fp
,
action
)
=
goldenVsStringDiff
testName
differ
fp
action
where
differ
ref
new
=
[
"diff"
,
"-u"
,
"-w"
,
"--color=always"
,
ref
,
new
]
tests
::
TestTree
tests
=
testGroup
"Phylo"
[
testGroup
"Export"
[
...
...
@@ -56,7 +65,7 @@ tests = testGroup "Phylo" [
]
,
testGroup
"toPhyloWithoutLink"
[
testCase
"returns expected data"
testSmallPhyloWithoutLinkExpectedOutput
,
testCase
"phyloCleopatre returns expected data"
testCleopatreWithoutLinkExpectedOutput
,
phyloGolden
"phyloCleopatre returns expected data"
testCleopatreWithoutLinkExpectedOutput
,
testCase
"Nadal canned corpus returns expected data"
testNadalWithoutLinkExpectedOutput
]
,
testGroup
"phylo2dot2json"
[
...
...
@@ -71,11 +80,10 @@ tests = testGroup "Phylo" [
,
testCase
"parses csv phylo"
testCsvPhylo
]
testCleopatreWithoutLinkExpectedOutput
::
Assertion
testCleopatreWithoutLinkExpectedOutput
=
do
testCleopatreWithoutLinkExpectedOutput
::
(
FilePath
,
IO
BL
.
ByteString
)
testCleopatreWithoutLinkExpectedOutput
=
let
actual
=
toPhyloWithoutLink
Cleopatre
.
docs
Cleopatre
.
config
expected
<-
readPhylo
=<<
getDataFileName
"test-data/phylo/cleopatre.golden.json"
assertBool
(
show
$
ansiWlEditExprCompact
$
ediff
expected
actual
)
(
expected
==
actual
)
in
(
"test-data/phylo/cleopatre.golden.json"
,
pure
$
JSON
.
encodePretty
actual
)
testNadalWithoutLinkExpectedOutput
::
Assertion
testNadalWithoutLinkExpectedOutput
=
do
...
...
Przemyslaw Kaminski
@cgenie
mentioned in commit
83c8708f
·
Nov 07, 2024
mentioned in commit
83c8708f
mentioned in commit 83c8708f08e563243a0ff361e51a46c7d7822bb7
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment