From 257563ba2ce01fb0137865d2855de6cdefa46bee Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 23 Jul 2025 22:51:30 -0500 Subject: [PATCH] test: Use automatic test detection Move from `test/` to `tests/`, which is the directory for autodetection. This means that we can drop `[[test]]` entries in `libc-test/Cargo.toml` that don't require nondefault configuration like `harness = false`. The style library had to be moved to `style_lib` so that `style` could be used as the test name. --- libc-test/Cargo.toml | 30 ++++--------------- libc-test/{test => tests}/ctest.rs | 0 libc-test/{test => tests}/linux_elf.rs | 0 libc-test/{test => tests}/linux_fcntl.rs | 0 libc-test/{test => tests}/linux_if_arp.rs | 0 libc-test/{test => tests}/linux_ipv6.rs | 0 .../{test => tests}/linux_kernel_version.rs | 0 libc-test/{test => tests}/linux_strerror_r.rs | 0 libc-test/{test => tests}/linux_termios.rs | 0 libc-test/{test => tests}/semver.rs | 0 .../{test/check_style.rs => tests/style.rs} | 4 +-- .../{test/style => tests/style_lib}/mod.rs | 0 libc-test/{test => tests}/style_tests.rs | 4 +-- 13 files changed, 10 insertions(+), 28 deletions(-) rename libc-test/{test => tests}/ctest.rs (100%) rename libc-test/{test => tests}/linux_elf.rs (100%) rename libc-test/{test => tests}/linux_fcntl.rs (100%) rename libc-test/{test => tests}/linux_if_arp.rs (100%) rename libc-test/{test => tests}/linux_ipv6.rs (100%) rename libc-test/{test => tests}/linux_kernel_version.rs (100%) rename libc-test/{test => tests}/linux_strerror_r.rs (100%) rename libc-test/{test => tests}/linux_termios.rs (100%) rename libc-test/{test => tests}/semver.rs (100%) rename libc-test/{test/check_style.rs => tests/style.rs} (96%) rename libc-test/{test/style => tests/style_lib}/mod.rs (100%) rename libc-test/{test => tests}/style_tests.rs (99%) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 66940ee8db169..f764d76d0cc2d 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -30,54 +30,36 @@ extra_traits = ["libc/extra_traits"] [[test]] name = "ctest" -path = "test/ctest.rs" harness = false [[test]] -name = "linux-fcntl" -path = "test/linux_fcntl.rs" +name = "linux_fcntl" harness = false [[test]] -name = "linux-if-arp" -path = "test/linux_if_arp.rs" +name = "linux_if_arp" harness = false [[test]] -name = "linux-ipv6" -path = "test/linux_ipv6.rs" +name = "linux_ipv6" harness = false [[test]] -name = "linux-elf" -path = "test/linux_elf.rs" +name = "linux_elf" harness = false [[test]] -name = "linux-strerror_r" -path = "test/linux_strerror_r.rs" +name = "linux_strerror_r" harness = false [[test]] -name = "linux-termios" -path = "test/linux_termios.rs" +name = "linux_termios" harness = false [[test]] name = "semver" -path = "test/semver.rs" harness = false -[[test]] -name = "style" -path = "test/check_style.rs" -harness = true - -[[test]] -name = "style_tests" -path = "test/style_tests.rs" -harness = true - # FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]` # once MSRV is above 1.64 and replaced with `[lints] workspace=true` diff --git a/libc-test/test/ctest.rs b/libc-test/tests/ctest.rs similarity index 100% rename from libc-test/test/ctest.rs rename to libc-test/tests/ctest.rs diff --git a/libc-test/test/linux_elf.rs b/libc-test/tests/linux_elf.rs similarity index 100% rename from libc-test/test/linux_elf.rs rename to libc-test/tests/linux_elf.rs diff --git a/libc-test/test/linux_fcntl.rs b/libc-test/tests/linux_fcntl.rs similarity index 100% rename from libc-test/test/linux_fcntl.rs rename to libc-test/tests/linux_fcntl.rs diff --git a/libc-test/test/linux_if_arp.rs b/libc-test/tests/linux_if_arp.rs similarity index 100% rename from libc-test/test/linux_if_arp.rs rename to libc-test/tests/linux_if_arp.rs diff --git a/libc-test/test/linux_ipv6.rs b/libc-test/tests/linux_ipv6.rs similarity index 100% rename from libc-test/test/linux_ipv6.rs rename to libc-test/tests/linux_ipv6.rs diff --git a/libc-test/test/linux_kernel_version.rs b/libc-test/tests/linux_kernel_version.rs similarity index 100% rename from libc-test/test/linux_kernel_version.rs rename to libc-test/tests/linux_kernel_version.rs diff --git a/libc-test/test/linux_strerror_r.rs b/libc-test/tests/linux_strerror_r.rs similarity index 100% rename from libc-test/test/linux_strerror_r.rs rename to libc-test/tests/linux_strerror_r.rs diff --git a/libc-test/test/linux_termios.rs b/libc-test/tests/linux_termios.rs similarity index 100% rename from libc-test/test/linux_termios.rs rename to libc-test/tests/linux_termios.rs diff --git a/libc-test/test/semver.rs b/libc-test/tests/semver.rs similarity index 100% rename from libc-test/test/semver.rs rename to libc-test/tests/semver.rs diff --git a/libc-test/test/check_style.rs b/libc-test/tests/style.rs similarity index 96% rename from libc-test/test/check_style.rs rename to libc-test/tests/style.rs index d1d7fdf4aa150..d5af8dddbf973 100644 --- a/libc-test/test/check_style.rs +++ b/libc-test/tests/style.rs @@ -9,12 +9,12 @@ //! cargo test --test style //! ``` -pub mod style; +pub mod style_lib; use std::env; use std::path::Path; -use style::{Result, StyleChecker}; +use style_lib::{Result, StyleChecker}; /// Relative to `src/`. const SKIP_PREFIXES: &[&str] = &[ diff --git a/libc-test/test/style/mod.rs b/libc-test/tests/style_lib/mod.rs similarity index 100% rename from libc-test/test/style/mod.rs rename to libc-test/tests/style_lib/mod.rs diff --git a/libc-test/test/style_tests.rs b/libc-test/tests/style_tests.rs similarity index 99% rename from libc-test/test/style_tests.rs rename to libc-test/tests/style_tests.rs index be8fddbccf644..e136bb66d26a4 100644 --- a/libc-test/test/style_tests.rs +++ b/libc-test/tests/style_tests.rs @@ -1,8 +1,8 @@ //! Verifies the implementation of the style checker in [style]. -use style::StyleChecker; +use style_lib::StyleChecker; -pub mod style; +pub mod style_lib; #[test] fn check_style_accept_correct_module_layout() {