Skip to content
Merged
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
62 changes: 27 additions & 35 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,33 @@ on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy, llvm-tools-preview

- name: Install lcov
run: sudo apt-get install lcov

- name: install grcov
run: cargo install grcov

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Run grcov
env:
PROJECT_NAME: "havocompare"
RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
CARGO_INCREMENTAL: 0
run: |
cargo +nightly build --verbose
cargo +nightly test --verbose
grcov . -s . --binary-path ./target/debug/ -t lcov --llvm --branch --ignore-not-existing --ignore="/*" --ignore="target/*" --ignore="tests/*" -o lcov.info

- name: Push grcov results to Coveralls via GitHub Action
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: "lcov.info"

- uses: actions/checkout@v4
- name: Install latest stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy, llvm-tools-preview

- name: Install lcov
run: sudo apt-get install lcov

- name: install grcov
run: cargo install grcov

- name: Run grcov
env:
PROJECT_NAME: "havocompare"
RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off"
CARGO_INCREMENTAL: 0
run: |
cargo +stable build --verbose
cargo +stable test --verbose
grcov . -s . --binary-path ./target/debug/ -t lcov --llvm --branch --ignore-not-existing --ignore="/*" --ignore="target/*" --ignore="tests/*" -o lcov.info

- name: Push grcov results to Coveralls via GitHub Action
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: "lcov.info"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/target
.idea
Cargo.lock
.vscode/
.zed/
report/
*.jpgdiff_image.png
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ description = "A flexible rule-based file and folder comparison tool and crate i
repository = "https://github.com/VolumeGraphics/havocompare"
homepage = "https://github.com/VolumeGraphics/havocompare"
documentation = "https://docs.rs/havocompare"
version = "0.8.0"
version = "0.9.0-alpha.1"
edition = "2021"
rust-version = "1.85"
license = "MIT"
authors = ["Volume Graphics GmbH"]
exclude = ["tests/pdf", "tests/integ", "tests/html", "target", "tests/csv", ".github", "test_report"]
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ rules:

## Changelog

### 0.9.0

- **Breaking**: Minimum supported Rust version (MSRV) is now 1.85
- Internal/CI:
- Switch GitHub CI from `nightly` to `stable` Rust toolchain
- Fix clippy warnings for Rust 1.93+

### 0.8.0

- Report will always be generated even though compare is failing.
Expand Down
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "stable"
components = ["rustfmt", "clippy"]
profile = "minimal"
4 changes: 2 additions & 2 deletions src/csv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,13 @@ impl Table {
Ok(Table { columns: cols })
}

pub(crate) fn rows(&self) -> RowIterator {
pub(crate) fn rows(&self) -> RowIterator<'_> {
RowIterator {
position: self.columns.iter().map(|c| c.rows.iter()).collect(),
}
}

pub(crate) fn rows_mut(&mut self) -> RowIteratorMut {
pub(crate) fn rows_mut(&mut self) -> RowIteratorMut<'_> {
RowIteratorMut {
position: self.columns.iter_mut().map(|c| c.rows.iter_mut()).collect(),
}
Expand Down
4 changes: 2 additions & 2 deletions src/csv/tokenizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub(crate) struct Parser<R: Read + Seek> {
delimiters: Delimiters,
}

fn tokenize(input: &str, field_sep: char) -> Result<Vec<Token>, Error> {
fn tokenize(input: &str, field_sep: char) -> Result<Vec<Token<'_>>, Error> {
let mut tokens = Vec::new();
let mut pos = 0;
while let Some(remainder) = &input.get(pos..) {
Expand Down Expand Up @@ -228,7 +228,7 @@ fn parse_literal(
field_sep: char,
remainder: &str,
literal_type: LiteralTerminator,
) -> Result<(usize, Token, bool), Error> {
) -> Result<(usize, Token<'_>, bool), Error> {
let terminator_len = literal_type.get_char().len_utf8();
let after_first_quote = &remainder[terminator_len..];
let quote_end =
Expand Down
6 changes: 3 additions & 3 deletions src/csv/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ impl Display for Value {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match &self {
Value::Quantity(val) => {
write!(f, "{val}").unwrap();
let _ = write!(f, "{val}");
}
Value::String(val) => {
write!(f, "'{val}'").unwrap();
let _ = write!(f, "'{val}'");
}
}
Ok(())
Expand Down Expand Up @@ -143,7 +143,7 @@ impl Value {
}
}

pub fn as_str(&self) -> Cow<str> {
pub fn as_str(&self) -> Cow<'_, str> {
match self {
Value::String(str) => str.as_str().into(),
Value::Quantity(quant) => quant.to_string().into(),
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub enum ComparisonMode {
Directory(DirectoryConfig),
}

fn get_file_name(path: &Path) -> Option<Cow<str>> {
fn get_file_name(path: &Path) -> Option<Cow<'_, str>> {
path.file_name().map(|f| f.to_string_lossy())
}

Expand Down
8 changes: 2 additions & 6 deletions src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ pub fn write_image_detail(
ctx.insert("actual", &actual.as_ref().to_string_lossy());
ctx.insert("nominal", &nominal.as_ref().to_string_lossy());

fn get_file_name(path: &Path) -> Result<Cow<str>, Error> {
fn get_file_name(path: &Path) -> Result<Cow<'_, str>, Error> {
path.file_name()
.map(|f| f.to_string_lossy())
.ok_or_else(|| {
Expand Down Expand Up @@ -612,11 +612,7 @@ pub fn write_error_detail(
errors: &[&String],
report_dir: impl AsRef<Path>,
) -> Option<DetailPath> {
if let Ok(sub_folder) = create_error_detail(nominal, actual, errors, report_dir) {
Some(sub_folder)
} else {
None
}
create_error_detail(nominal, actual, errors, report_dir).ok()
}

pub(crate) fn create_reports(
Expand Down