From dd0dc265a94cba5d25a5ee679634d28a00e66227 Mon Sep 17 00:00:00 2001 From: Jim Turner Date: Sat, 14 Sep 2024 01:09:01 -0400 Subject: [PATCH] Allow running tests with --no-default-features (#77) --- .github/workflows/ci.yml | 18 ++++++++++++++++++ tests/integration/examples.rs | 8 ++++++++ tests/integration/round_trip.rs | 2 ++ 3 files changed, 28 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a61dcc..214a0d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,24 @@ jobs: - name: Run tests run: cargo test --verbose + test_no_default_features: + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + - beta + - nightly + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + - name: Build + run: cargo build --no-default-features --verbose + - name: Run tests + run: cargo test --no-default-features --verbose + # We have to test the MSRV without the zip crate, since the zip crate has a higher MSRV and # doesn't consider a MSRV update to be a breaking change. test_msrv: diff --git a/tests/integration/examples.rs b/tests/integration/examples.rs index 642646b..2b1aee6 100644 --- a/tests/integration/examples.rs +++ b/tests/integration/examples.rs @@ -7,6 +7,7 @@ use ndarray_npy::{ write_zeroed_npy, ReadNpyError, ReadNpyExt, ViewMutNpyExt, ViewNpyError, ViewNpyExt, WriteNpyExt, }; +#[cfg(feature = "num-complex-0_4")] use num_complex_0_4::Complex; use std::fs::{self, File}; use std::io::{Read, Seek, SeekFrom, Write}; @@ -29,6 +30,7 @@ fn write_f64_standard() { assert_eq!(&correct, &writer); } +#[cfg(feature = "num-complex-0_4")] #[test] fn write_c64_standard() { #[cfg(target_endian = "little")] @@ -65,6 +67,7 @@ fn write_f64_fortran() { assert_eq!(&correct[..], &writer[..]); } +#[cfg(feature = "num-complex-0_4")] #[test] fn write_c64_fortran() { #[cfg(target_endian = "little")] @@ -103,6 +106,7 @@ fn write_f64_discontiguous() { assert_eq!(&correct, &writer); } +#[cfg(feature = "num-complex-0_4")] #[test] fn write_c64_discontiguous() { #[cfg(target_endian = "little")] @@ -141,6 +145,7 @@ fn read_f64_standard() { } } +#[cfg(feature = "num-complex-0_4")] #[test] fn read_c64_standard() { let mut correct = Array3::>::zeros((2, 3, 4)); @@ -175,6 +180,7 @@ fn read_f64_fortran() { } } +#[cfg(feature = "num-complex-0_4")] #[test] fn read_c64_fortran() { let mut correct = Array3::>::zeros((2, 3, 4).f()); @@ -230,6 +236,7 @@ fn view_f64_standard() { assert!(view.is_standard_layout()); } +#[cfg(feature = "num-complex-0_4")] #[test] fn view_c64_standard() { #[cfg(target_endian = "little")] @@ -266,6 +273,7 @@ fn view_f64_fortran() { assert!(view.t().is_standard_layout()); } +#[cfg(feature = "num-complex-0_4")] #[test] fn view_c64_fortran() { #[cfg(target_endian = "little")] diff --git a/tests/integration/round_trip.rs b/tests/integration/round_trip.rs index d0b809c..a983da0 100644 --- a/tests/integration/round_trip.rs +++ b/tests/integration/round_trip.rs @@ -7,6 +7,7 @@ use ndarray_npy::{ ReadNpyExt, ReadableElement, ViewElement, ViewMutElement, ViewMutNpyExt, ViewNpyExt, WritableElement, WriteNpyExt, }; +#[cfg(feature = "num-complex-0_4")] use num_complex_0_4::Complex; use std::fmt::Debug; use std::mem; @@ -149,6 +150,7 @@ fn round_trip_f64() { ); } +#[cfg(feature = "num-complex-0_4")] #[test] fn round_trip_c32() { test_round_trip_multiple_layouts(