Skip to content

test: Move style logic to libc-test source #4570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ target="$1"
export RUST_BACKTRACE="${RUST_BACKTRACE:-1}"

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

# Run tests in the `libc` crate
case "$target" in
Expand Down
13 changes: 4 additions & 9 deletions libc-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/libc"

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

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

[build-dependencies]
cc = "1.2.29"
Expand Down Expand Up @@ -95,12 +95,7 @@ harness = true

[[test]]
name = "style"
path = "test/check_style.rs"
harness = true

[[test]]
name = "style_tests"
path = "test/style_tests.rs"
path = "test/style.rs"
harness = true

# FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]`
Expand Down
1 change: 1 addition & 0 deletions libc-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod style;
7 changes: 4 additions & 3 deletions libc-test/test/style/mod.rs → libc-test/src/style.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! Provides the [StyleChecker] visitor to verify the coding style of
//! this library.
//!
//! This is split out so that the implementation itself can be tested
//! separately, see test/check_style.rs for how it's used and
//! test/style_tests.rs for the implementation tests.
//! See `tests/style.rs` for the invocation that gets run on CI.
//!
//! ## Guidelines
//!
Expand Down Expand Up @@ -37,6 +35,9 @@ use syn::spanned::Spanned;
use syn::visit::{self, Visit};
use syn::Token;

#[cfg(test)]
mod tests;

const ALLOWED_REPEATED_MACROS: &[&str] = &["s", "s_no_extra_traits", "s_paren"];

pub type Error = Box<dyn std::error::Error>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Verifies the implementation of the style checker in [style].

use style::StyleChecker;

pub mod style;
use super::StyleChecker;

#[test]
fn check_style_accept_correct_module_layout() {
Expand Down
4 changes: 1 addition & 3 deletions libc-test/test/check_style.rs → libc-test/test/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
//! cargo test --test style
//! ```

pub mod style;

use std::env;
use std::path::Path;

use style::{Result, StyleChecker};
use libc_test::style::{Result, StyleChecker};

/// Relative to `src/`.
const SKIP_PREFIXES: &[&str] = &[
Expand Down
Loading