Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
[DEVOPS-936] nix: Let tests.stylishHaskell work with utf-8 files
Browse files Browse the repository at this point in the history
When stylish-haskell is run under the C locale processing files with
unicode characters it crashes with the error:

    commitBuffer: invalid argument (invalid character)

So force the locale to be a UTF-8 one.
  • Loading branch information
rvl committed Jul 4, 2018
1 parent ef15b92 commit ed8c892
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
3 changes: 1 addition & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,10 @@ let
tests = {
shellcheck = pkgs.callPackage ./scripts/test/shellcheck.nix { src = ./.; };
hlint = pkgs.callPackage ./scripts/test/hlint.nix { src = ./.; };
stylishHaskell = pkgs.callPackage ./scripts/test/stylish.nix { src = ./.; stylish-haskell = cardanoPkgs.stylish-haskell; };
stylishHaskell = pkgs.callPackage ./scripts/test/stylish.nix { src = ./.; stylish-haskell = cardanoPkgs.stylish-haskell; inherit localLib; };
buildWalletIntegration = pkgs.callPackage ./scripts/test/wallet/integration/build-test.nix { inherit walletIntegrationTests pkgs; };
swaggerSchemaValidation = pkgs.callPackage ./scripts/test/wallet/swaggerSchemaValidation.nix { inherit gitrev; };
};
fixStylishHaskell = pkgs.callPackage ./scripts/haskell/stylish.nix { stylish-haskell = cardanoPkgs.stylish-haskell; };
cardano-sl-explorer-frontend = (import ./explorer/frontend {
inherit system config gitrev pkgs;
cardano-sl-explorer = cardanoPkgs.cardano-sl-explorer-static;
Expand Down
9 changes: 9 additions & 0 deletions lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ in lib // (rec {
inherit fetchNixPkgs;
isCardanoSL = lib.hasPrefix "cardano-sl";
isBenchmark = args: !((args.isExecutable or false) || (args.isLibrary or true));

# Insert this into builder scripts where programs require a UTF-8
# locale to work.
utf8LocaleSetting = ''
export LC_ALL=en_GB.UTF-8
export LANG=en_GB.UTF-8
'' + lib.optionalString (pkgs.glibcLocales != null) ''
export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive"
'';
})
6 changes: 0 additions & 6 deletions scripts/launch/connect-to-cluster/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ let
"--configuration-file ${environments.${environment}.confFile or "${configFiles}/lib/configuration.yaml"}"
"--configuration-key ${environments.${environment}.confKey}"
];
utf8LocaleSetting = ''
export LC_ALL=en_GB.UTF-8
export LANG=en_GB.UTF-8
'' + optionalString (pkgs.glibcLocales != null) ''
export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive"
'';

in pkgs.writeScript "${executable}-connect-to-${environment}" ''
#!${pkgs.stdenv.shell} -e
Expand Down
2 changes: 1 addition & 1 deletion scripts/launch/demo-cluster/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ in pkgs.writeScript "demo-cluster" ''
done
${ifWallet ''
export LC_ALL=C.UTF-8
${utf8LocaleSetting}
echo Launching wallet node: ${demoWallet}
${demoWallet} --runtime-args "--system-start $system_start" &> /dev/null &
wallet_pid=$!
Expand Down
3 changes: 2 additions & 1 deletion scripts/test/stylish.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ runCommand, stylish-haskell, src, lib, git }:
{ runCommand, stylish-haskell, src, lib, localLib, git }:

let
cleanSourceFilter = with lib;
Expand All @@ -11,6 +11,7 @@ let
in
runCommand "cardano-stylish-check" { succeedOnFailure = true; buildInputs = [ stylish-haskell git ]; } ''
set +e
${localLib.utf8LocaleSetting}
cp -a ${src'} tmp-cardano
chmod -R 0755 tmp-cardano
cd tmp-cardano
Expand Down

0 comments on commit ed8c892

Please sign in to comment.