From 9761faba8dc17e270073c3ea8bf2f33763cfd580 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Tue, 4 Jul 2023 21:36:18 +0100 Subject: [PATCH] Collect code coverage --- .github/workflows/coverage.yml | 26 ++++++++++++++++++++++++++ src/util.rs | 10 +++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..64e8a8a --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,26 @@ +on: [ push, pull_request ] + +name: Test coverage + +jobs: + coverage: + name: Collect test coverage + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + components: llvm-tools-preview + - name: Install latest nextest release + uses: taiki-e/install-action@nextest + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Collect coverage data + run: cargo llvm-cov nextest --lcov --output-path lcov.info + - name: Upload coverage data to codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + files: lcov.info diff --git a/src/util.rs b/src/util.rs index 6df9967..3ccaf2e 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,16 +1,24 @@ +use std::hash::Hasher; use std::{ borrow::Cow, fmt::{Display, Formatter}, + hash::Hash, ops::Deref, sync::Arc, }; -#[derive(Debug, Hash, Eq)] +#[derive(Debug, Eq)] pub enum ArcOrCowStr { Arc(Arc), Cow(Cow<'static, str>), } +impl Hash for ArcOrCowStr { + fn hash(&self, state: &mut H) { + (**self).hash(state); + } +} + impl PartialEq for ArcOrCowStr { fn eq(&self, other: &ArcOrCowStr) -> bool { **self == **other -- libgit2 1.7.2