mirror of
https://github.com/uutils/coreutils
synced 2024-10-15 12:24:09 +00:00
maint/build ~ add show-codecov utils
This commit is contained in:
parent
48dd6a2c81
commit
3e93e7c224
43
util/show-codecov.BAT
Normal file
43
util/show-codecov.BAT
Normal file
|
@ -0,0 +1,43 @@
|
|||
@setLocal
|
||||
@echo off
|
||||
|
||||
@rem ::# spell-checker:ignore (abbrevs/acronyms) gcno
|
||||
@rem ::# spell-checker:ignore (CMD) COMSPEC ERRORLEVEL
|
||||
@rem ::# spell-checker:ignore (jargon) toolchain
|
||||
@rem ::# spell-checker:ignore (rust) Ccodegen Cinline Coverflow RUSTC RUSTFLAGS RUSTUP
|
||||
@rem ::# spell-checker:ignore (utils) genhtml grcov lcov sccache uutils
|
||||
|
||||
set BIN=uutils
|
||||
|
||||
set "FEATURES_OPTION=--features windows"
|
||||
|
||||
cd "%~dp0.."
|
||||
call echo [ "%CD%" ]
|
||||
|
||||
call cargo clean
|
||||
|
||||
set CARGO_INCREMENTAL=0
|
||||
set "RUSTC_WRAPPER=" &@REM ## NOTE: RUSTC_WRAPPER=='sccache' breaks code coverage calculations (uu_*.gcno files are not created during build)
|
||||
set "RUSTFLAGS=-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads"
|
||||
set RUSTUP_TOOLCHAIN=nightly-x86_64-pc-windows-gnu
|
||||
call cargo build %FEATURES_OPTION%
|
||||
call cargo test --no-run %FEATURES_OPTION%
|
||||
call cargo test --quiet %FEATURES_OPTION%
|
||||
|
||||
set COVERAGE_REPORT_DIR=target\debug\coverage-win
|
||||
call rm -r "%COVERAGE_REPORT_DIR%" 2>NUL
|
||||
|
||||
set GRCOV_IGNORE_OPTION=--ignore build.rs --ignore "/*" --ignore "[A-Za-z]:/*"
|
||||
@rem ::# * build LCOV coverage file
|
||||
call grcov . --output-type lcov --output-file "%COVERAGE_REPORT_DIR%/../lcov.info" --branch %GRCOV_IGNORE_OPTION%
|
||||
@rem ::# * build HTML
|
||||
@rem ::# -- use `genhtml` if available for display of additional branch coverage information
|
||||
call genhtml --version 2>NUL 1>&2
|
||||
if NOT ERRORLEVEL 1 (
|
||||
call genhtml target/debug/lcov.info --output-directory "%COVERAGE_REPORT_DIR%" --branch-coverage --function-coverage
|
||||
) else (
|
||||
call grcov . --output-type html --output-file "%COVERAGE_REPORT_DIR%" --branch %GRCOV_IGNORE_OPTION%
|
||||
)
|
||||
if ERRORLEVEL 1 goto _undefined_ 2>NUL || @for %%G in ("%COMSPEC%") do @title %%nG & @"%COMSPEC%" /d/c exit %ERRORLEVEL%
|
||||
|
||||
call start "" "%COVERAGE_REPORT_DIR%"\index.html
|
50
util/show-codecov.sh
Normal file
50
util/show-codecov.sh
Normal file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/sh
|
||||
|
||||
# spell-checker:ignore (abbrevs/acronyms) HTML gcno llvm
|
||||
# spell-checker:ignore (jargon) toolchain
|
||||
# spell-checker:ignore (rust) Ccodegen Cinline Coverflow RUSTC RUSTFLAGS RUSTUP
|
||||
# spell-checker:ignore (shell) OSID esac
|
||||
# spell-checker:ignore (utils) genhtml grcov lcov readlink sccache uutils
|
||||
|
||||
BIN=uutils
|
||||
|
||||
FEATURES_OPTION="--features unix"
|
||||
|
||||
cd "$(dirname -- $(readlink -fm -- "$0"/..))"
|
||||
echo "[ \"$PWD\" ]"
|
||||
|
||||
cargo clean
|
||||
|
||||
export CARGO_INCREMENTAL=0
|
||||
export RUSTC_WRAPPER="" ## NOTE: RUSTC_WRAPPER=='sccache' breaks code coverage calculations (uu_*.gcno files are not created during build)
|
||||
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zno-landing-pads"
|
||||
export RUSTUP_TOOLCHAIN=nightly
|
||||
cargo build ${FEATURES_OPTION}
|
||||
cargo test --no-run ${FEATURES_OPTION}
|
||||
cargo test --quiet ${FEATURES_OPTION}
|
||||
|
||||
export COVERAGE_REPORT_DIR="target/debug/coverage-nix"
|
||||
rm -r "${COVERAGE_REPORT_DIR}" 2>/dev/null
|
||||
mkdir -p "${COVERAGE_REPORT_DIR}"
|
||||
|
||||
# GRCOV_IGNORE_OPTION="--ignore build.rs --ignore \"/cargo/*\" --ignore \"/rustc/*\" --ignore \"${HOME}/.cargo/*\" --ignore \"${PWD}/rustc/*\""
|
||||
export GRCOV_IGNORE_OPTION="--ignore build.rs --ignore \"/*\" --ignore \"[A-Za-z]:/*\""
|
||||
## FixME: `grcov . ... ${GRCOV_IGNORE_OPTION}` fails, completely ignoring the contents of ${GRCOV_IGNORE_OPTION}
|
||||
# * build LCOV coverage file
|
||||
## FixME: grcov . --output-type lcov --output-file "${COVERAGE_REPORT_DIR}/../lcov.info" --branch ${GRCOV_IGNORE_OPTION}
|
||||
grcov . --output-type lcov --output-file "${COVERAGE_REPORT_DIR}/../lcov.info" --branch --ignore build.rs --ignore '/*' --ignore '[A-Za-z]:/*'
|
||||
# * build HTML
|
||||
# -- use `genhtml` if available for display of additional branch coverage information
|
||||
genhtml --version 2>/dev/null 1>&2
|
||||
if [ $? -eq 0 ]; then
|
||||
genhtml "${COVERAGE_REPORT_DIR}/../lcov.info" --output-directory "${COVERAGE_REPORT_DIR}" --branch-coverage --function-coverage
|
||||
else
|
||||
## FixME: grcov . --output-type html --output-file "${COVERAGE_REPORT_DIR}" --branch ${GRCOV_IGNORE_OPTION}
|
||||
grcov . --output-type html --output-file "${COVERAGE_REPORT_DIR}" --branch --ignore build.rs --ignore '/*' --ignore '[A-Za-z]:/*'
|
||||
fi
|
||||
if [ $? -ne 0 ]; then exit 1 ; fi
|
||||
|
||||
case ";$OSID_tags;" in
|
||||
*";wsl;"* ) powershell.exe -c "${COVERAGE_REPORT_DIR}"/index.html ;;
|
||||
* ) xdg-open --version >/dev/null 2>&1 && xdg-open "${COVERAGE_REPORT_DIR}"/index.html || echo "report available at '\"${COVERAGE_REPORT_DIR}\"/index.html'" ;;
|
||||
esac ;
|
Loading…
Reference in a new issue