Reputation: 213
I need help for the following task: I want to measure the test coverage of an Mono Assembly. For this I want to use MonoCov. Unfortunately, my knowledge is not good enough to build the Tool on a Mac. Even this article couldn't help me. Is there someone out there who has managed to build monocov on a mac and use it to measure the test coverage??
Upvotes: 0
Views: 604
Reputation: 74144
Well, it appears that Xamarin has removed the 'internal' cov profiler and monocov will not produce any output (besides mono actually loading the shared library, no functions are called) as the api has changed.
They have added a code coverage filter (Apr 7 2015) to the core log profilers and while I could not find any published documentation(?). It is easy enough to enable.
--profile=log:coverage
coverage enable collection of code coverage data
covfilter=ASSEMBLY add an assembly to the code coverage filters
add a + to include the assembly or a - to exclude it
filter=-mscorlib
covfilter-file=FILE use FILE to generate the list of assemblies to be filtered
Git log info on cov removal and log coverage filter addition:
commit 16570265149730ec6a4760cc0fa34decc1a9d981
Author: Alex Rønne Petersen <[email protected]>
Date: Tue Apr 7 14:51:27 2015 +0200
[profiler] Remove old mono-cov profiler.
We're replacing this with coverage support in the log profiler.
commit e91693fbb87f687a2fdb5a495c945c1872b3066c
Author: iain holmes <[email protected]>
Date: Fri Feb 27 10:13:54 2015 +0000
[cov] Install a coverage filter
If you are still using Mono 3.x, then my original reply would work:
This is some old code...
Here are the steps to get MonoCov compiled if you have Mono 4.0.x installed. The gui works fine, not sure if the actual profiler (the shared profiling library) is working.
# Clone the MonoCov repo
git clone https://github.com/mono/monocov.git MonoCov
cd MonoCov
# A really old version of cecil and it not available as a nuget
curl http://go-mono.com/archive/cecil/cecil-0.6-bin.zip -o cecil-0.6-bin.zip
unzip cecil-0.6-bin.zip
# Make sure configure can find the Mono.Option source file
export PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/4.0.1/lib:/Library/Frameworks/Mono.framework/Versions/4.0.1/lib/pkgconfig:$PKG_CONFIG_PATH
# Config to install to users home dir
/configure --cecil=$PWD/monocov/cecil-0.6/Mono.Cecil.dll --prefix=$HOME/monocov
# Fix Makefile, gmcs no longer exists under Mono 4.x and Makefile is hard coded
sed -i.bak s/gmcs/mcs/g Makefile
# Pass -m32 to make since OS-X Mono framework is still 32-bit
CC="cc -m32" make
# Install does not properly create bin dir, do it before the first install
mkdir $HOME/monocov/bin
# Install..
make install
# Update your path
Run the gui
# GUI Framework DllNotFoundException fix (if needed)
export DYLD_FALLBACK_LIBRARY_PATH="/Library/Frameworks/Mono.framework/Versions/Current/li b:/usr/local/lib:/usr/lib"
# Update path to include MonoCov
export PATH=$HOME/monconv/bin:$PATH
monocov &
Of course you would need to create a MonoCov 'cov' file via using the profile to load into it...
Upvotes: 3