-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Single vs Multiple coverage.xml files #34
Comments
Hi, Thanks for your questions.
How did you do for generate a single coverage file ? If it's possible I will can modify the plugin to use a single coverage file. |
Generating single coverage.xml workdir=cover
profile="$workdir/cover.out"
mode=count
for pkg in $(glide nv);
do
for subpkg in $(go list "${pkg}");
do
f="$workdir/$(echo "$subpkg" | tr / -).cover"
go test -v -covermode="$mode" -coverprofile="$f" "$subpkg" >> test.out
done
done
set -- "$workdir"/*.cover
if [ ! -f "$1" ]; then
echo "No Test Cases"; exit 0
fi
echo "mode: $mode" >"$profile"
grep -h -v "^mode:" "$workdir"/*.cover >>"$profile"
rm -f test.xml coverage.xml
go2xunit -input test.out -output test.xml
gocov convert "$profile" | gocov-xml > coverage.xml That is how I have it scripted to generate the My alternate approach would be just to write the coverage.xml files into the cover/ directory as I don't like the idea of writing any files to my actual package directories. |
@thibaultfalque I guess that making sure to search first a single cover file in the root directory else look for multiple cover files in subdirectories could do the trick. @kenjones-cisco thanks for the script. Would you agree that we display it in the README page of the script? |
Sure, no problem. |
FYI, to make it not specific to glide, you should can use this: workdir=cover
profile="$workdir/cover.out"
mode=count
for pkg in $(go list ./...);
do
f="$workdir/$(echo "$pkg" | tr / -).cover"
go test -v -covermode="$mode" -coverprofile="$f" "$pkg" >> test.out
done
set -- "$workdir"/*.cover
if [ ! -f "$1" ]; then
rm -f "$results" || :
echo "No Test Cases"; exit 0
fi
echo "mode: $mode" >"$profile"
grep -h -v "^mode:" "$workdir"/*.cover >>"$profile"
rm -f test.xml coverage.xml
go2xunit -input test.out -output test.xml
gocov convert "$profile" | gocov-xml > coverage.xml |
@thibaultfalque are we done here? |
See the PR by @kernle32dll #50 |
For a bit more context what Also also - Golang 1.10 will bring support for |
Thanks @kernle32dll for your explanation |
Description
In the README I noticed the following section:
Currently I'm able to generate a single coverage.xml file for an entire project with multiple packages within the same project. And cobertura within Jenkins is able to read and process the file and show all of the packages.
Example single coverage.xml:
Is there a technical limitation within SonarQube that requires the coverage to be done as one coverage.xml per package? Or is this rule imposed by the plugin?
As a follow up, does the coverage.xml have to be in the same directory as the code? Or is it possible to leverage a
cover
directory that has a directory for each package and the coverage.xml file exists within that directory?Example Directory structure for coverage:
The text was updated successfully, but these errors were encountered: