Add tests for a simple workspace

This commit is contained in:
Ivan Petkov 2022-01-07 17:56:12 -08:00
parent 1c8034c0d9
commit a8c6f256bc
No known key found for this signature in database
GPG Key ID: BB6F9EFC065832B6
10 changed files with 72 additions and 18 deletions

View File

@ -72,24 +72,17 @@ onlyDrvs (lib.makeScope myLib.newScope (self:
src = ./simple;
};
smokeSimple = pkgs.runCommand "smoke-simple" { } ''
# does it run?
${self.simple}/bin/simple
touch $out
'';
smoke = callPackage ./smoke.nix { };
smokeSimple = self.smoke [ "simple" ] self.simple;
smokeOverlappingTargets =
let
overlappingTargets = myLib.buildPackage {
src = ./overlapping-targets;
};
in
pkgs.runCommand "smoke-overlapping-targets" { } ''
# does it run?
${overlappingTargets}/bin/foo
${overlappingTargets}/bin/bar
${overlappingTargets}/bin/baz
touch $out
'';
smokeOverlappingTargets = self.smoke [ "foo" "bar" "baz" ] (myLib.buildPackage {
src = ./overlapping-targets;
});
smokeWorkspace = self.smoke [ "print" ] self.workspace;
workspace = myLib.buildPackage {
src = ./workspace;
};
})
)

13
checks/smoke.nix Normal file
View File

@ -0,0 +1,13 @@
{ runCommand
}:
bins: drv:
let
testList = map (b: "${drv}/bin/${b}") bins;
tests = builtins.concatStringsSep "\n" testList;
in
runCommand "smoke-${drv.name}" { } ''
# does it run?
${tests}
touch $out
''

19
checks/workspace/Cargo.lock generated Normal file
View File

@ -0,0 +1,19 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "hello"
version = "0.1.0"
[[package]]
name = "print"
version = "0.1.0"
dependencies = [
"hello",
"world",
]
[[package]]
name = "world"
version = "0.1.0"

View File

@ -0,0 +1,4 @@
[workspace]
# NB: hello and world are intentionally left out cargo will
# promote them to members since they are listed as path deps
members = ["print"]

View File

@ -0,0 +1,4 @@
[package]
name = "hello"
version = "0.1.0"
edition = "2021"

View File

@ -0,0 +1,3 @@
pub fn hello() -> &'static str {
"hello"
}

View File

@ -0,0 +1,8 @@
[package]
name = "print"
version = "0.1.0"
edition = "2021"
[dependencies]
hello = { version = "*", path = "../hello" }
world = { version = "*", path = "../world" }

View File

@ -0,0 +1,3 @@
fn main() {
println!("{}, {}", hello::hello(), world::world());
}

View File

@ -0,0 +1,4 @@
[package]
name = "world"
version = "0.1.0"
edition = "2021"

View File

@ -0,0 +1,3 @@
pub fn world() -> &'static str {
"world!"
}