This topic explains how to configure the scope of analysis.
Modifying the Scope
By default, C/C++test analyzes all the resources that are selected when a test configuration is run. You can configure your test configuration to narrow down the default scope by specifying the scope options available on the Scope tab. See Scope Tab Settings: Defining What Code is Tested.
In addition, you can configure the scope on the project level (see Excluding Project Resources from Testing) or by using the -resource
, - exclude
, or - includ
e options when running analysis in the command line (see Testing from the Command Line Interface).
Defining File Filters Based on Source Control Data
You can restrict the scope of analysis to locally modified files or to files modified on the current working branch by setting up file filters based on source control data. This allows you to focus on identifying and fixing bugs introduced by your recent code changes before the code is checked in your source control system or merged with the main development stream.
You can define file filters:
- In the GUI of a selected test configuration–see Scope Tab Settings: Defining What Code is Tested.
- By specifying advanced scope settings–see Configuring File Filters with Advanced Settings. The settings will apply to all test configurations and overwrite the scope options specified in a test configuration.
Before you configure file filters, ensure that connection to a supported source control system is properly configured.
Configuring File Filters with Advanced Settings
To configure file filters:
Create an advanced settings file that includes C/C++test's advanced scope settings. See Advanced Scope Settings for a complete list of available settings. The contents of the advanced settings file may resemble the following:
// This configuration narrows down the scope of analysis to locally modified files // (including header files). scope.scontol.files.filter.mode=local cpptest.scope.adjuster.cu.enabled=true
// This configuration narrows down the scope of analysis to files (including header files) // that are different between the current working branch and the main stream of development. scope.scontol.files.filter.mode=branch cpptest.scope.adjuster.cu.enabled=true
// This configuration narrows down the scope of analysis to files (including header files) // that are different between the current working branch and branch "feature_372": scope.scontol.files.filter.mode=branch scope.scontrol.ref.branch=feature_372 cpptest.scope.adjuster.cu.enabled=true
- Specify the path to the advanced settings. See Configuring an Advanced Settings File for details.
Advanced scope settings configured in the settings file apply to all test configurations and overwrite the scope options specified in a test configuration.
Advanced Scope Settings
Setting | Description |
---|---|
scope.scontrol.files.filter.mode=local | Checks only locally modified files. |
scope.scontrol.files.filter.mode=branch | Checks only files that are different between the current working branch and the reference branch. By default, the reference branch is the main integration stream, such as "master", "trunk", etc. You can specify a custom branch with scope.scontrol.ref.branch . |
scope.scontrol.ref.branch=[branch or revision] | Specifies the name or ID of the branch or revision with which the current working branch is compared to identify and analyze modified files. It applies when the scope.scontrol.files.filter.mode option is set to branch . |
cpptest.scope.adjuster.cu.enabled=true | Enables checking all files that belong to the same compilation unit as the file that has been modified. This applies to both source files and header files. C/C++test cannot analyze header files directly. This option allows you to ensure that modified header files are analyzed, even if the source files that include them remain unchanged. |