From 2b89a5808fd1e1d6346e3aa4bed6d84651c0cfc2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 9 Apr 2024 23:46:33 +0200 Subject: [PATCH] Add regression test for components --- .github/workflows/CI.yml | 2 ++ tests/components.rs | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/components.rs diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7f6aa6f71..b393c1b03 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -164,6 +164,7 @@ jobs: if: matrix.os != 'macos-latest' env: RUST_BACKTRACE: full + LINUX_CI: 1 # Needed for components... - name: Execute tests (mac, no features) run: cargo test --no-default-features -- --test-threads 1 if: matrix.os == 'macos-latest' @@ -180,6 +181,7 @@ jobs: cargo test --features serde --doc env: RUST_BACKTRACE: full + LINUX_CI: 1 # Needed for components... c_interface: runs-on: ubuntu-latest diff --git a/tests/components.rs b/tests/components.rs new file mode 100644 index 000000000..72b9d5379 --- /dev/null +++ b/tests/components.rs @@ -0,0 +1,22 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +#[test] +fn test_components() { + use std::env::var; + + let mut c = sysinfo::Components::new(); + assert!(c.is_empty()); + + // Unfortunately, we can't get components in the CI... + if !sysinfo::IS_SUPPORTED_SYSTEM + || cfg!(windows) + || var("FREEBSD_CI").is_ok() + || var("LINUX_CI").is_ok() + || var("APPLE_CI").is_ok() + { + return; + } + + c.refresh_list(); + assert!(!c.is_empty()); +}