Skip to content

Commit 9afb2dd

Browse files
committed
test: Move style logic to libc-test source
This doesn't need to reside only within the test directory, so move it to the library to make testing simpler.
1 parent 503ece7 commit 9afb2dd

File tree

6 files changed

+12
-19
lines changed

6 files changed

+12
-19
lines changed

ci/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ target="$1"
1010
export RUST_BACKTRACE="${RUST_BACKTRACE:-1}"
1111

1212
cmd="cargo test --target $target ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}"
13-
test_flags="--skip check_style"
13+
test_flags="--skip style"
1414

1515
# Run tests in the `libc` crate
1616
case "$target" in

libc-test/Cargo.toml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ license = "MIT OR Apache-2.0"
99
repository = "https://github.com/rust-lang/libc"
1010

1111
[dependencies]
12+
annotate-snippets = { version = "0.11.5", features = ["testing-colors"] }
1213
cfg-if = "1.0.1"
1314
libc = { path = "..", version = "1.0.0-alpha.1", default-features = false }
15+
proc-macro2 = { version = "1.0.95", features = ["span-locations"] }
16+
syn = { version = "2.0.104", features = ["full", "visit"] }
1417

1518
[dev-dependencies]
16-
syn = { version = "2.0.104", features = ["full", "visit"] }
17-
proc-macro2 = { version = "1.0.95", features = ["span-locations"] }
1819
glob = "0.3.2"
19-
annotate-snippets = { version = "0.11.5", features = ["testing-colors"] }
2020

2121
[build-dependencies]
2222
cc = "1.2.29"
@@ -95,12 +95,7 @@ harness = true
9595

9696
[[test]]
9797
name = "style"
98-
path = "test/check_style.rs"
99-
harness = true
100-
101-
[[test]]
102-
name = "style_tests"
103-
path = "test/style_tests.rs"
98+
path = "test/style.rs"
10499
harness = true
105100

106101
# FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]`

libc-test/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod style;

libc-test/test/style/mod.rs renamed to libc-test/src/style.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//! Provides the [StyleChecker] visitor to verify the coding style of
22
//! this library.
33
//!
4-
//! This is split out so that the implementation itself can be tested
5-
//! separately, see test/check_style.rs for how it's used and
6-
//! test/style_tests.rs for the implementation tests.
4+
//! See `tests/style.rs` for the invocation that gets run on CI.
75
//!
86
//! ## Guidelines
97
//!
@@ -37,6 +35,9 @@ use syn::spanned::Spanned;
3735
use syn::visit::{self, Visit};
3836
use syn::Token;
3937

38+
#[cfg(test)]
39+
mod tests;
40+
4041
const ALLOWED_REPEATED_MACROS: &[&str] = &["s", "s_no_extra_traits", "s_paren"];
4142

4243
pub type Error = Box<dyn std::error::Error>;

libc-test/test/style_tests.rs renamed to libc-test/src/style/tests.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//! Verifies the implementation of the style checker in [style].
22
3-
use style::StyleChecker;
4-
5-
pub mod style;
3+
use super::StyleChecker;
64

75
#[test]
86
fn check_style_accept_correct_module_layout() {

libc-test/test/check_style.rs renamed to libc-test/test/style.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
//! cargo test --test style
1010
//! ```
1111
12-
pub mod style;
13-
1412
use std::env;
1513
use std::path::Path;
1614

17-
use style::{Result, StyleChecker};
15+
use libc_test::style::{Result, StyleChecker};
1816

1917
/// Relative to `src/`.
2018
const SKIP_PREFIXES: &[&str] = &[

0 commit comments

Comments
 (0)