Skip to content

Commit

Permalink
ci: test all parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma-s1n committed Jun 3, 2024
1 parent b910bbc commit dd78614
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,43 @@ 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
with:
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
Expand Down
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/strace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub enum Expression {
args: Vec<Expression>,
},
// 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),
}

Expand Down
20 changes: 10 additions & 10 deletions src/strace/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -1523,7 +1523,7 @@ mod tests {
}

#[cfg_attr(
feature = "parser-regex",
feature = "strace-parser-regex",
ignore = "named arguments not supported by regex parser"
)]
#[test]
Expand Down Expand Up @@ -1575,7 +1575,7 @@ mod tests {
}

#[cfg_attr(
feature = "parser-regex",
feature = "strace-parser-regex",
ignore = "bit shifts are broken with regex parser"
)]
#[test]
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/strace/parser/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ fn parse_argument(caps: &regex::Captures) -> anyhow::Result<Expression> {
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()))
Expand Down

0 comments on commit dd78614

Please sign in to comment.