Skip to content

Commit 51c22e4

Browse files
authored
Use normalized filepaths in dhall testsuite (#2593)
* Updated hnix dependencies in all Stack configurations Also added `mkParsec` method to MonadParsec instance for megaparsec>=9.4 * Require turtle >=1.6 * Removed depecated functions * Use normalized filepaths in tests * Made normalization tests a bit more chatty * Fix: Exclude unit test from beta-normalization in Dhall.Test.Normalization * Improved usage of guards for path selection in test suite * Normalize filepath in guards for path selection * Added turtle-1.6.2 to Nix setup * Unconditionally import Data.List in Dhall.Test.Util * Added small comment on the use of toDhallPath in Dhall.Test.Tags * Ran stylish-haskell * Log pkg-config path of libsodium in the CI * Log the libsodium version in the CI * Do not install a GHC with ghcup in the CI * Fixed pkg-config output in the CI * Bump cache_generation * Bumped version of some GH actions * Changed cache key * Small comment on pkg-config output * Added .envrc to .gitignore * Fixed deprecation warnings in dhall-nixpkgs package
1 parent e615993 commit 51c22e4

File tree

23 files changed

+149
-115
lines changed

23 files changed

+149
-115
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
env:
2-
cache_generation: 2021-06-22
2+
cache_generation: 2024-06-13
33

44
# NOTE: Please keep .mergify.yml in sync when adding or removing any jobs.
55
name: main
@@ -45,20 +45,23 @@ jobs:
4545
with:
4646
enable-stack: true
4747
stack-version: "latest"
48+
stack-no-global: true
4849
- name: "Cache"
49-
uses: actions/cache@v3
50+
uses: actions/cache@v4
5051
with:
51-
key: ${{ matrix.os.runner }}-${{ runner.arch }}-${{ hashFiles(matrix.stack-yaml) }}-${{ env.cache_generation }}
52+
key: ${{ matrix.os.runner }}-${{ runner.arch }}-${{ env.cache_generation }}-${{ hashFiles(matrix.stack-yaml) }}
5253
restore-keys: |
53-
${{ matrix.os.runner }}-${{ runner.arch }}-
54+
${{ matrix.os.runner }}-${{ runner.arch }}-${{ env.cache_generation }}-
5455
path: |
5556
${{ steps.setup-haskell-cabal.outputs.stack-root }}
56-
- name: Install libsodium
57+
- name: "Install libsodium"
5758
shell: bash
5859
run: |
5960
if [ '${{matrix.os.runner}}' == 'ubuntu-latest' ]; then
6061
sudo apt-get install -y libsodium-dev
6162
fi
63+
echo "::debug::'pkg-config libsodium' output:"
64+
pkg-config --print-errors --libs libsodium || true
6265
- name: "Build"
6366
shell: bash
6467
run: |
@@ -155,7 +158,7 @@ jobs:
155158
package 'dhall-yaml' "bin/dhall-to-yaml-ng${exe}" "bin/yaml-to-dhall${exe}"
156159
- name: "Upload package"
157160
if: ${{ matrix.stack-yaml == 'stack.yaml' }}
158-
uses: actions/upload-artifact@v3
161+
uses: actions/upload-artifact@v4
159162
with:
160163
name: 'dhall-${{ runner.os }}-${{ runner.arch }}.${{ matrix.os.file-extension }}'
161164
path: 'dhall-*${{ runner.os }}-${{ runner.arch }}.${{ matrix.os.file-extension }}'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ cabal.sandbox.config
1919
cabal.project.local
2020
cabal.project.local~
2121
.HTF/
22+
.envrc
2223
.ghc.environment.*
2324
.cache
2425
.history

dhall-docs/dhall-docs.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Test-Suite tasty
152152
tasty < 1.5 ,
153153
tasty-silver < 3.4 ,
154154
tasty-hunit >= 0.10 && < 0.11,
155-
turtle < 1.7 ,
155+
turtle >= 1.6 && < 1.7 ,
156156
text
157157
GHC-Options: -Wall
158158
Default-Language: Haskell2010

dhall-nixpkgs/Main.hs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ githubToNixpkgs GitHub{ name, uri, rev = maybeRev, hash, fetchSubmodules, direct
681681
ExitFailure _ -> die (FailedToFetchGitHubArchive args)
682682

683683
case Text.lines text of
684-
[ sha256, path ] -> return (r, sha256, Turtle.fromText path)
684+
[ sha256, path ] -> return (r, sha256, Text.unpack path)
685685
_ -> die (FailedToParseNixPrefetchURL args)
686686

687687
_ -> do
@@ -706,7 +706,7 @@ githubToNixpkgs GitHub{ name, uri, rev = maybeRev, hash, fetchSubmodules, direct
706706
Right n -> do
707707
return n
708708

709-
return (rev, sha256, Turtle.fromText path)
709+
return (rev, sha256, Text.unpack path)
710710

711711
let finalName =
712712
case name of
@@ -723,15 +723,11 @@ githubToNixpkgs GitHub{ name, uri, rev = maybeRev, hash, fetchSubmodules, direct
723723
then return ()
724724
else die (MissingFile expressionFile)
725725

726-
expressionText <- Turtle.readTextFile expressionFile
726+
expressionText <- Text.IO.readFile expressionFile
727727

728-
let expressionFileString = Turtle.encodeString expressionFile
728+
expression <- Dhall.Core.throws (Dhall.Parser.exprFromText expressionFile expressionText)
729729

730-
expression <- Dhall.Core.throws (Dhall.Parser.exprFromText expressionFileString expressionText)
731-
732-
let status = Dhall.Import.emptyStatus baseDirectoryString
733-
where
734-
baseDirectoryString = Turtle.encodeString baseDirectory
730+
let status = Dhall.Import.emptyStatus baseDirectory
735731

736732
dependencies <- Turtle.reduce Foldl.nub (State.evalStateT (findExternalDependencies expression) status)
737733

@@ -781,16 +777,11 @@ directoryToNixpkgs Directory{ name, directory, file, source, document, fixedOutp
781777
else do
782778
die (MissingFile expressionFile)
783779

784-
expressionText <- Turtle.readTextFile expressionFile
785-
786-
let expressionFileString = Turtle.encodeString expressionFile
780+
expressionText <- Text.IO.readFile expressionFile
787781

788-
expression <- Dhall.Core.throws (Dhall.Parser.exprFromText expressionFileString expressionText)
782+
expression <- Dhall.Core.throws (Dhall.Parser.exprFromText expressionFile expressionText)
789783

790-
let status = Dhall.Import.emptyStatus directoryString
791-
where
792-
directoryString =
793-
Turtle.encodeString (Turtle.directory expressionFile)
784+
let status = Dhall.Import.emptyStatus (Turtle.directory expressionFile)
794785

795786
dependencies <- Turtle.reduce Foldl.nub (State.evalStateT (findExternalDependencies expression) status)
796787

@@ -804,11 +795,9 @@ directoryToNixpkgs Directory{ name, directory, file, source, document, fixedOutp
804795

805796
let buildDhallDirectoryPackage = "buildDhallDirectoryPackage"
806797

807-
let src | null directoryString = directoryString
808-
| last directoryString == '/' = init directoryString
809-
| otherwise = directoryString
810-
where
811-
directoryString = Turtle.encodeString directory
798+
let src | null directory = directory
799+
| last directory == '/' = init directory
800+
| otherwise = directory
812801

813802
let functionParams =
814803
makeNixFunctionParams buildDhallDirectoryPackage nixDependencies
@@ -852,7 +841,7 @@ data Error
852841
| FailedToCloneRepository [Text]
853842
| FailedToParseNixPrefetchGit [Text] String
854843
| MissingFile FilePath
855-
844+
856845
renderError :: Error -> Text
857846
renderError e = case e of
858847
MissingSemanticIntegrityCheck url ->

dhall-nixpkgs/dhall-nixpkgs.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Executable dhall-to-nixpkgs
3434
, prettyprinter >= 1.7.0 && < 1.8
3535
, text >= 0.11.1.0 && < 2.1
3636
, transformers >= 0.2.0.0 && < 0.6
37-
, turtle < 1.6
37+
, turtle >= 1.6 && < 1.7
3838
, network-uri < 2.8
3939
Default-Language: Haskell2010
4040
GHC-Options: -Wall -threaded

dhall/dhall.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ Test-Suite tasty
452452
tasty-quickcheck >= 0.9.2 && < 0.11,
453453
tasty-silver < 3.4 ,
454454
temporary >= 1.2.1 && < 1.4 ,
455-
turtle < 1.7 ,
455+
turtle >= 1.6 && < 1.7 ,
456456
Default-Language: Haskell2010
457457

458458
Test-Suite doctest

dhall/src/Dhall/Diff.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ import Dhall.Syntax
4141
import Numeric.Natural (Natural)
4242
import Prettyprinter (Doc, Pretty)
4343

44-
import qualified Data.Algorithm.Diff as Algo.Diff
44+
import qualified Data.Algorithm.Diff as Algo.Diff
4545
import qualified Data.List.NonEmpty
4646
import qualified Data.Set
4747
import qualified Data.Text
48-
import qualified Data.Time as Time
48+
import qualified Data.Time as Time
4949
import qualified Dhall.Map
50-
import qualified Dhall.Normalize as Normalize
51-
import qualified Dhall.Pretty.Internal as Internal
52-
import qualified Dhall.Syntax as Syntax
53-
import qualified Prettyprinter as Pretty
50+
import qualified Dhall.Normalize as Normalize
51+
import qualified Dhall.Pretty.Internal as Internal
52+
import qualified Dhall.Syntax as Syntax
53+
import qualified Prettyprinter as Pretty
5454

5555
{-| This type is a `Doc` enriched with a `same` flag to efficiently track if
5656
any difference was detected

dhall/src/Dhall/Parser/Combinators.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ instance Text.Megaparsec.MonadParsec Void Text Parser where
169169

170170
updateParserState f = Parser (Text.Megaparsec.updateParserState f)
171171

172+
#if MIN_VERSION_megaparsec(9,4,0)
173+
mkParsec f = Parser (Text.Megaparsec.mkParsec f)
174+
#endif
175+
172176
instance Semigroup a => Semigroup (Parser a) where
173177
(<>) = liftA2 (<>)
174178

dhall/tests/Dhall/Test/Diff.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
module Dhall.Test.Diff where
44

55
import Data.Text (Text)
6-
import Prelude hiding (FilePath)
76
import Test.Tasty (TestTree)
8-
import Turtle (FilePath)
97

108
import qualified Data.Text as Text
119
import qualified Data.Text.IO as Text.IO

dhall/tests/Dhall/Test/Format.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import Dhall.Parser (Header (..))
77
import Dhall.Pretty (CharacterSet (..))
88
import Test.Tasty (TestTree)
99

10-
import qualified Control.Monad as Monad
1110
import qualified Data.Text as Text
1211
import qualified Data.Text.IO as Text.IO
1312
import qualified Dhall.Core as Core
@@ -27,7 +26,7 @@ getTests = do
2726

2827
let skip = [ "./tests/format/asciiA.dhall" ]
2928

30-
Monad.guard (path `notElem` skip)
29+
path `Test.Util.pathNotIn` skip
3130

3231
return path
3332

0 commit comments

Comments
 (0)