Main Content

polyspace.project.TestConfigurationRef Class

Namespace: polyspace.project

(Python) Manage references from project to external testing and profiling configurations

Since R2026a

Description

This Python® class contains information about an external testing and profiling configuration that is saved in a .pscfg file, referenced by a Polyspace® Platform project. Saving your testing and profiling configurations in .pscfg files and referencing those files from one or more projects enables you to create a modular project structure that improves sharing and version control managed workflows. For more information about project structure, see Modularize Project by Using External Configurations, Test References, and External Stub Files.

To work with external testing and profiling configurations, use this class, which contains the name of the configuration and the path to the .pscfg file, together with the polyspace.project.TestConfiguration class, which contains the testing and profiling configuration.

To work with testing and profiling configurations that are attached to a specific project, see polyspace.project.OwnedTestConfiguration.

Creation

Description

Import Configuration by Reference

testConfigRef = proj.TestConfigurationRefs.add(testConfig, testConfigRefName) adds a reference from the project to the testing and profiling configuration testConfig, which is an existing .pscfg file or a polyspace.project.TestConfiguration object. The Name property of the resulting polyspace.project.TestConfigurationRef object is set to testConfigRefName.

testConfigRef = proj.TestConfigurationRefs.add(testConfigRefObj) adds a reference from the project to an existing polyspace.project.TestConfigurationRef object testConfigRefObj and inherits the configuration name.

testConfigRef = proj.TestConfigurationRefs.add(testConfigRefObj, testConfigRefName) adds a reference from the project to an existing polyspace.project.TestConfigurationRef object testConfigRefObj. Use the testConfigRefName argument to set the Name property of the resulting testConfigRef object.

Convert Configuration

testConfigRef = proj.TestConfigurationRefs.moveAsRef(ownedTestConfigObj,testConfigFile) converts the existing ownedTestConfigObj to a polyspace.project.TestConfigRef object in the same project. After conversion process, the project references the external configuration saved in testConfigFile.pscfg. You can specify testConfigFile as an absolute or relative path, where relative paths are considered relative to the location of the .psprjx project file. The resulting polyspace.project.TestConfigRef object has its Path property set to testConfigFile and its Name property is inherited from the owned testing and profiling configuration.

example

testConfigRef = proj.TestConfigurationRefs.moveAsRef(ownedTestConfigObj,testConfigFile, testConfigRefName) converts the existing ownedTestConfigObj to a polyspace.project.TestConfigRef object in the same project. After conversion the project references the external configuration saved in testConfigFile.pscfg. You can specify testConfigFile as an absolute or relative path, where relative paths are considered relative to the location of the .psprjx project file. The resulting polyspace.project.TestConfigRef object has its Path property set to testConfigFile and its Name property is set by the testConfigRefName argument you provide.

Input Arguments

expand all

Testing and profiling configuration that you want to add a reference to from the project, specified as a polyspace.project.TestConfiguration object or a path to an existing .pscfg file.

Name to assign the referenced testing and profiling configuration, specified as a string. This argument sets the Name property of the polyspace.project.TestConfigurationRef object.

Existing testConfigRefObj that to add a reference to from the project, specified as a polyspace.project.TestConfigurationRef object.

Existing owned testing and profiling configuration to convert to an external configuration and reference from the project, specified as a polyspace.project.OwnedTestConfiguration object.

Relative or absolute path of the .pscfg file to create when converting an existing owned testing and profiling configuration to an external configuration, referenced by the project. Relative paths are considered relative to the location of the .psprjx project file.

Properties

expand all

Name of the referenced external testing and profiling configuration, specified as a string. If you do not specify a Name argument, the name defaults to that of the existing testing and profiling configuration you are adding or converting.

Path to the .pscfg file where the referenced external testing and profiling configuration is saved, specified as a string. All relative paths are considered relative to the location of the .psprjx project file.

Methods

expand all

Examples

collapse all

Modularize your project by converting an owned testing and profiling configuration to an external configuration, referenced by the project. An external configuration is a build, static analysis, or testing and profiling configuration that is saved in a .pscfg file that is referenced by the project.

Create the project, add your source files, and parse the code.

## Import modules
import polyspace.project
import polyspace.test
import os

## Create project
examples_path = os.path.join(polyspace.__install_path__, "polyspace", 
                            "examples", "doc_pstest", "python_api_test_authoring")
proj = polyspace.project.Project("testRefProject.psprjx")

## Add source files and include headers
proj.Code.Files.add(os.path.join(examples_path, "src", "algo.c"))
proj.Code.Files.add(os.path.join(examples_path, "src", "saturate.c"))
proj.IncludePaths.add(os.path.join(examples_path, "src"))

## Save project and parse code
proj.save()
codeInfo = polyspace.project.parseCode(proj)

Convert the existing testing and profiling configuration to an external configuration, referenced by the project using the moveAsRef method.

# Convert the configuration
testConfig = proj.TestConfigurations[0]  
proj.TestConfigurationRefs.moveAsRef(testConfig, "externalTestConfig.pscfg")

When you convert a configuration that is active in a project, Polyspace updates the active configuration accordingly. Check the active testing and profiling configuration for the project, then save and build the project.

proj.ActiveTestConfiguration
proj.save()
status = polyspace.test.build(proj)

Version History

Introduced in R2026a