From 694ff62501e534b7f93a1813abc12f73ec695fd8 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 20 Mar 2020 17:45:00 +0000 Subject: Add coverage gathering with grcov --- .github/workflows/coverage.yml | 27 +++++++++++++++++++++------ dhall/build.rs | 4 ++-- dhall/src/tests.rs | 24 +++++++++++++++++------- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 946113a..ba49b7f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -5,8 +5,8 @@ on: branches: [ master ] jobs: - coverage: - name: Gather coverage data + grcov: + name: Gather coverage data with grcov runs-on: ubuntu-latest steps: - name: Checkout branch @@ -17,11 +17,26 @@ jobs: uses: actions-rs/toolchain@v1 with: profile: minimal - - name: Run tests with tarpaulin - uses: actions-rs/tarpaulin@v0.1 + # toolchain: nightly + toolchain: nightly-2020-03-12 # latest nightly makes `quote` crash with -Zno-landing-pads + override: true + - name: Ensure workspace is clean + uses: actions-rs/cargo@v1 with: - args: '--all --exclude-files abnf_to_pest/* --exclude-files dhall_proc_macros/*' + command: clean + - name: Run tests with -Zprofile + uses: actions-rs/cargo@v1 + with: + command: test + env: + CI_GRCOV: '1' # Tell the test harness to increase stack size + CARGO_INCREMENTAL: '0' + RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads' + - name: Run grcov + id: grcov + uses: actions-rs/grcov@v0.1 - name: Upload coverage data to codecov.io - uses: codecov/codecov-action@v1.0.2 + uses: codecov/codecov-action@v1 with: token: ${{secrets.CODECOV_TOKEN}} + file: ${{steps.grcov.outputs.report}} diff --git a/dhall/build.rs b/dhall/build.rs index fb3f9ee..19abcc4 100644 --- a/dhall/build.rs +++ b/dhall/build.rs @@ -333,7 +333,7 @@ fn generate_tests() -> std::io::Result<()> { || path == "unit/MergeHandlerFreeVar" }), output_type: Some(FileType::UI), - ..default_feature.clone() + ..default_feature }, ]; @@ -450,7 +450,7 @@ fn convert_abnf_to_pest() -> std::io::Result<()> { Ok(()) } -// Generate pest parser manually becaue otherwise we'd need to modify something outside of +// Generate pest parser manually because otherwise we'd need to modify something outside of // OUT_DIR and that's forbidden by docs.rs. fn generate_pest_parser() -> std::io::Result<()> { let out_dir = env::var("OUT_DIR").unwrap(); diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs index d305b98..a5a278c 100644 --- a/dhall/src/tests.rs +++ b/dhall/src/tests.rs @@ -235,9 +235,22 @@ impl TestFile { } #[allow(dead_code)] -fn run_test_stringy_error(test: Test) -> std::result::Result<(), String> { - run_test(test).map_err(|e| e.to_string())?; - Ok(()) +fn run_test_or_panic(test: Test) { + let res = if env::var("CI_GRCOV").is_ok() { + // Augment stack size when running with 0 inlining to avoid overflows + std::thread::Builder::new() + .stack_size(128 * 1024 * 1024) + .spawn(|| run_test(test)) + .unwrap() + .join() + .unwrap() + } else { + run_test(test) + }; + match res { + Ok(_) => {} + Err(e) => panic!(e.to_string()), + } } fn run_test(test: Test) -> Result<()> { @@ -322,10 +335,7 @@ mod spec { fn $name() { use crate::tests::Test::*; use crate::tests::*; - match run_test_stringy_error($type) { - Ok(_) => {} - Err(s) => panic!(s), - } + run_test_or_panic($type); } }; } -- cgit v1.2.3