From 89fc0bb3a7fd51c21025fc96aeeb4276f1a29570 Mon Sep 17 00:00:00 2001 From: Amos Wenger Date: Fri, 26 Jan 2024 16:44:19 +0100 Subject: [PATCH] Use cargo-hack --feature-powerset --- .github/workflows/test.yml | 6 +++--- .gitignore | 1 + Justfile | 4 ++-- crates/rc-zip/src/error.rs | 2 ++ crates/rc-zip/src/reader/sync/decoder.rs | 1 + crates/rc-zip/src/reader/sync/entry_reader.rs | 8 +++++++- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60f6170..754648b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,17 +24,17 @@ jobs: run: rustup show - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.3 - - name: Install cargo-nextest + - name: Install just, nextest, cargo-llvm-cov, and cargo-hack uses: taiki-e/install-action@v2 with: - tool: just,nextest,cargo-llvm-cov + tool: just,nextest,cargo-llvm-cov,cargo-hack - name: Run cargo doc, deny warnings run: | export RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps - name: Run cargo clippy run: | - cargo clippy --all-targets --all-features + cargo hack clippy --feature-powerset - name: Run tests and collect coverage run: just ci-test - name: Upload coverage information diff --git a/.gitignore b/.gitignore index 31acb8b..77aae4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target .vscode/launch.json **/*.rs.bk +*.lcov diff --git a/Justfile b/Justfile index c09d602..fa53750 100644 --- a/Justfile +++ b/Justfile @@ -4,7 +4,7 @@ _default: just --list check: - cargo clippy --all-features --all-targets + cargo hack clippy --feature-powerset # Run all tests locally test *args: @@ -15,5 +15,5 @@ ci-test: #!/bin/bash -eux source <(cargo llvm-cov show-env --export-prefix) cargo llvm-cov clean --workspace - cargo nextest run --profile ci + cargo nextest run --all-features --profile ci cargo llvm-cov report --lcov --output-path coverage.lcov diff --git a/crates/rc-zip/src/error.rs b/crates/rc-zip/src/error.rs index fb50321..a8894f9 100644 --- a/crates/rc-zip/src/error.rs +++ b/crates/rc-zip/src/error.rs @@ -28,6 +28,8 @@ pub enum Error { pub enum UnsupportedError { #[error("unsupported compression method: {0:?}")] UnsupportedCompressionMethod(crate::format::Method), + #[error("compression method supported, but not enabled in this build: {0:?}")] + CompressionMethodNotEnabled(crate::format::Method), } /// Specific zip format errors, mostly due to invalid zip archives but that could also stem from diff --git a/crates/rc-zip/src/reader/sync/decoder.rs b/crates/rc-zip/src/reader/sync/decoder.rs index ea19da9..058e503 100644 --- a/crates/rc-zip/src/reader/sync/decoder.rs +++ b/crates/rc-zip/src/reader/sync/decoder.rs @@ -15,6 +15,7 @@ where fn get_mut(&mut self) -> &mut R; } +#[cfg(feature = "deflate")] impl Decoder for DeflateDecoder where R: io::Read, diff --git a/crates/rc-zip/src/reader/sync/entry_reader.rs b/crates/rc-zip/src/reader/sync/entry_reader.rs index aca7cb6..f82e873 100644 --- a/crates/rc-zip/src/reader/sync/entry_reader.rs +++ b/crates/rc-zip/src/reader/sync/entry_reader.rs @@ -75,7 +75,13 @@ where let limited_reader = LimitedReader::new(buffer, self.inner.compressed_size); let decoder: Box> = match self.method { Method::Store => Box::new(StoreDecoder::new(limited_reader)), - Method::Deflate => Box::new(DeflateDecoder::new(limited_reader)), + Method::Deflate => { + #[cfg(feature = "deflate")] + { Box::new(DeflateDecoder::new(limited_reader)) } + + #[cfg(not(feature = "deflate"))] + { return Err(Error::Unsupported(UnsupportedError::CompressionMethodNotEnabled(Method::Deflate)).into()) } + }, method => return Err(Error::Unsupported(UnsupportedError::UnsupportedCompressionMethod(method)).into()), };