Skip to content

Commit

Permalink
Merge pull request #44 from cabalism/bump/hpack-version-0.36
Browse files Browse the repository at this point in the history
Use hpack-0.36.0 in tests
  • Loading branch information
philderbeast authored Jun 4, 2024
2 parents f679422 + 566545a commit fa70fff
Show file tree
Hide file tree
Showing 54 changed files with 205 additions and 71 deletions.
139 changes: 139 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# NOTE: Dependencies are intentionally not listed.

.PHONY: delete-golden
delete-golden: \
delete-cabal-golden \
delete-json-golden \
delete-yaml-golden

.PHONY: delete-cabal-golden
delete-cabal-golden:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*\.cabal\.golden$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

.PHONY: delete-json-golden
delete-json-golden:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*\.json\.golden$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

.PHONY: delete-yaml-golden
delete-yaml-golden:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*\.yaml\.golden$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

.PHONY: delete-generated
.PHONY: delete-generated-cabal
.PHONY: delete-generated-json
.PHONY: delete-generated-yaml
delete-generated: \
delete-generated-cabal \
delete-generated-json \
delete-generated-yaml

delete-generated-cabal:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*(?<!\.yaml)\.cabal$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

delete-generated-json:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*\.json$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

delete-generated-yaml:
cd test-suite-golden \
&& find -type f \
| grep --perl-regexp ".*(?<!package)\.yaml$$" \
| xargs --no-run-if-empty --max-args=1 --verbose rm

KY := test-suite-golden/test-files/key
RW := test-suite-golden/test-files/real-world

.PHONY: generate-cabal
generate-cabal: \
$(KY)/empty-inferred/empty-inferred.cabal \
$(KY)/empty-package.cabal \
$(KY)/with-GHC2021.cabal \
$(KY)/when-dependencies.cabal \
$(KY)/import-relative/import-relative.cabal \
$(KY)/import-local/import-local.cabal \
$(KY)/empty-inferred/empty-inferred.cabal \
$(RW)/stack/stack.cabal \
$(RW)/hpack/hpack.cabal

$(KY)/empty-package.cabal:
dhall-hpack-cabal --package-dhall=$(@:.cabal=.dhall)

$(KY)/when-dependencies.cabal:
dhall-hpack-cabal --package-dhall=$(@:.cabal=.dhall)

$(KY)/with-GHC2021.cabal:
dhall-hpack-cabal --package-dhall=$(@:.cabal=.dhall)

$(KY)/%.cabal:
cd $(@D) && dhall-hpack-cabal

$(RW)/%.cabal:
dhall-hpack-cabal --package-dhall=$(@:.cabal=.dhall)

.PHONY: generate-json
generate-json: \
$(KY)/empty-inferred/package.json \
$(KY)/empty-package.json \
$(KY)/with-GHC2021.json \
$(KY)/when-dependencies.json \
$(KY)/import-relative/package.json \
$(KY)/import-local/package.json \
$(KY)/empty-inferred/package.json \
$(RW)/stack/stack.json \
$(RW)/hpack/hpack.json

$(KY)/empty-package.json:
dhall-hpack-json --package-dhall=$(@:.json=.dhall) > $@

$(KY)/when-dependencies.json:
dhall-hpack-json --package-dhall=$(@:.json=.dhall) > $@

$(KY)/with-GHC2021.json:
dhall-hpack-json --package-dhall=$(@:.json=.dhall) > $@

$(KY)/%/package.json:
cd $(@D) && dhall-hpack-json > $(@F)

$(RW)/%.json:
dhall-hpack-json --package-dhall=$(@:.json=.dhall) > $@

.PHONY: generate-yaml
generate-yaml: \
$(KY)/empty-inferred/package.yaml \
$(KY)/empty-package.yaml \
$(KY)/with-GHC2021.yaml \
$(KY)/when-dependencies.yaml \
$(KY)/import-relative/package.yaml \
$(KY)/import-local/package.yaml \
$(KY)/empty-inferred/package.yaml \
$(RW)/stack/stack.yaml \
$(RW)/hpack/hpack.yaml

$(KY)/empty-package.yaml:
dhall-hpack-yaml --package-dhall=$(@:.yaml=.dhall) > $@

