Skip to content
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

Merged
merged 52 commits into from
Nov 29, 2019

Conversation

hamishmack
Copy link
Collaborator

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.

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.
Copy link
Collaborator

@angerman angerman left a 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 🎉

Copy link
Contributor

@rvl rvl left a 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 Show resolved Hide resolved
# 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 ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better

lib/default.nix Outdated Show resolved Hide resolved
run = stdenv.mkDerivation ({
name = (fullName + "-run");

src = drv;
Copy link
Contributor

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?

Copy link
Collaborator Author

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).

checkPhase = ''
runHook preCheck

${toString component.testWrapper} $src/${installedExe} ${lib.concatStringsSep " " component.testFlags} | tee $out
Copy link
Contributor

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}?

Copy link
Collaborator Author

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

# 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

Copy link
Contributor

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.

hamishmack and others added 2 commits November 14, 2019 20:07
Co-Authored-By: Rodney Lorrimar <rodney.lorrimar@iohk.io>
@hamishmack hamishmack requested a review from rvl November 14, 2019 08:34
@rvl
Copy link
Contributor

rvl commented Nov 14, 2019

Because having a passthru derivation doesn't work well with mapTestOn, and because, .run is hidden quite deeply, could we change the layout?

Could you move it to hsPkgs.<package>.checks.<name>? This will execute the tests for hsPkgs.<package>.components.tests.<name>.

@michaelpj
Copy link
Collaborator

Could you move it to hsPkgs..checks.?

What about test-runners instead of checks? A bit more descriptive, perhaps.

components = haskellLib.applyComponents buildComp config;
run = builtins.mapAttrs (_: es: builtins.mapAttrs (_: d: d.run) es)
{ inherit (components) exes tests benchmarks; };
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Richard Wallace and others added 7 commits November 19, 2019 21:21
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`.
@hamishmack hamishmack requested a review from rvl November 22, 2019 00:58
@hamishmack hamishmack changed the title Add collectRunComponents. Move checkPhase to .run Replace collectRunComponents with haskellLib.check Nov 29, 2019
@hamishmack hamishmack merged commit a9b0122 into master Nov 29, 2019
@hamishmack hamishmack deleted the hkm/passthru-run-2 branch November 29, 2019 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants