Use kcov from official Ubuntu 20.04 repository (#25385)

* Ubuntu 20.04 provides kcov, so don't build from source

* Use two undocumented options for kcov v3.8
This commit is contained in:
Massimiliano Culpo 2021-08-19 23:03:10 +02:00 committed by GitHub
parent 350372e3bf
commit 10695f1ed3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 50 deletions

View file

@ -131,10 +131,7 @@ jobs:
# Needed for unit tests # Needed for unit tests
sudo apt-get -y install \ sudo apt-get -y install \
coreutils cvs gfortran graphviz gnupg2 mercurial ninja-build \ coreutils cvs gfortran graphviz gnupg2 mercurial ninja-build \
patchelf patchelf cmake bison libbison-dev kcov
# Needed for kcov
sudo apt-get -y install cmake binutils-dev libcurl4-openssl-dev
sudo apt-get -y install zlib1g-dev libdw-dev libiberty-dev
- name: Install Python packages - name: Install Python packages
run: | run: |
pip install --upgrade pip six setuptools codecov coverage[toml] pip install --upgrade pip six setuptools codecov coverage[toml]
@ -148,17 +145,6 @@ jobs:
# Need this for the git tests to succeed. # Need this for the git tests to succeed.
git --version git --version
. .github/workflows/setup_git.sh . .github/workflows/setup_git.sh
- name: Install kcov for bash script coverage
if: ${{ needs.changes.outputs.with_coverage == 'true' }}
env:
KCOV_VERSION: 34
run: |
KCOV_ROOT=$(mktemp -d)
wget --output-document=${KCOV_ROOT}/${KCOV_VERSION}.tar.gz https://github.com/SimonKagstrom/kcov/archive/v${KCOV_VERSION}.tar.gz
tar -C ${KCOV_ROOT} -xzvf ${KCOV_ROOT}/${KCOV_VERSION}.tar.gz
mkdir -p ${KCOV_ROOT}/build
cd ${KCOV_ROOT}/build && cmake -Wno-dev ${KCOV_ROOT}/kcov-${KCOV_VERSION} && cd -
make -C ${KCOV_ROOT}/build && sudo make -C ${KCOV_ROOT}/build install
- name: Bootstrap clingo - name: Bootstrap clingo
if: ${{ matrix.concretizer == 'clingo' }} if: ${{ matrix.concretizer == 'clingo' }}
env: env:
@ -204,10 +190,7 @@ jobs:
run: | run: |
sudo apt-get -y update sudo apt-get -y update
# Needed for shell tests # Needed for shell tests
sudo apt-get install -y coreutils csh zsh tcsh fish dash bash sudo apt-get install -y coreutils kcov csh zsh tcsh fish dash bash
# Needed for kcov
sudo apt-get -y install cmake binutils-dev libcurl4-openssl-dev
sudo apt-get -y install zlib1g-dev libdw-dev libiberty-dev
- name: Install Python packages - name: Install Python packages
run: | run: |
pip install --upgrade pip six setuptools codecov coverage[toml] pip install --upgrade pip six setuptools codecov coverage[toml]
@ -216,17 +199,6 @@ jobs:
# Need this for the git tests to succeed. # Need this for the git tests to succeed.
git --version git --version
. .github/workflows/setup_git.sh . .github/workflows/setup_git.sh
- name: Install kcov for bash script coverage
if: ${{ needs.changes.outputs.with_coverage == 'true' }}
env:
KCOV_VERSION: 38
run: |
KCOV_ROOT=$(mktemp -d)
wget --output-document=${KCOV_ROOT}/${KCOV_VERSION}.tar.gz https://github.com/SimonKagstrom/kcov/archive/v${KCOV_VERSION}.tar.gz
tar -C ${KCOV_ROOT} -xzvf ${KCOV_ROOT}/${KCOV_VERSION}.tar.gz
mkdir -p ${KCOV_ROOT}/build
cd ${KCOV_ROOT}/build && cmake -Wno-dev ${KCOV_ROOT}/kcov-${KCOV_VERSION} && cd -
make -C ${KCOV_ROOT}/build && sudo make -C ${KCOV_ROOT}/build install
- name: Run shell tests (without coverage) - name: Run shell tests (without coverage)
if: ${{ needs.changes.outputs.with_coverage == 'false' }} if: ${{ needs.changes.outputs.with_coverage == 'false' }}
run: | run: |
@ -314,21 +286,7 @@ jobs:
# Needed for unit tests # Needed for unit tests
sudo apt-get -y install \ sudo apt-get -y install \
coreutils cvs gfortran graphviz gnupg2 mercurial ninja-build \ coreutils cvs gfortran graphviz gnupg2 mercurial ninja-build \
patchelf patchelf kcov
# Needed for kcov
sudo apt-get -y install cmake binutils-dev libcurl4-openssl-dev
sudo apt-get -y install zlib1g-dev libdw-dev libiberty-dev
- name: Install kcov for bash script coverage
if: ${{ needs.changes.outputs.with_coverage == 'true' }}
env:
KCOV_VERSION: 34
run: |
KCOV_ROOT=$(mktemp -d)
wget --output-document=${KCOV_ROOT}/${KCOV_VERSION}.tar.gz https://github.com/SimonKagstrom/kcov/archive/v${KCOV_VERSION}.tar.gz
tar -C ${KCOV_ROOT} -xzvf ${KCOV_ROOT}/${KCOV_VERSION}.tar.gz
mkdir -p ${KCOV_ROOT}/build
cd ${KCOV_ROOT}/build && cmake -Wno-dev ${KCOV_ROOT}/kcov-${KCOV_VERSION} && cd -
make -C ${KCOV_ROOT}/build && sudo make -C ${KCOV_ROOT}/build install
- name: Install Python packages - name: Install Python packages
run: | run: |
pip install --upgrade pip six setuptools codecov coverage[toml] clingo pip install --upgrade pip six setuptools codecov coverage[toml] clingo

View file

@ -9,4 +9,7 @@ if [ -z "$SPACK_ROOT" ]; then
exit 1 exit 1
fi fi
kcov "$SPACK_ROOT/coverage" "$@" # Using a -- to separate the script to be tested from kcov is not documented
# as of v38, but seems to work. The same is true for the "--debug-force-bash-stderr"
# option, see https://github.com/SimonKagstrom/kcov/issues/61
kcov --debug-force-bash-stderr "$SPACK_ROOT/coverage" -- "$@"

View file

@ -38,8 +38,8 @@ cd "$SPACK_ROOT"
# Run bash tests with coverage enabled, but pipe output to /dev/null # Run bash tests with coverage enabled, but pipe output to /dev/null
# because it seems that kcov seems to undo the script's redirection # because it seems that kcov seems to undo the script's redirection
if [ "$COVERAGE" = true ]; then if [ "$COVERAGE" = true ]; then
"$QA_DIR/bashcov" "$QA_DIR/setup-env-test.sh" &> /dev/null kcov "$SPACK_ROOT/coverage" "$QA_DIR/setup-env-test.sh" &> /dev/null
"$QA_DIR/bashcov" "$QA_DIR/completion-test.sh" &> /dev/null kcov "$SPACK_ROOT/coverage" "$QA_DIR/completion-test.sh" &> /dev/null
else else
bash "$QA_DIR/setup-env-test.sh" bash "$QA_DIR/setup-env-test.sh"
bash "$QA_DIR/completion-test.sh" bash "$QA_DIR/completion-test.sh"

View file

@ -31,10 +31,10 @@ if [[ "$COVERAGE" == "true" ]]; then
bashcov=$(realpath ${QA_DIR}/bashcov) bashcov=$(realpath ${QA_DIR}/bashcov)
# instrument scripts requiring shell coverage # instrument scripts requiring shell coverage
sed -i~ "s@#\!/bin/bash@#\!${bashcov}@" "$SPACK_ROOT/lib/spack/env/cc" sed -i "s@#\!/bin/bash@#\!${bashcov}@" "$SPACK_ROOT/lib/spack/env/cc"
if [ "$(uname -o)" != "Darwin" ]; then if [ "$(uname -o)" != "Darwin" ]; then
# On darwin, #! interpreters must be binaries, so no sbang for bashcov # On darwin, #! interpreters must be binaries, so no sbang for bashcov
sed -i~ "s@#\!/bin/sh@#\!${bashcov}@" "$SPACK_ROOT/bin/sbang" sed -i "s@#\!/bin/sh@#\!${bashcov}@" "$SPACK_ROOT/bin/sbang"
fi fi
fi fi