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

buildRustCrate: add buildTests flag to tell rustc to build tests instead of binaries #76820

Merged
merged 3 commits into from
Jan 8, 2020

Commits on Jan 7, 2020

  1. buildRustCrate: add buildTests flag to tell rustc to build tests in…

    …stead 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
    ''
    ```
    andir committed Jan 7, 2020
    Configuration menu
    Copy the full SHA
    a3a5176 View commit details
    Browse the repository at this point in the history
  2. buildRustCrate: slight "rewording" and reformatting

    There is no point in reinventinb builtins through `filterAttrs` or the
    like. Lets just stick to what we already have in our toolbelt.
    andir committed Jan 7, 2020
    Configuration menu
    Copy the full SHA
    3e61906 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    71a96b2 View commit details
    Browse the repository at this point in the history