on iko/ghcjs-patch-master help sign in
ghcjs: copy and run tests (#494)
13a88d1Yorick
builder/comp-builder.nix+10−3
@@ -1,4 +1,4 @@
1−{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp }:
1+{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp, nodejs }:
2
2
3{ componentId
3{ componentId
4, component
4, component
@@ -142,7 +142,8 @@ let
142 && (haskellLib.isLibrary componentId)
142 && (haskellLib.isLibrary componentId)
143 && !haskellLib.isCrossHost;
143 && !haskellLib.isCrossHost;
144
144
145+ exeExt = if stdenv.hostPlatform.isGhcjs then ".jsexe/all.js" else
145− exeExt = lib.optionalString stdenv.hostPlatform.isWindows ".exe";
146+ if stdenv.hostPlatform.isWindows then ".exe" else "";
146 exeName = componentId.cname + exeExt;
147 exeName = componentId.cname + exeExt;
147 testExecutable = "dist/build/${componentId.cname}/${exeName}";
148 testExecutable = "dist/build/${componentId.cname}/${exeName}";
148
149
@@ -313,7 +314,13 @@ stdenv.mkDerivation ({
313 ${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId || haskellLib.isAll componentId) ''
314 ${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId || haskellLib.isAll componentId) ''
314 mkdir -p $out/bin
315 mkdir -p $out/bin
315 if [ -f ${testExecutable} ]; then
316 if [ -f ${testExecutable} ]; then
317+ mkdir -p $(dirname $out/bin/${exeName})
318+ ${if stdenv.hostPlatform.isGhcjs then ''
319+ cat <(echo \#!${lib.getBin buildPackages.nodejs}/bin/node) ${testExecutable} >| $out/bin/${exeName}
320+ chmod +x $out/bin/${exeName}
321+ '' else ''
316− cp ${testExecutable} $out/bin/
322+ cp -r ${testExecutable} $(dirname $out/bin/${exeName})
323+ ''}
317 fi
324 fi
318 '')
325 '')
319 # In case `setup copy` did not creat this
326 # In case `setup copy` did not creat this