$(KY)/when-dependencies.yaml:
dhall-hpack-yaml --package-dhall=$(@:.yaml=.dhall) > $@

$(KY)/with-GHC2021.yaml:
dhall-hpack-yaml --package-dhall=$(@:.yaml=.dhall) > $@

$(KY)/%/package.yaml:
cd $(@D) && dhall-hpack-yaml > $(@F)

$(RW)/%.yaml:
dhall-hpack-yaml --package-dhall=$(@:.yaml=.dhall) > $@
4 changes: 2 additions & 2 deletions hpack-dhall.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack

name: hpack-dhall
version: 0.5.7
version: 0.5.8
synopsis: hpack's dhalling
description: Use hpack phrasing in dhall to write cabal files.
.
Expand All @@ -22,7 +22,7 @@ category: Development
homepage: https://github.com/cabalism/hpack-dhall#readme
bug-reports: https://github.com/cabalism/hpack-dhall/issues
maintainer: Phil de Joux <[email protected]>
copyright: © 2018 - 2022 Phil de Joux, © 2018 - 2022 Block Scope Limited
copyright: © 2018 - 2024 Phil de Joux, © 2018 - 2024 Block Scope Limited
license: BSD3
license-file: LICENSE
build-type: Simple
Expand Down
4 changes: 2 additions & 2 deletions package.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ let deps =
in let exe-deps = [ "optparse-applicative" ]

in { name = "hpack-dhall"
, version = "0.5.7"
, version = "0.5.8"
, maintainer = "Phil de Joux <[email protected]>"
, copyright =
"© 2018 - 2022 Phil de Joux, © 2018 - 2022 Block Scope Limited"
"© 2018 - 2024 Phil de Joux, © 2018 - 2024 Block Scope Limited"
, license = "BSD3"
, license-file = "LICENSE"
, category = "Development"
Expand Down
2 changes: 1 addition & 1 deletion project-stackage/lts-20.26.config
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ constraints: abstract-deque ==0.3,
hourglass-orphans ==0.1.0.0,
hp2pretty ==0.10,
-- hpack ==0.35.2,
hpack-dhall ==0.5.7,
-- hpack-dhall ==0.5.7,
hpc installed,
hpc-codecov ==0.3.0.0,
hpc-lcov ==1.1.1,
Expand Down
2 changes: 1 addition & 1 deletion project-stackage/lts-21.25.config
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ constraints: abstract-deque ==0.3,
hourglass-orphans ==0.1.0.0,
hp2pretty ==0.10,
-- hpack ==0.35.2,
hpack-dhall ==0.5.7,
-- hpack-dhall ==0.5.7,
hpc installed,
hpc-codecov ==0.3.0.0,
hpc-lcov ==1.1.1,
Expand Down
17 changes: 12 additions & 5 deletions test-suite-golden/src/Golden.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,47 +55,52 @@ goldenTestSet title dhallFiles = do
[ testGroup ".dhall to .cabal"
[ goldenVsFile
(testName dhallFile)
(cabalFile -<.> goldExt Cabal)
goldenFile
cabalFile
(writeDhallCabal dhallFile)
| dhallFile <- dhallFiles
, let cabalFile = cabalFilePath dhallFile
, let goldenFile = cabalFile -<.> goldExt Cabal
]
, testGroup ".dhall to dhall"
[ goldenVsString
(testName dhallFile)
(dhallFile -<.> goldExt Dhall)
goldenFile
(fmap fromString . showDhall $ dhallFile)
| dhallFile <- dhallFiles
, let goldenFile = dhallFile -<.> goldExt Dhall
]
, testGroup ".dhall to json"
[ goldenVsFile
(testName dhallFile)
(dhallFile -<.> goldExt Json)
goldenFile
jsonFile
(writeJson dhallFile jsonFile)
| dhallFile <- dhallFiles
, let jsonFile = dhallFile -<.> ".json"
, let goldenFile = dhallFile -<.> goldExt Json
]
, testGroup ".dhall to yaml"
[ goldenVsFile
(testName dhallFile)
(dhallFile -<.> goldExt Yaml)
goldenFile
yamlFile
(writeYaml dhallFile yamlFile)
| dhallFile <- dhallFiles
, let yamlFile = dhallFile -<.> ".yaml"
, let goldenFile = dhallFile -<.> goldExt Yaml
]
, testGroup ".yaml to .cabal"
[ goldenVsFile
(testName dhallFile)
(cabalFile -<.> goldExt Cabal)
goldenFile
cabalFile
(writeYamlCabal yamlFile cabalFile yamlCabalFile)
| dhallFile <- dhallFiles
, let yamlFile = dhallFile -<.> ".yaml"
, let cabalFile = cabalFilePath dhallFile
, let yamlCabalFile = yamlFile <.> ".cabal"
, let goldenFile = cabalFile -<.> goldExt Cabal
]
]

Expand Down Expand Up @@ -145,11 +150,13 @@ writeJson :: FilePath -> FilePath -> IO ()
writeJson dhallFile jsonFile = do
s <- showJson Nothing dhallFile
writeFile jsonFile s
appendFile jsonFile $ unlines [""]

writeYaml :: FilePath -> FilePath -> IO ()
writeYaml dhallFile yamlFile = do
s <- showYaml Nothing dhallFile
writeFile yamlFile s
appendFile yamlFile $ unlines [""]

cabalFilePath :: FilePath -> FilePath
cabalFilePath p
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cabal-version: 1.12

-- This file has been generated from package.dhall by hpack version 0.31.0.
-- This file has been generated from package.dhall by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: 9f10239d716ef4564587e29b36c0e3b74056721733790211e20061a86a0feb53

name: empty-inferred
version: 0.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cabal-version: 1.12

-- This file has been generated from package.dhall by hpack version 0.31.0.
-- This file has been generated from package.dhall by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: 9f10239d716ef4564587e29b36c0e3b74056721733790211e20061a86a0feb53

name: empty-inferred
version: 0.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.35.0.
-- This file has been generated from package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}

