Skip to content

Commit c659d88

Browse files
committed
Combine drv, drv.source and drv.dist for doctest
1 parent 473c375 commit c659d88

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

builder/comp-builder.nix

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ stdenv.mkDerivation ({
179179
# The directory containing the haddock documentation.
180180
# `null' if no haddock documentation was built.
181181
haddockDir = if doHaddock' then "${docdir drv.doc}/html" else null;
182+
} // lib.optionalAttrs isDoctest {
183+
# We could not figure out how to have separate `source` and `dist` outputs
184+
# for doctest as it results in a circular references.
185+
source = drv;
182186
};
183187

184188
meta = {
@@ -213,8 +217,7 @@ stdenv.mkDerivation ({
213217
outputs = ["out"]
214218
++ (lib.optional enableSeparateDataOutput "data")
215219
++ (lib.optional doHaddock' "doc")
216-
++ (lib.optional keepSource "source")
217-
++ (lib.optional isDoctest "dist");
220+
++ (lib.optional (keepSource && !isDoctest) "source");
218221

219222
# Phases
220223
preInstallPhases = lib.optional doHaddock' "haddockPhase";
@@ -226,7 +229,12 @@ stdenv.mkDerivation ({
226229
'';
227230

228231
configurePhase =
229-
(lib.optionalString keepSource ''
232+
(lib.optionalString isDoctest ''
233+
cp -r . $out
234+
cd $out
235+
chmod -R +w .
236+
'') +
237+
(lib.optionalString (keepSource && !isDoctest) ''
230238
cp -r . $source
231239
cd $source
232240
chmod -R +w .
@@ -354,9 +362,7 @@ stdenv.mkDerivation ({
354362
'')
355363
}
356364
runHook postInstall
357-
'' + (lib.optionalString isDoctest ''
358-
cp -r dist/ $dist/
359-
'') + (lib.optionalString keepSource ''
365+
'' + (lib.optionalString (keepSource && !isDoctest) ''
360366
rm -rf dist
361367
'');
362368

lib/check.nix

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,7 @@ in stdenv.mkDerivation ({
2626

2727
# If doCheck or doCrossCheck are false we may still build this
2828
# component and we want it to quietly succeed.
29-
buildPhase =
30-
(lib.optionalString component.isDoctest ''
31-
# cabal-doctest assumes we are running tests in a directory with the same
32-
# name as when we built the test.
33-
this_dir_name=$(pwd)
34-
src_basename="$(basename "${drv.cleanSrc}")"
35-
cd ../
36-
mv "$this_dir_name" "$src_basename"
37-
cd "$src_basename"
38-
39-
# cabal-doctest needs the ./dist directory available to get auto-generated
40-
# modules.
41-
cp -r ${drv.dist} ./dist
42-
chmod u+w -R ./dist
43-
'') + ''
29+
buildPhase = ''
4430
touch $out
4531
4632
runHook preCheck

0 commit comments

Comments
 (0)