Skip to content

Support for packages with only tests #1732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,13 @@ let
target-pkg-and-db = "${ghc.targetPrefix}ghc-pkg -v0 --package-db $out/package.conf.d";
in ''
runHook preInstall
$SETUP_HS copy ${lib.concatStringsSep " " (
setupInstallFlags
++ lib.optional configureAllComponents
(haskellLib.componentTarget componentId)
)}
${ # `Setup copy` does not install tests and benchmarks.
lib.optionalString (!haskellLib.isTest componentId && !haskellLib.isBenchmark componentId) ''
$SETUP_HS copy ${lib.concatStringsSep " " (
setupInstallFlags
++ lib.optional configureAllComponents
(haskellLib.componentTarget componentId)
)}''}
${lib.optionalString (haskellLib.isLibrary componentId) ''
$SETUP_HS register --gen-pkg-config=${name}.conf
${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
Expand Down Expand Up @@ -512,7 +514,7 @@ let
if [ -f ${testExecutable} ]; then
mkdir -p $(dirname $out/bin/${exeName})
${if stdenv.hostPlatform.isGhcjs then ''
cat <(echo \#!${lib.getBin buildPackages.nodejs-12_x}/bin/node) ${testExecutable} >| $out/bin/${exeName}
cat <(echo \#!${lib.getBin buildPackages.nodejs-18_x}/bin/node) ${testExecutable} >| $out/bin/${exeName}
chmod +x $out/bin/${exeName}
'' else ''
cp -r ${testExecutable} $(dirname $out/bin/${exeName})
Expand Down
1 change: 1 addition & 0 deletions test/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ let
exe-lib-dlls = callTest ./exe-lib-dlls { inherit util; };
ca-derivations = callTest ./ca-derivations { inherit CADerivationsEnabled; };
ca-derivations-include = callTest ./ca-derivations-include { inherit CADerivationsEnabled; };
test-only = callTest ./test-only { inherit util; };

unit = unitTests;
};
Expand Down
2 changes: 2 additions & 0 deletions test/test-only/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Main where
main = return ()
1 change: 1 addition & 0 deletions test/test-only/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: .
17 changes: 17 additions & 0 deletions test/test-only/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ stdenv, lib, util, project', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name, evalPackages }:

with lib;

let
project = project' {
inherit compiler-nix-name evalPackages;
src = testSrc "test-only";
};

in recurseIntoAttrs {
ifdInputs = {
inherit (project) plan-nix;
};

run = project.hsPkgs.test-only.checks.my-test;
}
8 changes: 8 additions & 0 deletions test/test-only/test-only.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cabal-version: 1.24
name: test-only
version: 1
build-type: Simple
test-suite my-test
type: exitcode-stdio-1.0
main-is: Main.hs
build-depends: base