Skip to content

Commit

Permalink
Merge pull request #34 from mbj/add/stack-yaml-env-sensitivity
Browse files Browse the repository at this point in the history
Add STACK_YAML sensitivity to dependencies tracking
  • Loading branch information
mbj committed Nov 20, 2020
2 parents daacc48 + 0beea6e commit 5d7846e
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 67 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
os: [ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-haskell@2215b2cb657e9dd555e7d634509d859983e7aa1e
- uses: actions/setup-haskell@v1
with:
enable-stack: true
ghc-version: ${{ matrix.ghc }}
stack-version: '2.3'
stack-version: '2.5.1'
- name: Setup stack
run: |
stack config set install-ghc false
Expand Down
8 changes: 0 additions & 8 deletions app/Main.hs

This file was deleted.

32 changes: 3 additions & 29 deletions devtools.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.18
--
-- see: https://github.com/sol/hpack
--
-- hash: f4e4b379c093455d9e68f7eb7aa3181435b0f51b61584906ff523a3f6315afbc
-- hash: 28160fc04e20acffdb935a7fe9d603e6dc99612264c2fe23c6bab134280907af

name: devtools
version: 0.0.3
Expand Down Expand Up @@ -63,35 +63,9 @@ library
ghc-options: -Wwarn
default-language: Haskell2010

executable devtools
main-is: app/Main.hs
other-modules:
Paths_devtools
default-extensions: DerivingStrategies LambdaCase NoImplicitPrelude OverloadedStrings RecordWildCards StrictData
ghc-options: -Wall -Wcompat -Widentities -Wimplicit-prelude -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-exported-signatures -Wmissing-local-signatures -Wmonomorphism-restriction -Wredundant-constraints -fplugin=SourceConstraints -funbox-strict-fields -optP-Wno-nonportable-include-path -rtsopts -threaded -with-rtsopts=-N
build-depends:
Diff >0.3 && <0.5
, base >4.12 && <4.14
, bytestring >=0.10 && <0.11
, cmdargs >=0.10.20 && <0.11
, devtools
, filepath >=1.4 && <1.5
, hlint >3.1 && <4
, mprelude >=0.2.0 && <0.3
, source-constraints >=0.0.1 && <0.1
, tasty >=1.3.1 && <1.4
, tasty-mgolden >=0.0.1 && <0.1
, text >=1.2 && <1.3
, typed-process >=0.2 && <0.3
if flag(development)
ghc-options: -Werror
else
ghc-options: -Wwarn
default-language: Haskell2010

test-suite devtools-test
test-suite test
type: exitcode-stdio-1.0
main-is: app/Main.hs
main-is: test/Test.hs
other-modules:
Paths_devtools
default-extensions: DerivingStrategies LambdaCase NoImplicitPrelude OverloadedStrings RecordWildCards StrictData
Expand Down
9 changes: 3 additions & 6 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,12 @@ when:
else:
ghc-options: -Wwarn

executables:
devtools: &devtools
main: app/Main.hs
tests:
test:
main: test/Test.hs
ghc-options:
- -rtsopts
- -threaded
- -with-rtsopts=-N
dependencies:
- devtools

tests:
devtools-test: *devtools
16 changes: 10 additions & 6 deletions src/Devtools.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ defaultMain = main defaultConfig
main :: Config -> IO ()
main config = do
putStrLn empty
Tasty.defaultMain $ testTree config
Tasty.defaultMain =<< testTree config

testTree :: Config -> Tasty.TestTree
testTree Config{..} = Tasty.testGroup "devtools"
[ Dependencies.testTree targets
, HLint.testTree hlintArguments
]
testTree :: Config -> IO Tasty.TestTree
testTree Config{..} = do
filename <- Dependencies.getFilename

pure $ Tasty.testGroup
"devtools"
[ Dependencies.testTree filename targets
, HLint.testTree hlintArguments
]
27 changes: 20 additions & 7 deletions src/Devtools/Dependencies.hs
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
module Devtools.Dependencies (testTree) where
module Devtools.Dependencies
( getFilename
, testTree
)
where

import Data.Tuple (fst)
import Devtools.Config
import Devtools.Prelude
import System.FilePath (FilePath, (</>))

import qualified Data.ByteString.Lazy as LBS
import qualified Data.Text.Encoding as Text
import qualified System.Environment as Environment
import qualified System.FilePath as FilePath
import qualified System.Process.Typed as Process
import qualified Test.Tasty as Tasty
import qualified Test.Tasty.MGolden as Tasty

testTree :: [Target] -> Tasty.TestTree
testTree targets =
Tasty.goldenTest
"dependencies"
"test/stack-dependencies.txt"
readDependenciesText
testTree :: FilePath -> [Target] -> Tasty.TestTree
testTree filename targets =
Tasty.goldenTest "dependencies" filename readDependenciesText
where
readDependenciesText :: IO Text
readDependenciesText
Expand All @@ -31,3 +35,12 @@ testTree targets =
, "dependencies"
, "--test"
] <> (targetString <$> targets)

getFilename :: IO FilePath
getFilename = do
prefix <- getPrefix
pure $ "test" </> prefix <> "-dependencies.txt"
where
getPrefix
= maybe "stack" (FilePath.dropExtension . FilePath.takeFileName)
<$> Environment.lookupEnv "STACK_YAML"
14 changes: 5 additions & 9 deletions test/Test.hs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import MPrelude
module Main (main) where

import System.IO (IO)
import Test.Tasty
import Test.Tasty.MGolden

main :: IO ()
main = defaultMain tests
import qualified Devtools

tests :: TestTree
tests = testGroup "mgolden tests"
[ goldenTest "test/expected/foo.txt" $ pure "foo\nbar\n"
]
main :: IO ()
main = Devtools.main Devtools.defaultConfig
File renamed without changes.

0 comments on commit 5d7846e

Please sign in to comment.