4 changes: 1 addition & 3 deletions test-suite-golden/test-files/key/empty-package.cabal
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cabal-version: 1.12

-- This file has been generated from empty-package.dhall by hpack version 0.31.0.
-- This file has been generated from empty-package.dhall by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: e0a74f511d829cae53cd712664781db312951dd773249603163ba1b1e32afd04

name: empty-package
version: 0.0.0
Expand Down
4 changes: 1 addition & 3 deletions test-suite-golden/test-files/key/empty-package.cabal.golden
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cabal-version: 1.12

-- This file has been generated from empty-package.dhall by hpack version 0.31.0.
-- This file has been generated from empty-package.dhall by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: e0a74f511d829cae53cd712664781db312951dd773249603163ba1b1e32afd04

name: empty-package
version: 0.0.0
Expand Down
2 changes: 1 addition & 1 deletion test-suite-golden/test-files/key/empty-package.json.golden
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "empty-package"
}
}
1 change: 1 addition & 0 deletions test-suite-golden/test-files/key/empty-package.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
name: empty-package

2 changes: 1 addition & 1 deletion test-suite-golden/test-files/key/empty-package.yaml.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

-- This file has been generated from empty-package.yaml by hpack version 0.35.0.
-- This file has been generated from empty-package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

Expand Down
1 change: 1 addition & 0 deletions test-suite-golden/test-files/key/empty-package.yaml.golden
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
name: empty-package

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cabal-version: 1.12

-- This file has been generated from package.dhall by hpack version 0.31.0.
-- This file has been generated from package.dhall by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: fb3f09267f149cb49eb030ac951c27be9964aa0d51e91460e5b2d59ee1a5082f

name: import-local
version: 0.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
cabal-version: 1.12

-- This file has been generated from package.dhall by hpack version 0.31.0.
-- This file has been generated from package.dhall by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack
--
-- hash: fb3f09267f149cb49eb030ac951c27be9964aa0d51e91460e5b2d59ee1a5082f

name: import-local
version: 0.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "import-local"
}
}
1 change: 1 addition & 0 deletions test-suite-golden/test-files/key/import-local/package.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
name: import-local

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.35.0.
-- This file has been generated from package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
name: import-local

Loading

0 comments on commit fa70fff

Please sign in to comment.