File: coverage.sh

package info (click to toggle)
ujson 5.11.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,148 kB
  • sloc: ansic: 2,789; python: 1,510; cpp: 50; makefile: 43; sh: 12
file content (28 lines) | stat: -rwxr-xr-x 891 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash

# Coverage for ultrajson's C code.
# Usage:
#   CFLAGS="--coverage -O0" python setup.py -q build_ext --inplace -f
#   pytest
#   ./scripts/coverage.sh
# Then inspect the files in the `cov` folder.

# The exact arguments depend on whether we're using LLVM's gcov or GNU's.
unameOut="$(uname -s)"
case "${unameOut}" in
    Linux*)     gcov_options=(--relative-only);;
    Darwin*)    gcov_options=(--color);;
    *)          echo "Unsupported OS ${unameOut}"; exit 1;;
esac

# The actual gcov instructions:
gcov "${gcov_options[@]}" src/ujson/python/**.c -o build/temp.*/src/ujson/python
gcov "${gcov_options[@]}" src/ujson/lib/**.c -o build/temp.*/src/ujson/lib

# gcov dumps everything in the cwd without any option to change this.
# Manually move the .gcov files to a `cov` folder.
mkdir -p cov
rm -rf cov/*
mv ./**.gcov cov || exit 1

echo Written gcov files to ./cov