Skip to content

Commit

Permalink
Parallelize the test suite (for real this time) (#374)
Browse files Browse the repository at this point in the history
This is a better attempt at fixing #123 in which I use `tasty-1.2`'s
new API for expressing test dependencies. (I previously attempted to
parallelize the test suite in commit
7962d08, but that ended
disastrously. See
#123 (comment)
for more details.)

I also use `-maxN16` this time instead of `-N`. It's unclear how well
this scales, so I decided to be cautious at cap it off at 16. Testing
this locally on my machine, using `-maxN16` reduces the build time
from about 90 to 15 seconds, which is pretty nice in its own right.
(If more adventurous users want to attempt using more threads, they
can always override this themselves.)
  • Loading branch information
RyanGlScott authored Dec 3, 2018
1 parent 4f6dc86 commit 5968d93
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ install:
- "echo ' type: git' >> cabal.project"
- "echo ' location: https://github.com/goldfirere/th-desugar' >> cabal.project"
- "echo ' tag: 567145eddeb5f6692a75e74d4a2dc575b1ad6f29' >> cabal.project"
- "printf 'write-ghc-environment-files: always' >> cabal.project"
- touch cabal.project.local
- "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- singletons | grep -vw -- accept-all | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
- cat cabal.project || true
Expand Down Expand Up @@ -112,6 +113,7 @@ script:
- "echo ' type: git' >> cabal.project"
- "echo ' location: https://github.com/goldfirere/th-desugar' >> cabal.project"
- "echo ' tag: 567145eddeb5f6692a75e74d4a2dc575b1ad6f29' >> cabal.project"
- "printf 'write-ghc-environment-files: always' >> cabal.project"
- touch cabal.project.local
- "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | grep -vw -- singletons | grep -vw -- accept-all | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
- cat cabal.project || true
Expand Down
4 changes: 2 additions & 2 deletions singletons.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ library
test-suite singletons-test-suite
type: exitcode-stdio-1.0
hs-source-dirs: tests
ghc-options: -Wall
ghc-options: -Wall -threaded -with-rtsopts=-maxN16
default-language: Haskell2010
main-is: SingletonsTestSuite.hs
other-modules: ByHand
Expand All @@ -155,5 +155,5 @@ test-suite singletons-test-suite
filepath >= 1.3,
process >= 1.1,
singletons,
tasty >= 0.6,
tasty >= 1.2,
tasty-golden >= 2.2
61 changes: 39 additions & 22 deletions tests/SingletonsTestSuite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ module Main (
main
) where

import Test.Tasty ( TestTree, defaultMain, testGroup )
import Test.Tasty ( DependencyType(..), TestTree
, after, defaultMain, testGroup )
import SingletonsTestSuiteUtils ( compileAndDumpStdTest, compileAndDumpTest
, testCompileAndDumpGroup, ghcOpts
-- , cleanFiles
)
, testCompileAndDumpGroup, ghcOpts )

main :: IO ()
main = do
-- cleanFiles We really need to parallelize the testsuite.
defaultMain tests
main = defaultMain tests

tests :: TestTree
tests =
Expand All @@ -21,29 +18,44 @@ tests =
, compileAndDumpStdTest "Empty"
, compileAndDumpStdTest "Maybe"
, compileAndDumpStdTest "BoxUnBox"
, compileAndDumpStdTest "Operators"
, compileAndDumpStdTest "HigherOrder"
, afterSingletonsNat .
compileAndDumpStdTest "Operators"
, afterSingletonsNat .
compileAndDumpStdTest "HigherOrder"
, compileAndDumpStdTest "Contains"
, compileAndDumpStdTest "AsPattern"
, compileAndDumpStdTest "DataValues"
, compileAndDumpStdTest "EqInstances"
, afterSingletonsNat .
compileAndDumpStdTest "AsPattern"
, afterSingletonsNat .
compileAndDumpStdTest "DataValues"
, after AllSucceed "$3 == \"Empty\"" .
after AllSucceed "$3 == \"Operators\"" .
compileAndDumpStdTest "EqInstances"
, compileAndDumpStdTest "CaseExpressions"
, compileAndDumpStdTest "Star"
, compileAndDumpStdTest "ReturnFunc"
, afterSingletonsNat .
compileAndDumpStdTest "Star"
, afterSingletonsNat .
compileAndDumpStdTest "ReturnFunc"
, compileAndDumpStdTest "Lambdas"
, compileAndDumpStdTest "LambdasComprehensive"
, afterSingletonsNat .
compileAndDumpStdTest "LambdasComprehensive"
, compileAndDumpStdTest "Error"
, compileAndDumpStdTest "TopLevelPatterns"
, compileAndDumpStdTest "LetStatements"
, afterSingletonsNat .
compileAndDumpStdTest "LetStatements"
, compileAndDumpStdTest "LambdaCase"
, compileAndDumpStdTest "Sections"
, compileAndDumpStdTest "PatternMatching"
, afterSingletonsNat .
compileAndDumpStdTest "Sections"
, afterSingletonsNat .
compileAndDumpStdTest "PatternMatching"
, compileAndDumpStdTest "Records"
, compileAndDumpStdTest "T29"
, compileAndDumpStdTest "T33"
, compileAndDumpStdTest "T54"
, compileAndDumpStdTest "Classes"
, compileAndDumpStdTest "Classes2"
, afterSingletonsNat .
compileAndDumpStdTest "Classes"
, afterSingletonsNat .
after AllSucceed "$3 == \"Classes\"" .
compileAndDumpStdTest "Classes2"
, compileAndDumpStdTest "FunDeps"
, compileAndDumpStdTest "T78"
, compileAndDumpStdTest "OrdDeriving"
Expand Down Expand Up @@ -107,17 +119,22 @@ tests =
testCompileAndDumpGroup "Promote"
[ compileAndDumpStdTest "Constructors"
, compileAndDumpStdTest "GenDefunSymbols"
, compileAndDumpStdTest "Newtypes"
, afterSingletonsNat .
compileAndDumpStdTest "Newtypes"
, compileAndDumpStdTest "Pragmas"
, compileAndDumpStdTest "Prelude"
, compileAndDumpStdTest "T180"
, compileAndDumpStdTest "T361"
],
testGroup "Database client"
[ compileAndDumpTest "GradingClient/Database" ghcOpts
, compileAndDumpTest "GradingClient/Main" ghcOpts
, after AllSucceed "$3 == \"Database\"" $
compileAndDumpTest "GradingClient/Main" ghcOpts
],
testCompileAndDumpGroup "InsertionSort"
[ compileAndDumpStdTest "InsertionSortImp"
]
]

afterSingletonsNat :: TestTree -> TestTree
afterSingletonsNat = after AllSucceed "$3 == \"Nat\""

0 comments on commit 5968d93

Please sign in to comment.