Skip to content

Commit 9ecb42c

Browse files
authored
Merge pull request #111 from Neotron-Compute/nbuild_cleanup
nbuild cleanup
2 parents f5ad60d + 9972f01 commit 9ecb42c

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

nbuild/src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,21 @@ pub enum PackageKind {
2828
NBuild,
2929
}
3030

31+
/// Can this package be tested?
32+
#[derive(Debug, PartialEq, Eq)]
33+
pub enum Testable {
34+
No,
35+
All,
36+
Libs,
37+
}
38+
3139
/// Describes a package in this repository
3240
#[derive(Debug)]
3341
pub struct Package {
3442
pub name: &'static str,
3543
pub path: &'static std::path::Path,
3644
pub kind: PackageKind,
37-
pub testable: bool,
45+
pub testable: Testable,
3846
pub output_template: Option<&'static str>,
3947
}
4048

@@ -98,7 +106,7 @@ where
98106
}
99107
command_line.arg("--manifest-path");
100108
command_line.arg(manifest_path.as_ref());
101-
for (k, v) in environment.into_iter() {
109+
for (k, v) in environment.iter() {
102110
command_line.env(k, v);
103111
}
104112

nbuild/src/main.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,21 @@ fn packages() -> Vec<nbuild::Package> {
4747
path: std::path::Path::new("./nbuild/Cargo.toml"),
4848
output_template: None,
4949
kind: nbuild::PackageKind::NBuild,
50-
testable: true,
50+
testable: nbuild::Testable::All,
5151
},
5252
nbuild::Package {
5353
name: "flames",
5454
path: std::path::Path::new("./utilities/flames/Cargo.toml"),
5555
output_template: Some("./target/{target}/{profile}/flames"),
5656
kind: nbuild::PackageKind::Utility,
57-
testable: false,
57+
testable: nbuild::Testable::No,
5858
},
5959
nbuild::Package {
6060
name: "Neotron OS",
6161
path: std::path::Path::new("./neotron-os/Cargo.toml"),
6262
output_template: Some("./target/{target}/{profile}/neotron-os"),
6363
kind: nbuild::PackageKind::Os,
64-
testable: false,
64+
testable: nbuild::Testable::Libs,
6565
},
6666
]
6767
}
@@ -265,7 +265,20 @@ fn clippy(packages: &[nbuild::Package]) {
265265
/// Runs `cargo test` over all the packages
266266
fn test(packages: &[nbuild::Package]) {
267267
let mut is_error = false;
268-
for package in packages.iter().filter(|p| p.testable) {
268+
for package in packages
269+
.iter()
270+
.filter(|p| p.testable == nbuild::Testable::Libs)
271+
{
272+
println!("Testing {}", package.name);
273+
if let Err(e) = nbuild::cargo(&["test", "--lib"], None, package.path) {
274+
eprintln!("Test failed: {}", e);
275+
is_error = true;
276+
}
277+
}
278+
for package in packages
279+
.iter()
280+
.filter(|p| p.testable == nbuild::Testable::All)
281+
{
269282
println!("Testing {}", package.name);
270283
if let Err(e) = nbuild::cargo(&["test"], None, package.path) {
271284
eprintln!("Test failed: {}", e);

0 commit comments

Comments
 (0)