diff options
author | sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> | 2021-02-14 15:21:18 +0100 |
---|---|---|
committer | sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> | 2021-02-14 15:26:52 +0100 |
commit | 2c6c013291932e4d82712b4672e3958b52563634 (patch) | |
tree | 6d651b604dde0c3fb00d2b0a15311683cbba4442 /pkgs | |
parent | 587fcc7b89cda8abbbd1f08722b2b3e1349869c8 (diff) |
pkgs/profpatsch: vendor testRustSimple from tvl
testRustSimple builds and runs the tests of a buildRustCrate derivation automatically using drvSeqL, returning its non-test variant. Really looking forward to pkgs.tvl :)
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/profpatsch/default.nix | 3 | ||||
-rw-r--r-- | pkgs/profpatsch/write-rust.nix | 30 |
2 files changed, 30 insertions, 3 deletions
diff --git a/pkgs/profpatsch/default.nix b/pkgs/profpatsch/default.nix index 8e8f77e2..063b3acc 100644 --- a/pkgs/profpatsch/default.nix +++ b/pkgs/profpatsch/default.nix @@ -162,9 +162,10 @@ in rec { ]; }); - inherit (import ./write-rust.nix { inherit pkgs runExeclineLocal getBins; }) + inherit (import ./write-rust.nix { inherit pkgs runExeclineLocal getBins drvSeqL; }) writeRustSimple writeRustSimpleLib + testRustSimple ; inherit (runExeclineFns) diff --git a/pkgs/profpatsch/write-rust.nix b/pkgs/profpatsch/write-rust.nix index bf6c1eb2..afbeb80b 100644 --- a/pkgs/profpatsch/write-rust.nix +++ b/pkgs/profpatsch/write-rust.nix @@ -1,6 +1,6 @@ -{ pkgs, runExeclineLocal, getBins }: +{ pkgs, runExeclineLocal, getBins, drvSeqL }: let - bins = getBins pkgs.coreutils [ "ln" ]; + bins = getBins pkgs.coreutils [ "ln" "ls" "touch" ]; writeRustSimple = name: args: srcFile: linkTo name "${writeRustSimpleBin name args srcFile}/bin/${name}"; @@ -35,10 +35,36 @@ let ''; } // args); + /* Takes a `buildRustCrate` derivation as an input, + * builds it with `{ buildTests = true; }` and runs + * all tests found in its `tests` dir. If they are + * all successful, `$out` will point to the crate + * built with `{ buildTests = false; }`, otherwise + * it will fail to build. + * + * See also the documentation on `drvSeqL` which is + * used to implement this behavior. + */ + testRustSimple = rustDrv: + let + crate = buildTests: rustDrv.override { inherit buildTests; }; + tests = runExeclineLocal "${rustDrv.name}-tests-run" {} [ + "importas" "out" "out" + "if" [ + "pipeline" [ bins.ls "${crate true}/tests" ] + "forstdin" "test" + "importas" "test" "test" + "${crate true}/tests/$test" + ] + bins.touch "$out" + ]; + in drvSeqL [ tests ] (crate false); + in { inherit writeRustSimple writeRustSimpleBin writeRustSimpleLib + testRustSimple ; } |