nixpkgs/pkgs/build-support/rust
Andreas Rammhold a3a51763f9
buildRustCrate: add buildTests flag to tell rustc to build tests instead of binaries
This helps us instruct rustc to build tests instead of binaries. The
actual build will then ONLY produce test executables. This is a first
step towards having rust crate tests within nixpkgs.

We default back to only a single output in test cases since that is the
only reasonable thing to do here.

Producing libraries or binaries in addition to tests would theoretically
be feasible but usually generates different dependency trees. It is very
common to have some libraries in `[dev-depdendencies]` within Cargo.toml
just for your tests. To not start mixing things up going with a
dedicated derivation for the test build sounds like the best choice for
now.

To use this you must provide a proper test dependency chain to
`buildRustCrate` (as you would usually do with your non-test inputs).
And then set the `buildTests` attribute to `true`. The derivation will
then contain all tests that were built in `$out/tests`. All common test
patterns and directories should be supported and tested by this change.

Below is an example how you would run a single test from the derivation.
This commit contains some more examples in the `buildRustCrateTests`
attribute set that might be helpful.

```
let
  drv = buildRustCrate {
     …
     buildTests true;
  };
in runCommand "test-my-crate" {} ''
  touch $out
  exec ${drv}/tests/my-test
''
```
2020-01-07 11:57:34 +01:00
..
build-rust-crate buildRustCrate: add buildTests flag to tell rustc to build tests instead of binaries 2020-01-07 11:57:34 +01:00
patch-registry-deps buildRustPackage: don't hardcode /nix/store, use $NIX_STORE 2016-01-12 13:45:11 -05:00
cargo-vendor-normalise.py fetchcargo: add type checking to cargo-vendor-normalise.py 2018-09-11 23:44:14 +02:00
carnix.nix Carnix: 0.9 -> 0.10 2019-03-26 18:54:28 +00:00
crates-io.nix treewide: remove redundant rec 2019-08-28 11:07:32 +00:00
default-crate-overrides.nix cargo-vendor: drop 2019-09-22 20:20:20 -05:00
default.nix rustPlatform: forward unpackPhase to fetchcargo 2019-12-23 18:27:56 +00:00
fetchcargo-default-config.toml fectchcargo: don't break old sha256 2018-09-11 23:44:14 +02:00
fetchcargo.nix rustPlatform.fetchcargo: expose 2019-12-23 18:27:56 +00:00
fetchcrate.nix add fetchCrate function to fetch rust crates 2017-12-12 04:58:45 -06:00