diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 468f0b4..e18ed57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,26 +8,35 @@ env: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + strace-parser: [combinator, peg, regex] steps: - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable - - run: cargo build --verbose + - run: cargo build --no-default-features --features strace-parser-${{matrix.strace-parser}} --verbose test: runs-on: ubuntu-latest + strategy: + matrix: + strace-parser: [combinator, peg, regex] steps: - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable - - run: cargo test --bins --verbose + - run: cargo test --bins --no-default-features --features strace-parser-${{matrix.strace-parser}} --verbose clippy: runs-on: ubuntu-latest + strategy: + matrix: + strace-parser: [combinator, peg, regex] steps: - uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 @@ -35,7 +44,7 @@ jobs: profile: minimal toolchain: stable components: clippy - - run: cargo clippy -- -D warnings + - run: cargo clippy --no-default-features --features strace-parser-${{matrix.strace-parser}} -- -D warnings fmt: runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index e676f02..775b6e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,13 +39,12 @@ predicates = { version = "3.0.3", default-features = false, features = ["color"] pretty_assertions = { version = "1.4.0", default-features = false, features = ["std"] } [features] -default = ["parser-combinator"] +default = ["strace-parser-combinator"] as-root = [] # for tests only nightly = [] # for benchmarks only -parser-combinator = ["dep:function_name", "dep:nom"] -parser-peg = ["dep:pest", "dep:pest_derive"] -parser-regex = [] -function_name = ["dep:function_name"] +strace-parser-combinator = ["dep:function_name", "dep:nom"] +strace-parser-peg = ["dep:pest", "dep:pest_derive"] +strace-parser-regex = [] [lints.rust] missing_docs = "warn" diff --git a/src/strace/mod.rs b/src/strace/mod.rs index 00cba9a..68716e3 100644 --- a/src/strace/mod.rs +++ b/src/strace/mod.rs @@ -50,6 +50,7 @@ pub enum Expression { args: Vec, }, // Only used for strace pseudo macro invocations, see `test_macro_addr_arg` for an example + #[cfg_attr(feature = "strace-parser-regex", allow(dead_code))] DestinationAddress(String), } diff --git a/src/strace/parser/mod.rs b/src/strace/parser/mod.rs index a5f8380..8cb9d2f 100644 --- a/src/strace/parser/mod.rs +++ b/src/strace/parser/mod.rs @@ -8,18 +8,18 @@ use std::{ use crate::strace::Syscall; -#[cfg(feature = "parser-combinator")] +#[cfg(feature = "strace-parser-combinator")] mod combinator; -#[cfg(feature = "parser-peg")] +#[cfg(feature = "strace-parser-peg")] mod peg; -#[cfg(feature = "parser-regex")] +#[cfg(feature = "strace-parser-regex")] mod regex; -#[cfg(feature = "parser-combinator")] +#[cfg(feature = "strace-parser-combinator")] use combinator::parse_line; -#[cfg(feature = "parser-peg")] +#[cfg(feature = "strace-parser-peg")] use peg::parse_line; -#[cfg(feature = "parser-regex")] +#[cfg(feature = "strace-parser-regex")] use regex::parse_line; pub struct LogParser { @@ -1433,7 +1433,7 @@ mod tests { } #[cfg_attr( - feature = "parser-regex", + feature = "strace-parser-regex", ignore = "in/out arguments not supported by regex parser" )] #[test] @@ -1523,7 +1523,7 @@ mod tests { } #[cfg_attr( - feature = "parser-regex", + feature = "strace-parser-regex", ignore = "named arguments not supported by regex parser" )] #[test] @@ -1575,7 +1575,7 @@ mod tests { } #[cfg_attr( - feature = "parser-regex", + feature = "strace-parser-regex", ignore = "bit shifts are broken with regex parser" )] #[test] @@ -1645,7 +1645,7 @@ mod tests { } #[cfg_attr( - feature = "parser-regex", + feature = "strace-parser-regex", ignore = "macro address argument not supported by regex parser" )] #[test] diff --git a/src/strace/parser/regex.rs b/src/strace/parser/regex.rs index 5c6382f..5ff9067 100644 --- a/src/strace/parser/regex.rs +++ b/src/strace/parser/regex.rs @@ -345,7 +345,7 @@ fn parse_argument(caps: ®ex::Captures) -> anyhow::Result { one_shift.to_owned(), )), }) - } else if t.starts_with("0") { + } else if t.starts_with('0') { Ok(IntegerExpressionValue::Literal(i128::from_str_radix(t, 8)?)) } else { Ok(IntegerExpressionValue::NamedConst(t.to_owned()))