Skip to content

Commit aba4aa5

Browse files
committed
Tests: Recursively look for test cases
1 parent f660bd6 commit aba4aa5

File tree

14 files changed

+35
-2
lines changed

14 files changed

+35
-2
lines changed

fay.cabal

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ extra-source-files: examples/ref.hs examples/alert.hs examples/console.hs examp
136136
tests/HidePreludeImport_Import.hs
137137
tests/HidePreludeImport_Import.res
138138
tests/Hierarchical/Export.hs
139+
tests/Hierarchical/Export.res
139140
tests/Hierarchical/RecordDefined.hs
141+
tests/Hierarchical/RecordDefined.res
140142
tests/HierarchicalImport.hs
141143
tests/HierarchicalImport.res
142144
tests/ImportHiding.hs
@@ -146,23 +148,29 @@ extra-source-files: examples/ref.hs examples/alert.hs examples/console.hs examp
146148
tests/ImportList.hs
147149
tests/ImportList.res
148150
tests/ImportList1/A.hs
151+
tests/ImportList1/A.res
149152
tests/ImportList1/B.hs
153+
tests/ImportList1/B.res
150154
tests/ImportList1/C.hs
155+
tests/ImportList1/C.res
151156
tests/ImportListType.hs
152157
tests/ImportListType.res
153158
tests/ImportType.hs
154159
tests/ImportType.res
155160
tests/ImportType2.hs
156161
tests/ImportType2.res
157162
tests/ImportType2I/A.hs
163+
tests/ImportType2I/A.res
158164
tests/ImportType2I/B.hs
165+
tests/ImportType2I/B.res
159166
tests/infixDataConst.hs
160167
tests/infixDataConst.res
161168
tests/Integral.hs
162169
tests/Integral.res
163170
tests/ints.hs
164171
tests/ints.res
165172
tests/Issue215/B.hs
173+
tests/Issue215/B.res
166174
tests/Issue215A.hs
167175
tests/Issue215A.res
168176
tests/Js2FayFunc.hs
@@ -180,6 +188,7 @@ extra-source-files: examples/ref.hs examples/alert.hs examples/console.hs examp
180188
tests/listlen.hs
181189
tests/listlen.res
182190
tests/ModuleRecordClash/R.hs
191+
tests/ModuleRecordClash/R.res
183192
tests/ModuleRecordClash.hs
184193
tests/Monad.hs
185194
tests/Monad.res
@@ -194,9 +203,11 @@ extra-source-files: examples/ref.hs examples/alert.hs examples/console.hs examp
194203
tests/negation.hs
195204
tests/negation.res
196205
tests/NestedImporting/A.hs
206+
tests/NestedImporting/A.res
197207
tests/NestedImporting.hs
198208
tests/NestedImporting.res
199209
tests/NestedImporting2/A.hs
210+
tests/NestedImporting2/A.res
200211
tests/NestedImporting2.hs
201212
tests/NestedImporting2.res
202213
tests/newtype.hs
@@ -321,7 +332,7 @@ Flag devel
321332
library
322333
hs-source-dirs: src
323334
exposed-modules: Fay, Fay.Types, Language.Fay.FFI, Fay.Convert, Fay.Compiler, Fay.Compiler.Debug, Fay.Compiler.Config
324-
other-modules: Fay.Compiler.Print, Control.Monad.IO, System.Process.Extra, Data.List.Extra, Paths_fay, Fay.Compiler.Misc, Fay.Compiler.FFI, Fay.Compiler.Optimizer, Fay.Compiler.Packages, Fay.Compiler.ModuleScope, Control.Monad.Extra, Fay.Compiler.InitialPass, Fay.Compiler.Decl, Fay.Compiler.Defaults, Fay.Compiler.Exp, Fay.Compiler.Pattern, Fay.Compiler.Typecheck, Fay.Compiler.GADT, Fay.Compiler.QName
335+
other-modules: Fay.Compiler.Print, Control.Monad.IO, System.Process.Extra, System.Directory.Extra, Data.List.Extra, Paths_fay, Fay.Compiler.Misc, Fay.Compiler.FFI, Fay.Compiler.Optimizer, Fay.Compiler.Packages, Fay.Compiler.ModuleScope, Control.Monad.Extra, Fay.Compiler.InitialPass, Fay.Compiler.Decl, Fay.Compiler.Defaults, Fay.Compiler.Exp, Fay.Compiler.Pattern, Fay.Compiler.Typecheck, Fay.Compiler.GADT, Fay.Compiler.QName
325336
ghc-options: -O2 -Wall -fno-warn-name-shadowing
326337
build-depends: base >= 4 && < 5,
327338
aeson,

src/System/Directory/Extra.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
module System.Directory.Extra where
3+
4+
import Control.Monad (forM)
5+
import System.Directory (doesDirectoryExist, getDirectoryContents)
6+
import System.FilePath ((</>))
7+
8+
-- Taken from Real World Haskell
9+
-- http://book.realworldhaskell.org/read/io-case-study-a-library-for-searching-the-filesystem.html
10+
getRecursiveContents :: FilePath -> IO [FilePath]
11+
getRecursiveContents topdir = do
12+
names <- getDirectoryContents topdir
13+
let properNames = filter (`notElem` [".", ".."]) names
14+
paths <- forM properNames $ \name -> do
15+
let path = topdir </> name
16+
isDirectory <- doesDirectoryExist path
17+
if isDirectory
18+
then getRecursiveContents path
19+
else return [path]
20+
return (concat paths)

src/Tests.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Data.Default
1515
import Data.List
1616
import Data.Maybe
1717
import System.Directory
18+
import System.Directory.Extra
1819
import System.Environment
1920
import System.FilePath
2021
import System.Process.Extra
@@ -42,7 +43,7 @@ prefixed f (break f -> (x,y)) = (listToMaybe (drop 1 y),x ++ drop 2 y)
4243
-- | Make the case-by-case unit tests.
4344
makeCompilerTests :: Maybe FilePath -> Maybe FilePath -> IO Test
4445
makeCompilerTests packageConf basePath = do
45-
files <- fmap (map ("tests" </>) . sort . filter (isSuffixOf ".hs")) $ getDirectoryContents "tests"
46+
files <- sort . filter (not . isInfixOf "/Api/") . filter (isSuffixOf ".hs") <$> getRecursiveContents "tests"
4647
return $ testGroup "Tests" $ flip map files $ \file -> testCase file $ do
4748
testFile packageConf basePath False file
4849
testFile packageConf basePath True file

tests/Hierarchical/Export.res

Whitespace-only changes.

tests/Hierarchical/RecordDefined.res

Whitespace-only changes.

tests/ImportList1/A.res

Whitespace-only changes.

tests/ImportList1/B.res

Whitespace-only changes.

tests/ImportList1/C.res

Whitespace-only changes.

tests/ImportType2I/A.res

Whitespace-only changes.

tests/ImportType2I/B.res

Whitespace-only changes.

0 commit comments

Comments
 (0)