Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tests to centralise the test main for CI #199

Merged
merged 2 commits into from Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -42,7 +42,6 @@ dist-package/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
Expand Down
1 change: 1 addition & 0 deletions build_config/stack-local.yaml
Expand Up @@ -17,6 +17,7 @@ packages:
- location: ../project
- location: ../syntax/text/parser
- location: ../syntax/text/lexer
- location: ../lib/ci
- location: ../../libs/container
- location: ../../libs/convert
- location: ../../libs/data-base
Expand Down
1 change: 1 addition & 0 deletions core/package.yaml
Expand Up @@ -32,6 +32,7 @@ tests:
source-dirs: test/spec
dependencies:
- luna-core
- luna-ci
- directory
- filepath
- hspec
Expand Down
22 changes: 2 additions & 20 deletions core/test/spec/Main.hs
Expand Up @@ -2,28 +2,10 @@ module Main where

import Prelude

import Data.Maybe (fromJust, isJust)
import System.Directory (createDirectoryIfMissing)
import System.Environment (lookupEnv)
import System.FilePath ((</>))
import qualified Luna.CI as CI

import Test.Hspec.Runner
import Test.Hspec.Formatters.Jenkins
import qualified Spec


main :: IO ()
main = do
buildInCI <- isJust <$> lookupEnv "CIRCLECI"

config <-
if buildInCI then do
-- if in CI, CIRCLE_TEST_REPORTS is always defined
circleTestPath <- fmap fromJust $ lookupEnv "CIRCLE_TEST_REPORTS"
let testPath = circleTestPath </> "hspec"
createDirectoryIfMissing True testPath
return $ defaultConfig { configFormatter = Just xmlFormatter
, configOutputFile = Right $ testPath </> "output.xml" }
else return defaultConfig
main = CI.main Spec.spec

hspecWith config Spec.spec
Empty file added lib/.gitkeep
Empty file.
62 changes: 62 additions & 0 deletions lib/ci/package.yaml
@@ -0,0 +1,62 @@
name: luna-ci
version: "0.1"
author: Luna Team <contact@luna-lang.org>
maintainer: Luna Team <contact@luna-lang.org>

library:
source-dirs:
- src

dependencies:
- base
- hspec
- hspec-jenkins
- directory
- filepath

default-extensions:
- AllowAmbiguousTypes
- ApplicativeDo
- Arrows
- BangPatterns
- BinaryLiterals
- ConstraintKinds
- DataKinds
- DefaultSignatures
- DeriveDataTypeable
- DeriveFoldable
- DeriveFunctor
- DeriveGeneric
- DeriveTraversable
- DoAndIfThenElse
- DuplicateRecordFields
- EmptyDataDecls
- FlexibleContexts
- FlexibleInstances
- FunctionalDependencies
- GeneralizedNewtypeDeriving
- InstanceSigs
- LambdaCase
- MonadComprehensions
- MultiWayIf
- NamedWildCards
- NegativeLiterals
- NoImplicitPrelude
- NumDecimals
- OverloadedLabels
- PackageImports
- QuasiQuotes
- RankNTypes
- RecursiveDo
- ScopedTypeVariables
- StandaloneDeriving
- TemplateHaskell
- TupleSections
- TypeApplications
- TypeFamilies
- TypeFamilyDependencies
- TypeOperators
- ViewPatterns

- LiberalTypeSynonyms
- RelaxedPolyRec
29 changes: 29 additions & 0 deletions lib/ci/src/Luna/CI.hs
@@ -0,0 +1,29 @@
module Luna.CI where

import Prelude

import Data.Maybe (fromJust, isJust)
import System.Directory (createDirectoryIfMissing)
import System.Environment (lookupEnv)
import System.FilePath ((</>))

import Test.Hspec
import Test.Hspec.Runner
import Test.Hspec.Formatters.Jenkins

main :: Spec -> IO ()
main spec = do
buildInCI <- isJust <$> lookupEnv "CIRCLECI"

config <-
if buildInCI then do
-- if in CI, CIRCLE_TEST_REPORTS is always defined
circleTestPath <- fmap fromJust $ lookupEnv "CIRCLE_TEST_REPORTS"
let testPath = circleTestPath </> "hspec"
createDirectoryIfMissing True testPath
return $ defaultConfig { configFormatter = Just xmlFormatter
, configOutputFile = Right $ testPath </> "output.xml" }
else return defaultConfig

hspecWith config spec

1 change: 1 addition & 0 deletions passes/package.yaml
Expand Up @@ -26,6 +26,7 @@ tests:
- luna-parser
- luna-lexer
- luna-stdlib
- luna-ci
- directory
- filepath
- hspec
Expand Down
22 changes: 2 additions & 20 deletions passes/test/spec/Main.hs
Expand Up @@ -2,28 +2,10 @@ module Main where

import Prelude

import Data.Maybe (fromJust, isJust)
import System.Directory (createDirectoryIfMissing)
import System.Environment (lookupEnv)
import System.FilePath ((</>))
import qualified Luna.CI as CI

import Test.Hspec.Runner
import Test.Hspec.Formatters.Jenkins
import qualified Spec


main :: IO ()
main = do
buildInCI <- isJust <$> lookupEnv "CIRCLECI"

config <-
if buildInCI then do
-- if in CI, CIRCLE_TEST_REPORTS is always defined
circleTestPath <- fmap fromJust $ lookupEnv "CIRCLE_TEST_REPORTS"
let testPath = circleTestPath </> "hspec"
createDirectoryIfMissing True testPath
return $ defaultConfig { configFormatter = Just xmlFormatter
, configOutputFile = Right $ testPath </> "output.xml" }
else return defaultConfig
main = CI.main Spec.spec

hspecWith config Spec.spec
1 change: 1 addition & 0 deletions stack.yaml
Expand Up @@ -17,4 +17,5 @@ packages:
- location: project
- location: syntax/text/parser
- location: syntax/text/lexer
- location: lib/ci
resolver: ./build_config/luna-snapshot.yaml
2 changes: 1 addition & 1 deletion syntax/text/parser/package.yaml
Expand Up @@ -16,14 +16,14 @@ tests:
- luna-core
- luna-parser
- luna-lexer
- luna-ci
- directory
- filepath
- hspec
- hspec-megaparsec
- hspec-jenkins
- open-browser


dependencies:
- base
- luna-core
Expand Down
22 changes: 2 additions & 20 deletions syntax/text/parser/test/spec/Main.hs
Expand Up @@ -2,28 +2,10 @@ module Main where

import Prelude

import Data.Maybe (fromJust, isJust)
import System.Directory (createDirectoryIfMissing)
import System.Environment (lookupEnv)
import System.FilePath ((</>))
import qualified Luna.CI as CI

import Test.Hspec.Runner
import Test.Hspec.Formatters.Jenkins
import qualified Spec


main :: IO ()
main = do
buildInCI <- isJust <$> lookupEnv "CIRCLECI"

config <-
if buildInCI then do
-- if in CI, CIRCLE_TEST_REPORTS is always defined
circleTestPath <- fmap fromJust $ lookupEnv "CIRCLE_TEST_REPORTS"
let testPath = circleTestPath </> "hspec"
createDirectoryIfMissing True testPath
return $ defaultConfig { configFormatter = Just xmlFormatter
, configOutputFile = Right $ testPath </> "output.xml" }
else return defaultConfig
main = CI.main Spec.spec

hspecWith config Spec.spec