Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions nbuild/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@ pub enum PackageKind {
NBuild,
}

/// Can this package be tested?
#[derive(Debug, PartialEq, Eq)]
pub enum Testable {
No,
All,
Libs,
}

/// Describes a package in this repository
#[derive(Debug)]
pub struct Package {
pub name: &'static str,
pub path: &'static std::path::Path,
pub kind: PackageKind,
pub testable: bool,
pub testable: Testable,
pub output_template: Option<&'static str>,
}

Expand Down Expand Up @@ -98,7 +106,7 @@ where
}
command_line.arg("--manifest-path");
command_line.arg(manifest_path.as_ref());
for (k, v) in environment.into_iter() {
for (k, v) in environment.iter() {
command_line.env(k, v);
}

Expand Down
21 changes: 17 additions & 4 deletions nbuild/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ fn packages() -> Vec<nbuild::Package> {
path: std::path::Path::new("./nbuild/Cargo.toml"),
output_template: None,
kind: nbuild::PackageKind::NBuild,
testable: true,
testable: nbuild::Testable::All,
},
nbuild::Package {
name: "flames",
path: std::path::Path::new("./utilities/flames/Cargo.toml"),
output_template: Some("./target/{target}/{profile}/flames"),
kind: nbuild::PackageKind::Utility,
testable: false,
testable: nbuild::Testable::No,
},
nbuild::Package {
name: "Neotron OS",
path: std::path::Path::new("./neotron-os/Cargo.toml"),
output_template: Some("./target/{target}/{profile}/neotron-os"),
kind: nbuild::PackageKind::Os,
testable: false,
testable: nbuild::Testable::Libs,
},
]
}
Expand Down Expand Up @@ -265,7 +265,20 @@ fn clippy(packages: &[nbuild::Package]) {
/// Runs `cargo test` over all the packages
fn test(packages: &[nbuild::Package]) {
let mut is_error = false;
for package in packages.iter().filter(|p| p.testable) {
for package in packages
.iter()
.filter(|p| p.testable == nbuild::Testable::Libs)
{
println!("Testing {}", package.name);
if let Err(e) = nbuild::cargo(&["test", "--lib"], None, package.path) {
eprintln!("Test failed: {}", e);
is_error = true;
}
}
for package in packages
.iter()
.filter(|p| p.testable == nbuild::Testable::All)
{
println!("Testing {}", package.name);
if let Err(e) = nbuild::cargo(&["test"], None, package.path) {
eprintln!("Test failed: {}", e);
Expand Down
Loading