Skip to content

Commit

Permalink
feat(rust): add doctest check
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
  • Loading branch information
rvolosatovs committed Oct 21, 2024
1 parent 0e0bc1c commit ddfd1d8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ in
assert attrs.${system} ? "${name}-x86_64-unknown-linux-musl-oci";
assert attrs.${system} ? ${name}; x;
in
assert flakes.rust.complex.checks.${system} ? doctest;
assert flakes.rust.complex.packages.${system} ? default;
assert flakes.rust.hello-multibin.packages.${system} ? default;
assert flakes.rust.hello-multibin.packages.${system} ? rust-hello-multibin-wasm32-wasip1;
Expand Down
1 change: 1 addition & 0 deletions examples/rust-complex/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

build.workspace = true;
clippy.workspace = true;
test.doc = true;
test.workspace = true;

buildOverrides = {
Expand Down
1 change: 1 addition & 0 deletions lib/rust/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ in {

defaultTestConfig.allFeatures = false;
defaultTestConfig.allTargets = false;
defaultTestConfig.doc = false;
defaultTestConfig.excludes = [];
defaultTestConfig.features = [];
defaultTestConfig.noDefaultFeatures = false;
Expand Down
18 changes: 13 additions & 5 deletions lib/rust/mkAttrs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,24 @@ with self.lib.rust.targets;
}
callCraneWithDeps (mkHostArgs craneArgs);

callHostCraneCheckWithDeps = craneArgs:
trace' "callHostCraneCheckWithDeps" {
inherit craneArgs;
}
callHostCraneWithDeps (craneArgs
// {
doCheck = true; # without performing the actual testing, this check is useless
});

checks =
{
clippy = callHostCraneWithDeps {} hostCraneLib.cargoClippy;
doc = callHostCraneWithDeps {} hostCraneLib.cargoDoc;
fmt = callHostCrane {} hostCraneLib.cargoFmt;
nextest =
callHostCraneWithDeps {
doCheck = true; # without performing the actual testing, this check is useless
}
hostCraneLib.cargoNextest;
nextest = callHostCraneCheckWithDeps {} hostCraneLib.cargoNextest;
}
// (optionalAttrs (test ? doc && test.doc)) {
doctest = callHostCraneCheckWithDeps {} hostCraneLib.cargoDocTest;
}
// (optionalAttrs (pathExists "${src}/Cargo.lock") {
# TODO: Use `cargoLock` if `Cargo.lock` missing
Expand Down

0 comments on commit ddfd1d8

Please sign in to comment.