Repository: rust-ndarray/ndarray
Pull request #1405 (2024-08-01 17:31:34)

Organize the workspace of test crates a bit better
Using workspace = true (Rust 1.64+)

Moving 

- xtest-numeric -> extra-tests/numeric
- xtest-serialization -> extra-tests/serialization
- xtest-blas -> extra-tests/blas


Patch:
diff --git a/Cargo.toml b/Cargo.toml
index 943621de..f2a6f7fd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -80,7 +80,18 @@ opt-level = 2
 opt-level = 2
 
 [workspace]
-members = ["ndarray-rand", "xtest-serialization", "xtest-blas", "xtest-numeric"]
+members = [
+    "ndarray-rand",
+    "extra-tests/serialization",
+    "extra-tests/blas",
+    "extra-tests/numeric",
+]
+
+[workspace.dependencies]
+ndarray = { path = "." }
+num-traits = { version = "0.2", default-features = false }
+num-complex = { version = "0.4", default-features = false }
+ndarray-rand = { path = "./ndarray-rand" }
 
 [package.metadata.release]
 no-dev-version = true


Test patch:
diff --git a/extra-tests/README.md b/extra-tests/README.md
new file mode 100644
index 00000000..5b5b78b5
--- /dev/null
+++ b/extra-tests/README.md
@@ -0,0 +1,5 @@
+
+# Extra Tests
+
+These are test crates whose settings, features and dependencies should be
+separate from the main crate.
diff --git a/xtest-blas/Cargo.toml b/extra-tests/blas/Cargo.toml
similarity index 86%
rename from xtest-blas/Cargo.toml
rename to extra-tests/blas/Cargo.toml
index b53919e9..a41efa57 100644
--- a/xtest-blas/Cargo.toml
+++ b/extra-tests/blas/Cargo.toml
@@ -11,11 +11,11 @@ test = false
 [dev-dependencies]
 approx = "0.5"
 defmac = "0.2"
-num-traits = "0.2"
-num-complex = { version = "0.4", default-features = false }
+num-traits = { workspace = true }
+num-complex = { workspace = true }
 
 [dependencies]
-ndarray = { path = "..", features = ["approx", "blas"] }
+ndarray = { workspace = true, features = ["approx"] }
 
 blas-src = { version = "0.10", optional = true }
 
diff --git a/xtest-blas/src/lib.rs b/extra-tests/blas/src/lib.rs
similarity index 100%
rename from xtest-blas/src/lib.rs
rename to extra-tests/blas/src/lib.rs
diff --git a/xtest-blas/tests/oper.rs b/extra-tests/blas/tests/oper.rs
similarity index 100%
rename from xtest-blas/tests/oper.rs
rename to extra-tests/blas/tests/oper.rs
diff --git a/xtest-numeric/Cargo.toml b/extra-tests/numeric/Cargo.toml
similarity index 71%
rename from xtest-numeric/Cargo.toml
rename to extra-tests/numeric/Cargo.toml
index 843fbfef..3af9538e 100644
--- a/xtest-numeric/Cargo.toml
+++ b/extra-tests/numeric/Cargo.toml
@@ -7,8 +7,8 @@ edition = "2018"
 
 [dependencies]
 approx = "0.5"
-ndarray = { path = "..", features = ["approx"] }
-ndarray-rand = { path = "../ndarray-rand" }
+ndarray = { workspace = true, features = ["approx"] }
+ndarray-rand = { workspace = true }
 rand_distr = "0.4"
 
 blas-src = { optional = true, version = "0.10", default-features = false, features = ["openblas"] }
@@ -19,8 +19,8 @@ version = "0.8.0"
 features = ["small_rng"]
 
 [dev-dependencies]
-num-traits = { version = "0.2.14", default-features = false }
-num-complex = { version = "0.4", default-features = false }
+num-traits = { workspace = true }
+num-complex = { workspace = true }
 
 [lib]
 test = false
