Skip to content

Commit 28a32b1

Browse files
committed
Merge pull request #11 from diffr/issue-10
closes #10: Setup HTF and QuickCheck. closes #12: Enable Travis CI.
2 parents 51b2118 + 0687099 commit 28a32b1

File tree

9 files changed

+126
-47
lines changed

9 files changed

+126
-47
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: haskell
2+
notifications:
3+
email: false

AUTHORS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
Amaury Couste <[email protected]>
22
Jakub Kozlowski <[email protected]>
33
William Martin <[email protected]>
4-

INSTALL.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
Installation Instructions
22
=========================
3-
This program is written in Haskell and built using cabal.
3+
4+
This program is written in Haskell and built using (cabal)[http://www.haskell.org/cabal/].
5+
6+
It is suggested that (cabal-dev)[http://hackage.haskell.org/package/cabal-dev] be used as
7+
it provides a sandboxed, per-project dependency management, which leads to less issues with
8+
conflicting library versions.
9+
410
To build, you will need:
511
* haskell-platform
12+
* cabal (or cabal-dev)
13+
14+
If you're on a mac, check out (homebrew)[http://mxcl.github.io/homebrew/].
615

716
#### Building
817

@@ -19,7 +28,7 @@ Optionally:
1928
#### Testing
2029

2130
1. Run "cabal clean".
22-
2. Run "cabal configure".
31+
2. Run "cabal configure --enable-tests".
2332
3. Run "cabal build" to compile the sources to dist/.
2433
4. Run "cabal test" to run the tests.
2534

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
diffr-h
22
=======
3+
[![Build Status](https://travis-ci.org/diffr/diffr-h.png)](https://travis-ci.org/diffr/diffr-h)
4+
35
An intelligent diff/patch tool that knows how to copy and move, has an 'r' at the end of its name and is written in Haskell.
46

57
* See AUTHORS for the details on who contributed to this awesome project.

diffr.cabal

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
1-
name: diffr
2-
version: 0.1
3-
description: Intelligent diff/patch tool that knows how to copy and move, has an 'r' at the end of its name.
4-
license: GPL-3
5-
license-file: LICENCE
6-
author: Amaury Couste, Jakub Kozlowski, William Martin
7-
maintainer:
8-
build-Type: Simple
9-
cabal-Version: >=1.2
1+
name: diffr
2+
version: 0.1
3+
description: Intelligent diff/patch tool that knows how to copy and move, has an 'r' at the end of its name.
4+
license: GPL-3
5+
license-file: LICENCE
6+
author: Amaury Couste, Jakub Kozlowski, William Martin
7+
maintainer:
8+
build-Type: Simple
9+
cabal-Version: >=1.2
1010

1111
executable diffr
12-
hs-source-dirs: src
13-
main-is: Diffr/Main.hs
14-
build-Depends:
12+
hs-source-dirs: src
13+
main-is: Diffr/Main.hs
14+
build-Depends:
1515
base >= 4,
1616
cmdargs > 0.10
17-
ghc-options: -Wall
18-
other-modules: Diffr.Util
17+
ghc-options: -Wall
18+
other-modules: Diffr.Util
19+
20+
test-suite TestSuite
21+
type: exitcode-stdio-1.0
22+
main-is: TestSuite.hs
23+
ghc-options: -Wall -rtsopts
24+
build-depends: base >= 4, HTF > 0.9
25+
other-modules:
26+
Diffr.Util,
27+
Diffr.UtilTest
28+
hs-source-dirs:
29+
test,
30+
src
31+

src/Diffr/Main.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{-# LANGUAGE DeriveDataTypeable, RecordWildCards #-}
1+
{-# LANGUAGE DeriveDataTypeable #-}
22
{- |
33
Module : Main
44
Description : Main entry point for Diffr.
@@ -21,9 +21,9 @@
2121

2222
module Main(main) where
2323

24-
import System.Environment ( getArgs, withArgs )
25-
import qualified System.Console.CmdArgs as CM
26-
import qualified Diffr.Util as DU
24+
import qualified Diffr.Util as DU
25+
import qualified System.Console.CmdArgs as CM
26+
import System.Environment (getArgs, withArgs)
2727

2828
main :: IO ()
2929
main = do

src/Diffr/Util.hs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
-}
2121
module Diffr.Util (
2222
DConfig(..)
23-
, diffrModes
23+
, diffrModes
2424
) where
2525

26-
import System.Console.CmdArgs
26+
import System.Console.CmdArgs
2727

2828
{-| Static values -}
29-
_PROGRAM_NAME, _PROGRAM_VERSION,
29+
_PROGRAM_NAME, _PROGRAM_VERSION,
3030
_PROGRAM_INFO, _PROGRAM_ABOUT, _COPYRIGHT :: String
3131
_PROGRAM_NAME = "diffr"
3232
_PROGRAM_VERSION = "0.1"
@@ -43,48 +43,48 @@ _COPYRIGHT = "(C) diffr 2013"
4343
{-| Configuration for running diffr's commands -}
4444
data DConfig =
4545

46-
-- | Configuration for running diff command
47-
Diff { -- | Path to the 'base' file we will diff against
46+
-- | Configuration for running diff command
47+
Diff { -- | Path to the 'base' file we will diff against
4848
baseFile :: FilePath
49-
50-
-- | Path to the 'new' file we will compare to 'base' file
51-
, newFile :: FilePath
52-
49+
50+
-- | Path to the 'new' file we will compare to 'base' file
51+
, newFile :: FilePath
52+
5353
-- | Path to the output file where to write the diff file
5454
, dOutFile :: Maybe FilePath
5555
}
56-
57-
-- | Configuration for running patch command
56+
57+
-- | Configuration for running patch command
5858
| Patch { -- | Path to the 'original' file we will apply patch to
5959
originalFile :: FilePath
60-
60+
6161
-- | Path to the 'patch' file we will apply to 'originalFile'
6262
, patchFile :: FilePath
63-
63+
6464
-- | Path to the output file where to write the patched file
6565
, pOutFile :: Maybe FilePath
66-
} deriving (Show, Data, Typeable)
66+
} deriving (Eq, Show, Data, Typeable)
6767

6868
{-| Annotate the 'Diff' configuration -}
6969
diff :: DConfig
7070
diff = Diff
71-
{ baseFile = def &= argPos 0
72-
&= typ "BASEFILE"
73-
, newFile = def &= argPos 1
74-
&= typ "NEWFILE"
75-
, dOutFile = def &= help "path to the output file"
71+
{ baseFile = def &= argPos 0
72+
&= typ "BASEFILE"
73+
, newFile = def &= argPos 1
74+
&= typ "NEWFILE"
75+
, dOutFile = def &= help "path to the output file"
7676
&= name "output-file" &= typFile
7777
}
78-
78+
7979
{-| Annotate the 'Patch' configuration -}
8080
patch :: DConfig
8181
patch = Patch
82-
{ originalFile = def &= argPos 0
83-
&= typ "ORIGINALFILE"
82+
{ originalFile = def &= argPos 0
83+
&= typ "ORIGINALFILE"
8484
, patchFile = def &= argPos 1
85-
&= typ "PATCHFILE"
86-
, pOutFile = def &= help "Path to the output file where to write the patched file"
87-
&= name "output-file"
85+
&= typ "PATCHFILE"
86+
, pOutFile = def &= help "Path to the output file where to write the patched file"
87+
&= name "output-file"
8888
&= typFile
8989
}
9090

@@ -96,4 +96,4 @@ diffrModes = cmdArgsMode $ modes [diff, patch]
9696
&= help _PROGRAM_ABOUT
9797
&= helpArg [explicit, name "help", name "h"]
9898
&= program _PROGRAM_NAME
99-
99+

test/Diffr/UtilTest.hs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{-# OPTIONS_GHC -F -pgmF htfpp #-}
2+
{- |
3+
Module : UtilTest
4+
Description : Tests 'Diffr.Util'.
5+
Since : 0.1
6+
Authors : William Martin, Jakub Kozlowski
7+
License : This file is part of diffr-h.
8+
9+
diffr-h is free software: you can redistribute it and/or modify
10+
it under the terms of the GNU General Public License as published by
11+
the Free Software Foundation, either version 3 of the License, or
12+
(at your option) any later version.
13+
14+
diffr-h is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
GNU General Public License for more details.
18+
You should have received a copy of the GNU General Public License
19+
along with diffr-h. If not, see <http://www.gnu.org/licenses/>.
20+
-}
21+
module Diffr.UtilTest where
22+
23+
import qualified Diffr.Util as DU
24+
import Test.Framework
25+
import Test.Framework.TestManager
26+
27+
-- | Example QuickCheck test
28+
prop_config :: FilePath -> FilePath -> FilePath -> Bool
29+
prop_config base new out = config == config
30+
where config = DU.Diff { DU.baseFile = base, DU.newFile = new, DU.dOutFile = Just out}
31+
32+
-- | Test fixture
33+
defaultConfig :: DU.DConfig
34+
defaultConfig = DU.Diff { DU.baseFile = "original.txt", DU.newFile = "original-1.txt", DU.dOutFile = Nothing}
35+
36+
-- | Example assertion test
37+
test_oddSquareSum :: Assertion
38+
test_oddSquareSum = do assertEqual defaultConfig defaultConfig
39+
assertEqual True True

test/TestSuite.hs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{-# OPTIONS_GHC -F -pgmF htfpp #-}
2+
module Main where
3+
4+
5+
import Test.Framework
6+
7+
{-|
8+
Simply import the test classes,
9+
in order for them to be run.
10+
-}
11+
import {-@ HTF_TESTS @-} Diffr.UtilTest
12+
13+
main :: IO()
14+
main = htfMain htf_importedTests

0 commit comments

Comments
 (0)