This topic explains how to configure the scope of analysis.
Modifying the Scope for a Test Configuration
By default, C/C++test analyzes the resources selected when the test configuration runs, but you can configure a narrower scope using the scope options available on the test configuration's Scope tab. See Scope Tab Settings: Defining What Code is Tested.
Modifying the Scope on the Project Level
You can configure the scope on the project level by excluding resources in the GUI (see Excluding Project Resources from Testing) or by using the -resource
, -exclude
, or -include
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 checking the code into your source control system or merging 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.scontrol.files.filter.mode=local cpptest.scope.adjuster.cu.enabled=true
// This configuration narrows down the scope of analysis to files (including header files) // on the current working branch that differ from the main stream of development: scope.scontrol.files.filter.mode=branch cpptest.scope.adjuster.cu.enabled=true
// This configuration narrows down the scope of analysis to files (including header files) // on the current working branch that differ from branch "feature_372": scope.scontrol.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 on the current working branch that differ from 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. |