Skip to content

Commit

Permalink
Add test for #60
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Shadle committed Jan 12, 2024
1 parent 24df688 commit 2bfb66f
Show file tree
Hide file tree
Showing 11 changed files with 1,598 additions and 8 deletions.
18 changes: 18 additions & 0 deletions tests/feature-bug/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[workspace.dependencies]
ndarray-linalg = { path = "ndarray-linalg" }
lax = { path = "lax" }

workspace.members = ["lax", "ndarray-linalg", "sub-crate"]

[package]
name = "feature-bug"
version = "0.1.0"
edition = "2021"

[dependencies]
sub-crate = { path = "sub-crate", version = "0.1", default-features = false, features = [
"simple",
] }

[dev-dependencies]
ndarray-linalg = { workspace = true, features = ["intel-mkl-static"] }
40 changes: 40 additions & 0 deletions tests/feature-bug/lax/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
name = "lax"
version = "0.16.0"
edition = "2021"

[features]
default = []

netlib = ["netlib-static"]
openblas = ["openblas-static"]
intel-mkl = ["intel-mkl-static"]

netlib-static = ["netlib-src/static"]
netlib-system = ["netlib-src/system"]

openblas-static = ["openblas-src/static"]
openblas-system = ["openblas-src/system"]

intel-mkl-static = ["intel-mkl-src/mkl-static-lp64-seq"]
intel-mkl-system = ["intel-mkl-src/mkl-dynamic-lp64-seq"]

[dependencies]
itoa = "1.0"

[dependencies.intel-mkl-src]
version = "0.8.1"
default-features = false
optional = true

[dependencies.netlib-src]
version = "0.8.0"
optional = true
features = ["cblas"]
default-features = false

[dependencies.openblas-src]
version = "0.10.4"
optional = true
default-features = false
features = ["cblas"]
14 changes: 14 additions & 0 deletions tests/feature-bug/lax/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
36 changes: 36 additions & 0 deletions tests/feature-bug/ndarray-linalg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
name = "ndarray-linalg"
version = "0.1.0"
edition = "2021"

[features]
default = []

netlib = ["lax/netlib"]
openblas = ["lax/openblas"]
intel-mkl = ["lax/intel-mkl"]

netlib-static = ["lax/netlib-static"]
netlib-system = ["lax/netlib-system"]

openblas-static = ["lax/openblas-static"]
openblas-system = ["lax/openblas-system"]

intel-mkl-static = ["lax/intel-mkl-static"]
intel-mkl-system = ["lax/intel-mkl-system"]

[dependencies]
libc = "0.2"

[dependencies.ndarray]
version = "0.15.2"
features = ["blas", "approx", "std"]
default-features = false

[dependencies.lax]
version = "0.16.0"
workspace = true
default-features = false

[dev-dependencies]
paste = "1.0.5"
14 changes: 14 additions & 0 deletions tests/feature-bug/ndarray-linalg/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
14 changes: 14 additions & 0 deletions tests/feature-bug/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
16 changes: 16 additions & 0 deletions tests/feature-bug/sub-crate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "sub-crate"
version = "0.1.0"
edition = "2021"

[features]
default = []
simple = ["dep:ndarray-linalg"]

[target.'cfg(target_os = "windows")'.dependencies]
ndarray-linalg = { workspace = true, default-features = false, optional = true }

[target.'cfg(target_os = "linux")'.dependencies]
ndarray-linalg = { workspace = true, default-features = false, features = [
"netlib",
], optional = true }
1 change: 1 addition & 0 deletions tests/feature-bug/sub-crate/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

17 changes: 17 additions & 0 deletions tests/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,23 @@ fn handles_cyclic_features() {
assert_features!(md, "features-galore", ["cycle", "midi", "subfeatcycle"]);
}

/// Ensures that features only brought in by eg dev-dependencies are not used if
/// dev-dependencies are ignored
/// <https://github.com/EmbarkStudios/krates/issues/60>
#[test]
fn ignores_features_for_ignored_kinds() {
let mut cmd = krates::Cmd::new();
cmd.manifest_path("tests/feature-bug/Cargo.toml")
.all_features();

let mut builder = krates::Builder::new();
builder.ignore_kind(krates::DepKind::Dev, krates::Scope::All);
let md: krates::Krates<util::JustId> = builder.build(cmd, krates::NoneFilter).unwrap();

let dotgraph = krates::petgraph::dot::Dot::new(md.graph()).to_string();
insta::assert_snapshot!(dotgraph);
}

/// Tests validating <https://github.com/EmbarkStudios/krates/issues/46>
mod prefer_index {
fn confirm_index_snapshot(builder: krates::Builder) {
Expand Down
9 changes: 1 addition & 8 deletions tests/features/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
}

1,427 changes: 1,427 additions & 0 deletions tests/snapshots/features__ignores_features_for_ignored_kinds.snap

Large diffs are not rendered by default.

0 comments on commit 2bfb66f

Please sign in to comment.