Generating instrumentations without modifying projects

Coco can also generate code coverage information for a project without the need to modify it. The principle is to prepend to the PATH variable the path of the CoverageScanner compiler wrappers and to set the instrumentation parameters with the COVERAGESCANNER_ARGS environment variable. To activate the instrumentation, --cs-on must be present in COVERAGESCANNER_ARGS. If this is not the case, CoverageScanner is completely deactivated.

Note: The variable COVERAGESCANNER_ARGS should only be set locally, e.g. in a script or on the command line. If it is set globally, it will influence every build.

GNU Make

On a UNIX® system, proceed as follows to instrument a project which can be generated using GNU Make:

export PATH=/opt/SquishCoco/wrapper/bin:$PATH
export COVERAGESCANNER_ARGS=--cs-on
make clean
make

For macOS, replace the first line with:

export PATH=/opt/SquishCoco/wrapper:$PATH

Microsoft NMake

To instrument a project that is generated with NMake:

set PATH=%SQUISHCOCO%\visualstudio;%PATH%
set COVERAGESCANNER_ARGS=--cs-on
nmake clean
nmake

Microsoft Visual Studio

To instrument a project that is generated with Microsoft® Visual Studio®:

set PATH=%SQUISHCOCO%\visualstudio;%PATH%
set COVERAGESCANNER_ARGS=--cs-on
devenv /useenv myproject.sln /Rebuild

Microsoft MSBuild

To instrument a project that is generated with MSBuild:

set PATH=%SQUISHCOCO%\visualstudio;%PATH%
set COVERAGESCANNER_ARGS=--cs-on
msbuild /p:UseEnv=true myproject.sln /t:ReBuild

Mono C# XBuild

To instrument a project that is generated with Mono C# XBuild:

export COVERAGESCANNER_ARGS=--cs-on
msbuild \
   /p:UseEnv=true \
   /p:UseHostCompilerIfAvailable=true \
   /p:CscToolPath="${SQUISHCOCO}/wrapper" \
   myproject.sln /t:ReBuild

The environment variable SQUISHCOCO contains the path to the CoverageScanner executable.