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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Christian Merten
haskell-gargantext
Commits
8d07ed51
Commit
8d07ed51
authored
Jul 01, 2024
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port golden-file-diff to CLI
parent
a4c1fbec
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
15 deletions
+65
-15
FileDiff.hs
bin/gargantext-cli/CLI/FileDiff.hs
+40
-0
Types.hs
bin/gargantext-cli/CLI/Types.hs
+6
-0
Main.hs
bin/gargantext-cli/Main.hs
+5
-1
gargantext.cabal
gargantext.cabal
+2
-13
Lancaster.hs
test/Test/Offline/Stemming/Lancaster.hs
+12
-1
No files found.
bin/gargantext-
golden-file-diff/Main
.hs
→
bin/gargantext-
cli/CLI/FileDiff
.hs
View file @
8d07ed51
module
Main
where
module
CLI.FileDiff
where
import
Prelude
import
CLI.Types
import
Data.List
qualified
as
L
import
Data.Text
qualified
as
T
import
Data.Text.IO
qualified
as
TIO
import
Data.TreeDiff.Class
import
Data.TreeDiff.Pretty
import
qualified
Data.Text
as
T
import
qualified
Data.Text.IO
as
TIO
import
System.Environment
(
getArgs
)
import
System.Exit
(
exitFailure
)
import
Control.Monad
(
unless
)
import
qualified
Data.List
as
L
import
Gargantext.Prelude
(
HasCallStack
,
unless
,
exitFailure
)
import
Options.Applicative
import
Prelude
-- | Renders in a pretty way the content of two golden files. The
-- first file should contain the expected output, the second the
-- actual data generated by the test suite.
main
::
IO
()
main
=
do
(
refPath
:
newPath
:
_
)
<-
getArgs
fileDiffCLI
::
GoldenFileDiffArgs
->
IO
()
fileDiffCLI
(
GoldenFileDiffArgs
refPath
newPath
)
=
do
ref
<-
T
.
lines
<$>
TIO
.
readFile
refPath
new
<-
T
.
lines
<$>
TIO
.
readFile
newPath
...
...
@@ -25,3 +24,17 @@ main = do
unless
(
L
.
null
differences
)
$
do
putStrLn
$
show
$
ansiWlEditExpr
$
ediff'
(
map
fst
differences
)
(
map
snd
differences
)
exitFailure
fileDiffCmd
::
HasCallStack
=>
Mod
CommandFields
CLI
fileDiffCmd
=
command
"golden-file-diff"
(
info
(
helper
<*>
fmap
CLISub
filediff_p
)
(
progDesc
"Compare the output of two golden files."
))
filediff_p
::
Parser
CLICmd
filediff_p
=
fmap
CCMD_golden_file_diff
$
GoldenFileDiffArgs
<$>
(
strOption
(
long
"expected"
<>
metavar
"FILEPATH"
<>
help
"Path to the file containing the expected output."
)
)
<*>
(
strOption
(
long
"actual"
<>
metavar
"FILEPATH"
<>
help
"Path to the file containing the actual output."
)
)
bin/gargantext-cli/CLI/Types.hs
View file @
8d07ed51
...
...
@@ -63,6 +63,11 @@ data UpgradeArgs = UpgradeArgs
{
upgrade_ini
::
!
FilePath
}
deriving
(
Show
,
Eq
)
data
GoldenFileDiffArgs
=
GoldenFileDiffArgs
{
gdf_expected
::
!
FilePath
,
gdf_actual
::
!
FilePath
}
deriving
(
Show
,
Eq
)
data
CLICmd
=
CCMD_clean_csv_corpus
|
CCMD_filter_terms_and_cooc
!
CorpusFile
!
TermListFile
!
OutputFile
...
...
@@ -74,6 +79,7 @@ data CLICmd
|
CCMD_phylo
!
PhyloArgs
|
CCMD_phylo_profile
|
CCMD_upgrade
!
UpgradeArgs
|
CCMD_golden_file_diff
!
GoldenFileDiffArgs
deriving
(
Show
,
Eq
)
data
CLI
=
...
...
bin/gargantext-cli/Main.hs
View file @
8d07ed51
...
...
@@ -30,6 +30,7 @@ import CLI.Invitations (invitationsCLI, invitationsCmd)
import
CLI.Phylo
(
phyloCLI
,
phyloCmd
)
import
CLI.Phylo.Profile
(
phyloProfileCLI
,
phyloProfileCmd
)
import
CLI.Upgrade
(
upgradeCLI
,
upgradeCmd
)
import
CLI.FileDiff
(
fileDiffCLI
,
fileDiffCmd
)
runCLI
::
CLI
->
IO
()
runCLI
=
\
case
...
...
@@ -53,6 +54,8 @@ runCLI = \case
->
phyloProfileCLI
CLISub
(
CCMD_upgrade
args
)
->
upgradeCLI
args
CLISub
(
CCMD_golden_file_diff
args
)
->
fileDiffCLI
args
main
::
IO
()
main
=
runCLI
=<<
execParser
opts
...
...
@@ -72,5 +75,6 @@ allOptions = subparser (
invitationsCmd
<>
phyloCmd
<>
phyloProfileCmd
<>
upgradeCmd
upgradeCmd
<>
fileDiffCmd
)
gargantext.cabal
View file @
8d07ed51
...
...
@@ -700,6 +700,7 @@ executable gargantext-cli
other-modules:
CLI.Admin
CLI.CleanCsvCorpus
CLI.FileDiff
CLI.FilterTermsAndCooc
CLI.Import
CLI.Init
...
...
@@ -736,6 +737,7 @@ executable gargantext-cli
, split ^>= 0.2.3.4
, text ^>= 1.2.4.1
, time ^>= 1.9.3
, tree-diff
, unordered-containers ^>= 0.2.16.0
, vector ^>= 0.7.3
...
...
@@ -983,16 +985,3 @@ benchmark garg-bench
ghc-options: "-with-rtsopts=-T -A32m"
if impl(ghc >= 8.6)
ghc-options: "-with-rtsopts=--nonmoving-gc"
executable garg-golden-file-diff
import:
defaults
, optimized
main-is: Main.hs
hs-source-dirs:
bin/gargantext-golden-file-diff
build-depends:
base
, text
, tree-diff
default-language: Haskell2010
test/Test/Offline/Stemming/Lancaster.hs
View file @
8d07ed51
...
...
@@ -15,7 +15,18 @@ import qualified Data.Text.Encoding as TE
tests
::
TestTree
tests
=
testGroup
"Lancaster"
[
goldenVsStringDiff
"test vector works"
(
\
ref
new
->
[
"cabal"
,
"v2-run"
,
"-v0"
,
"garg-golden-file-diff"
,
"--"
,
ref
,
new
])
"test-data/stemming/lancaster.txt"
mkTestVector
goldenVsStringDiff
"test vector works"
(
\
ref
new
->
[
"cabal"
,
"v2-run"
,
"-v0"
,
"--"
,
"gargantext-cli"
,
"golden-file-diff"
,
"--expected"
,
ref
,
"--actual"
,
new
])
"test-data/stemming/lancaster.txt"
mkTestVector
]
...
...
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