diff --git a/xtest-numeric/src/lib.rs b/extra-tests/numeric/src/lib.rs
similarity index 100%
rename from xtest-numeric/src/lib.rs
rename to extra-tests/numeric/src/lib.rs
diff --git a/xtest-numeric/tests/accuracy.rs b/extra-tests/numeric/tests/accuracy.rs
similarity index 98%
rename from xtest-numeric/tests/accuracy.rs
rename to extra-tests/numeric/tests/accuracy.rs
index e98fb3c4..c594f020 100644
--- a/xtest-numeric/tests/accuracy.rs
+++ b/extra-tests/numeric/tests/accuracy.rs
@@ -172,9 +172,9 @@ fn random_matrix_mul<A>(
 ) -> (Array2<A>, Array2<A>)
 where A: LinalgScalar
 {
-    let m = rng.gen_range(15..512);
-    let k = rng.gen_range(15..512);
-    let n = rng.gen_range(15..1560);
+    let m = rng.gen_range(15..128);
+    let k = rng.gen_range(15..128);
+    let n = rng.gen_range(15..512);
     let a = generator(Ix2(m, k), rng);
     let b = generator(Ix2(n, k), rng);
     let c = if use_general {
@@ -261,7 +261,7 @@ fn accurate_mul_with_column_f64()
     // pick a few random sizes
     let rng = &mut SmallRng::from_entropy();
     for i in 0..10 {
-        let m = rng.gen_range(1..350);
+        let m = rng.gen_range(1..128);
         let k = rng.gen_range(1..350);
         let a = gen::<f64, _>(Ix2(m, k), rng);
         let b_owner = gen::<f64, _>(Ix2(k, k), rng);
diff --git a/xtest-serialization/Cargo.toml b/extra-tests/serialization/Cargo.toml
similarity index 90%
rename from xtest-serialization/Cargo.toml
rename to extra-tests/serialization/Cargo.toml
index fbc1a7cb..bdfcaf90 100644
--- a/xtest-serialization/Cargo.toml
+++ b/extra-tests/serialization/Cargo.toml
@@ -9,7 +9,7 @@ edition = "2018"
 test = false
 
 [dependencies]
-ndarray = { path = "..", features = ["serde"] }
+ndarray = { workspace = true, features = ["serde"] }
 
 [features]
 default = ["ron"]
diff --git a/xtest-serialization/src/lib.rs b/extra-tests/serialization/src/lib.rs
similarity index 100%
rename from xtest-serialization/src/lib.rs
rename to extra-tests/serialization/src/lib.rs
diff --git a/xtest-serialization/tests/serialize.rs b/extra-tests/serialization/tests/serialize.rs
similarity index 100%
rename from xtest-serialization/tests/serialize.rs
rename to extra-tests/serialization/tests/serialize.rs
diff --git a/scripts/all-tests.sh b/scripts/all-tests.sh
index 03f0729f..ca40c210 100755
--- a/scripts/all-tests.sh
+++ b/scripts/all-tests.sh
@@ -12,11 +12,13 @@ cargo test --verbose --no-default-features
 cargo test --release --verbose --no-default-features
 cargo build --verbose --features "$FEATURES"
 cargo test --verbose --features "$FEATURES"
-cargo test --manifest-path=ndarray-rand/Cargo.toml --no-default-features --verbose
-cargo test --manifest-path=ndarray-rand/Cargo.toml --features quickcheck --verbose
-cargo test --manifest-path=xtest-serialization/Cargo.toml --verbose
-cargo test --manifest-path=xtest-blas/Cargo.toml --verbose --features openblas-system
+cargo test -p ndarray-rand --no-default-features --verbose
+cargo test -p ndarray-rand --features ndarray-rand/quickcheck --verbose
+
+cargo test -p serialization-tests -v
+cargo test -p blas-tests -v --features blas-tests/openblas-system
+cargo test -p numeric-tests -v
+cargo test -p numeric-tests -v --features numeric-tests/test_blas
+
 cargo test --examples
-cargo test --manifest-path=xtest-numeric/Cargo.toml --verbose
-cargo test --manifest-path=xtest-numeric/Cargo.toml --verbose --features test_blas
 ([ "$CHANNEL" != "nightly" ] || cargo bench --no-run --verbose --features "$FEATURES")
diff --git a/scripts/cross-tests.sh b/scripts/cross-tests.sh
index dc27058f..f28623b4 100755
--- a/scripts/cross-tests.sh
+++ b/scripts/cross-tests.sh
@@ -9,6 +9,6 @@ TARGET=$3
 
 cross build -v --features="$FEATURES" --target=$TARGET
 cross test -v --no-fail-fast --features="$FEATURES" --target=$TARGET
-cross test -v --no-fail-fast --target=$TARGET --manifest-path=ndarray-rand/Cargo.toml --features quickcheck
-cross test -v --no-fail-fast --target=$TARGET --manifest-path=xtest-serialization/Cargo.toml --verbose
-cross test -v --no-fail-fast --target=$TARGET --manifest-path=xtest-numeric/Cargo.toml --release
+cross test -v --no-fail-fast --target=$TARGET -p ndarray-rand --features ndarray-rand/quickcheck
+cross test -v --no-fail-fast --target=$TARGET -p serialization-tests --verbose
+cross test -v --no-fail-fast --target=$TARGET -p numeric-tests --release