Skip to content

Commit

Permalink
Fix the golden test's interaction with cabal-fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
alunduil committed Aug 30, 2023
1 parent d50c7f5 commit a90675f
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 60 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ repos:
entry: cabal-fmt
language: system
files: '\.cabal$'
exclude: '\.golden\.cabal$'
args: ["-i"]
4 changes: 2 additions & 2 deletions lib/initialise/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Control.Monad.Catch (throwM)
import Control.Monad.Reader (asks, liftIO)
import Data.ByteString (ByteString, readFile)
import Data.Text (unpack)
import Distribution.Fields (CommentPosition (NoComment), Field, fromParsecFields, readFields, showFields)
import Distribution.Fields (CommentPosition (CommentBefore), Field, fromParsecFields, readFields, showFields)
import Distribution.Parsec.Position (Position)
import Initialise (Initialise)
import System.Directory.Extra (removeFile)
Expand All @@ -33,7 +33,7 @@ replace path = do
convert :: ByteString -> Initialise String
convert contents = do
fs <- either throwM pure (readFields contents)
showFields (const NoComment) . fromParsecFields <$> convert' fs
showFields (const $ CommentBefore []) . fromParsecFields <$> convert' fs

convert' :: [Field Position] -> Initialise [Field Position]
convert' fs = mapM_ (liftIO . print) fs >> pure fs
Expand Down
116 changes: 58 additions & 58 deletions test/initialise/data/templatise-20230829.golden.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -10,82 +10,82 @@ stability: alpha
homepage: https://github.com/alunduil/template.hs
bug-reports: https://github.com/alunduil/template.hs/issues
synopsis:
You can use template.hs to create a new Haskell GitHub repository.
You can use template.hs to create a new Haskell GitHub repository.

description:
You can use template.hs to create a new GitHub repository. The repository will
have Haskell, VS Code devcontainers, and various GitHub actions ready to use.
You can use template.hs to create a new GitHub repository. The repository will
have Haskell, VS Code devcontainers, and various GitHub actions ready to use.

category: VSCode
tested-with: GHC ==9.2.8 || ==9.4.5 || ==9.6.2
extra-source-files:
CHANGELOG.md
README.md
CHANGELOG.md
README.md

source-repository head
type: git
location: https://github.com/alunduil/template.hs
type: git
location: https://github.com/alunduil/template.hs

common initialise-common
build-depends:
, base ^>=4.16.4.0 || ^>=4.17.0.0 || ^>=4.18.0.0
, bytestring ^>=0.11.4.0 || ^>=0.12.0.2
, Cabal-syntax ^>=3.10.1.0
, filepath ^>=1.4.2.2
, mtl ^>=2.2.2 || ^>=2.3.1
, network-uri ^>=2.6.4.1 || ^>=2.7.0.0
, optparse-applicative ^>=0.18.1.0
, text ^>=2.0.2
build-depends:
, base ^>=4.16.4.0 || ^>=4.17.0.0 || ^>=4.18.0.0
, bytestring ^>=0.11.4.0 || ^>=0.12.0.2
, Cabal-syntax ^>=3.10.1.0
, filepath ^>=1.4.2.2
, mtl ^>=2.2.2 || ^>=2.3.1
, network-uri ^>=2.6.4.1 || ^>=2.7.0.0
, optparse-applicative ^>=0.18.1.0
, text ^>=2.0.2

library initialise-library
import: initialise-common
exposed-modules:
Cabal
Configuration
Defaults
Git
Initialise
import: initialise-common
exposed-modules:
Cabal
Configuration
Defaults
Git
Initialise

build-depends:
, exceptions ^>=0.10.5
, extra ^>=1.7.14
, parsec ^>=3.1.16.1
, process ^>=1.6.16.0
, time ^>=1.11.1.1 || ^>=1.12.2
build-depends:
, exceptions ^>=0.10.5
, extra ^>=1.7.14
, parsec ^>=3.1.16.1
, process ^>=1.6.16.0
, time ^>=1.11.1.1 || ^>=1.12.2

hs-source-dirs: lib/initialise
default-language: Haskell2010
ghc-options: -Wall
hs-source-dirs: lib/initialise
default-language: Haskell2010
ghc-options: -Wall

test-suite initialise-test
import: initialise-common
type: exitcode-stdio-1.0
main-is: Main.hs
build-depends:
, hspec ^>=2.11.4
, initialise-library
, tasty ^>=1.4.3
, tasty-golden ^>=2.3.5
, tasty-hspec ^>=1.2.0.4
import: initialise-common
type: exitcode-stdio-1.0
main-is: Main.hs
build-depends:
, hspec ^>=2.11.4
, initialise-library
, tasty ^>=1.4.3
, tasty-golden ^>=2.3.5
, tasty-hspec ^>=1.2.0.4

other-modules:
CabalGolden
ConfigurationSpec
DefaultsSpec
GitSpec
other-modules:
CabalGolden
ConfigurationSpec
DefaultsSpec
GitSpec

hs-source-dirs: test/initialise
default-language: Haskell2010
ghc-options: -threaded -Wall
hs-source-dirs: test/initialise
default-language: Haskell2010
ghc-options: -threaded -Wall

executable initialise
main-is: Main.hs
build-depends:
, base ^>=4.16.4.0 || ^>=4.17.0.0 || ^>=4.18.0.0
, http-client ^>=0.7.13.1
, http-conduit ^>=2.3.8.3
, initialise-library
main-is: Main.hs
build-depends:
, base ^>=4.16.4.0 || ^>=4.17.0.0 || ^>=4.18.0.0
, http-client ^>=0.7.13.1
, http-conduit ^>=2.3.8.3
, initialise-library

hs-source-dirs: bin/initialise
default-language: Haskell2010
ghc-options: -threaded -Wall
hs-source-dirs: bin/initialise
default-language: Haskell2010
ghc-options: -threaded -Wall

0 comments on commit a90675f

Please sign in to comment.