From abd187035c3b3b2fc6f0916b507670880bbac9ec Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Sun, 26 Aug 2018 19:28:52 +0300 Subject: [PATCH 1/2] Test that utf-8 files can be parsed --- tests/utf-8/Main.hs | 12 ++++++++++++ tests/utf-8/golden | 1 + tests/utf-8/package.yaml | 4 ++++ tests/utf-8/snack.nix | 3 +++ tests/utf-8/test | 20 ++++++++++++++++++++ 5 files changed, 40 insertions(+) create mode 100644 tests/utf-8/Main.hs create mode 100644 tests/utf-8/golden create mode 100644 tests/utf-8/package.yaml create mode 100644 tests/utf-8/snack.nix create mode 100755 tests/utf-8/test diff --git a/tests/utf-8/Main.hs b/tests/utf-8/Main.hs new file mode 100644 index 0000000..4bc1cec --- /dev/null +++ b/tests/utf-8/Main.hs @@ -0,0 +1,12 @@ +{-| +Copyright: + © 2018 Nicolas Mattia +-} +module Main + ( main + ) where + +import Numeric.Natural (Natural) + +main :: IO () +main = putStrLn "hello" diff --git a/tests/utf-8/golden b/tests/utf-8/golden new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/tests/utf-8/golden @@ -0,0 +1 @@ +hello diff --git a/tests/utf-8/package.yaml b/tests/utf-8/package.yaml new file mode 100644 index 0000000..90066c0 --- /dev/null +++ b/tests/utf-8/package.yaml @@ -0,0 +1,4 @@ +name: snack-strips-versions +executable: + main: Main.hs + source-dirs: . diff --git a/tests/utf-8/snack.nix b/tests/utf-8/snack.nix new file mode 100644 index 0000000..3b4022a --- /dev/null +++ b/tests/utf-8/snack.nix @@ -0,0 +1,3 @@ +{ main = "Main"; + src = ./.; +} diff --git a/tests/utf-8/test b/tests/utf-8/test new file mode 100755 index 0000000..7ff56f4 --- /dev/null +++ b/tests/utf-8/test @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# vim: ft=sh sw=2 et + +set -euo pipefail + +test() { + $SNACK build + $SNACK run | diff golden - + + TMP_FILE=$(mktemp) + + capture_io "$TMP_FILE" main | $SNACK ghci + + diff golden $TMP_FILE + rm $TMP_FILE +} + +SNACK="snack" test +SNACK="snack -s ./snack.nix" test +SNACK="snack --package-yaml ./package.yaml" test From bbef676f0984c8b0ab9b5db261b2e4c486c68e4a Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Sun, 26 Aug 2018 19:29:05 +0300 Subject: [PATCH 2/2] Enable utf-8 when parsing dependencies --- snack-lib/modules.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/snack-lib/modules.nix b/snack-lib/modules.nix index f3c16c6..1e3b8ad 100644 --- a/snack-lib/modules.nix +++ b/snack-lib/modules.nix @@ -2,6 +2,7 @@ { lib , callPackage , runCommand +, glibcLocales , haskellPackages }: @@ -58,7 +59,10 @@ rec { } "ghc -package ghc ${./Imports.hs} -o $out" ; # XXX: this command needs ghc in the environment so that it can call "ghc # --print-libdir"... - in runCommand "dependencies-json" { buildInputs = [ ghc ]; } + in runCommand "dependencies-json" + { buildInputs = [ ghc glibcLocales ]; + LANG="en_US.utf-8"; + } '' ${importParser} ${singleOutModulePath base modName} > $out