build-support writers: content can be string or file

This commit is contained in:
lassulus
2018-12-04 16:40:32 +01:00
parent 90f0a7c390
commit 995defbb9b
2 changed files with 105 additions and 63 deletions
+20 -1
View File
@@ -1,4 +1,4 @@
{ stdenv, lib, runCommand, haskellPackages, nodePackages, perlPackages, python2Packages, python3Packages, writers}:
{ stdenv, lib, runCommand, haskellPackages, nodePackages, perlPackages, python2Packages, python3Packages, writers, writeText }:
with writers;
let
@@ -128,6 +128,24 @@ let
'';
};
path = {
bash = writeBash "test_bash" (writeText "test" ''
if [[ "test" == "test" ]]; then echo "success"; fi
'');
haskell = writeHaskell "test_haskell" { libraries = [ haskellPackages.acme-default ]; } (writeText "test" ''
import Data.Default
int :: Int
int = def
main :: IO ()
main = case int of
18871 -> putStrLn $ id "success"
_ -> print "fail"
'');
};
writeTest = expectedValue: test:
writeDash "test-writers" ''
if test "$(${test})" != "${expectedValue}"; then
@@ -142,6 +160,7 @@ in runCommand "test-writers" {
} ''
${lib.concatMapStringsSep "\n" (test: writeTest "success" "${test}/bin/test_writers") (lib.attrValues bin)}
${lib.concatMapStringsSep "\n" (test: writeTest "success" "${test}") (lib.attrValues simple)}
${lib.concatMapStringsSep "\n" (test: writeTest "success" "${test}") (lib.attrValues path)}
echo 'nix-writers successfully tested' >&2
touch $out