-
Notifications
You must be signed in to change notification settings - Fork 239
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
Replace collectRunComponents with haskellLib.check #316
Conversation
In order to make it easier to run tests this change adds a collectRunComponents function (like collectComponents but with it returns the `passthru.run` derivation for each component). This change also disables `checkPhase` for all components to avoid running the tests twice. To run a test or benchmark you now have to use the the `passthru.run` derivation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! With lots of comments 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better, but I would prefer to leave collectComponents
as is, and make a more specialised runTestComponents
.
builder/comp-builder.nix
Outdated
# This run derivation can be used to execute test, benchmark (or even | ||
# exe) components. The $out of the derivation is a file containing | ||
# the resulting stdout output. | ||
run = stdenv.mkDerivation ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better
builder/comp-builder.nix
Outdated
run = stdenv.mkDerivation ({ | ||
name = (fullName + "-run"); | ||
|
||
src = drv; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the test suite has a dependency on data files in the source directory, will it work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The executable is not copied out of the location it is in. I checked that echo $src
was the same as echo ${drv}
in the checkPhase. (if that is what you were concerned about).
builder/comp-builder.nix
Outdated
checkPhase = '' | ||
runHook preCheck | ||
|
||
${toString component.testWrapper} $src/${installedExe} ${lib.concatStringsSep " " component.testFlags} | tee $out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good reason that installedExe
is not bin/${componentId.cname}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure. See
haskell.nix/builder/comp-builder.nix
Lines 120 to 123 in 6e95ba5
# exe components are in /bin, but test and benchmarks are not. Perhaps to avoid | |
# them being from being added to the PATH when the all component added to an env. | |
# TODO revist this to find out why and document or maybe change this. | |
installedExeDir = if haskellLib.isTest componentId || haskellLib.isBenchmark componentId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it should be bin
. Having the component name as a directory is inconvenient.
Co-Authored-By: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Because having a passthru derivation doesn't work well with Could you move it to |
What about |
builder/hspkg-builder.nix
Outdated
components = haskellLib.applyComponents buildComp config; | ||
run = builtins.mapAttrs (_: es: builtins.mapAttrs (_: d: d.run) es) | ||
{ inherit (components) exes tests benchmarks; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't really see why users would want to run exes and benchmarks like this.
It could be simpler with a single test-runners
attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An exe might be pure generator (for instance it could build an html file or a log table). I think making sure it runs could be meaningful test.
Checking that a benchmarks runs seems like it could also be a meaningful test. You might not care about the performance result when run in nix (since it is hard to know what load the machine will be under), but you could also have it exitFailure
if the result was very poor.
caches `configure-flags`, `cabal.config`, and `ghc-environment` files per library in the nix store, so the `make-config-files` script just has to append them into the same named files for the package being built instead of using `ghc-pkg dump` and `ghc-pkg register` for each dependency, copies the `.conf` files from the dependencies `package.conf.d` directory and then uses a single `ghc-pkg recache` eliminate the call of `ghc-pkg check` suppress some output of `ghc-pkg` (not related to speed improvements, I'm flexible on rolling this bit back) in my tests, the make-config-files scripts now only take seconds, even for packages that have many many dependencies - prior to this change, this script took more than a minute for such packages
This is what most people will want and it means using collecting all the derivations with `release-lib.nix` will work without having to filter out `exes` and `benchmarks`.
`normalizeRelativeDir` adds a slash on to the end of `dataDir`. Adding another one here results in `//` and files are left out by mistake.
In order to make it easier to run tests this change adds a
collectRunComponents function (like collectComponents but
with it returns the
passthru.run
derivation for each component).This change also disables
checkPhase
for all components to avoidrunning the tests twice. To run a test or benchmark you now have to
use the the
passthru.run
derivation.