ghcjs: copy and run tests (#494)

This commit is contained in:
Yorick 2020-03-17 10:20:08 +01:00 committed by GitHub
parent b921ff83f0
commit 13a88d15f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp }:
{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp, nodejs }:
{ componentId
, component
@ -142,7 +142,8 @@ let
&& (haskellLib.isLibrary componentId)
&& !haskellLib.isCrossHost;
exeExt = lib.optionalString stdenv.hostPlatform.isWindows ".exe";
exeExt = if stdenv.hostPlatform.isGhcjs then ".jsexe/all.js" else
if stdenv.hostPlatform.isWindows then ".exe" else "";
exeName = componentId.cname + exeExt;
testExecutable = "dist/build/${componentId.cname}/${exeName}";
@ -313,7 +314,13 @@ stdenv.mkDerivation ({
${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId || haskellLib.isAll componentId) ''
mkdir -p $out/bin
if [ -f ${testExecutable} ]; then
cp ${testExecutable} $out/bin/
mkdir -p $(dirname $out/bin/${exeName})
${if stdenv.hostPlatform.isGhcjs then ''
cat <(echo \#!${lib.getBin buildPackages.nodejs}/bin/node) ${testExecutable} >| $out/bin/${exeName}
chmod +x $out/bin/${exeName}
'' else ''
cp -r ${testExecutable} $(dirname $out/bin/${exeName})
''}
fi
'')
# In case `setup copy` did not creat this