Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stefan Schindler
weighted_random_list
Commits
145911da
Commit
145911da
authored
Apr 17, 2019
by
Stefan Schindler
Browse files
Add Coverage with kcov
parent
55e2b533
Pipeline
#188
passed with stage
in 2 minutes and 48 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
145911da
...
...
@@ -10,6 +10,10 @@ image: "rust:latest"
# - redis:latest
# - postgres:latest
variables
:
KCOV_DISCARD_CACHE
:
"
false"
APT_CACHE_DIR
:
apt-cache
# Optional: Install a C compiler, cmake and git into the container.
# You will often need this when you (or any of your dependencies) depends on C code.
#before_script:
...
...
@@ -17,7 +21,26 @@ image: "rust:latest"
#- apt-get install -yqq --no-install-recommends build-essential
# Use cargo to test the project
# And kcov to analyze the coverage:
# https://grauwoelfchen.at/posts/get-test-coverage-for-software-written-in-rust-using-kcov/
test:cargo:
before_script
:
-
mkdir -pv $APT_CACHE_DIR && apt-get -qq update && apt-get -qqy upgrade
-
apt-get -qq -o dir::cache::archives="$APT_CACHE_DIR" install -y
binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev
cmake
-
./ci/build-kcov
-
./kcov/bin/kcov --version
-
rustc --version && cargo --version
# Print version info for debugging
script
:
-
rustc --version && cargo --version
# Print version info for debugging
-
cargo test --all
after_script
:
-
rm -f target/debug/weighted_random_list-*.d
-
./kcov/bin/kcov --include-path ./src ./target/cov target/debug/weighted_random_list-*
-
COVERAGE=$(grep -Po 'covered":.*?[^\\]"' target/cov/index.js* | grep "[0-9]*\.[0-9]" -o)
-
echo "Coverage:" $COVERAGE
cache
:
untracked
:
true
paths
:
-
apt-cache
-
kcov
README.md
View file @
145911da
# weighted_random_list
[

](https://gitlab.com/dns2utf8/weighted_random_list)
[

](https://gitlab.com/dns2utf8/weighted_random_list/commits/master)
A Vec
<T>
that allows you to define the weight of each entry and randomly get entries:
...
...
ci/build-kcov
0 → 100755
View file @
145911da
#!/bin/bash
set
-eu
# NOTE:
# if set KCOV_DISCARD_CACHE=true, then it will force installing kcov)
renew
=
"
${
KCOV_DISCARD_CACHE
:-
false
}
"
kcov_dir
=
"kcov"
kcov_bin
=
"
${
kcov_dir
}
/bin/kcov"
kcov_url
=
"https://github.com/SimonKagstrom/kcov/archive"
kcov_ver
=
"v34"
if
[[
-f
"
${
kcov_bin
}
"
&&
"
${
renew
}
"
!=
"true"
]]
;
then
echo
"kcov already installed in
${
kcov_bin
}
"
else
rm
-fr
$kcov_dir
mkdir
$kcov_dir
cd
$kcov_dir
curl
-sLO
${
kcov_url
}
/
${
kcov_ver
}
.tar.gz
mkdir
$kcov_ver
tar
zxvf
${
kcov_ver
}
.tar.gz
-C
$kcov_ver
--strip-components
=
1
cd
$kcov_ver
mkdir
build
cmake
\
-DCMAKE_BUILD_TYPE
=
Release
\
-DCMAKE_INSTALL_PREFIX
=
/
make
make
install
DESTDIR
=
../
fi
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment