Main Content

polyspace.test.run

(Python) Run test executable for specified project

Since R2024a

Description

testResults=polyspace.test.run(proj) runs a test executable generated from the tests and build configuration of the project proj.

  • If the test executable does not exist, Polyspace builds the executable and then runs it.

  • If an error occurs during the test build, the function throws an exception of type polyspace.ErrorWithLog. (since R2026a)

testResults=polyspace.test.run(proj, otherOptions) runs a test executable generated from the tests and build configuration of the project proj. You can optionally overwrite some of the default project options.

Input Arguments

expand all

Name of the polyspace.project.Project object that contains the code and tests that you are building.

Example: myProject=polyspace.project.Project(newProj.psprjx)

Enable debugger, specify new build directory, overwrite current profiling selection.

ParameterDescription
EnableDebugger=True | False

Inspect the test executable generated by Polyspace Test using the Visual Studio® (Windows®), DDD (Linux®), or LLDB (macOS) debugger. The debugger is attached to the specified process and adds breakpoints in selected tests.

By default, the debugger is disabled.

ForceRebuild=True | False

Force a full build of the source files instead of an incremental build.

This parameter is set to False by default. As a result, a project build takes into account previous build information and rebuilds only those sources that changed since the previous build. Some changes in project configuration such as changes in processor information might not trigger a rebuild at all. To force a build of all sources, set this parameter to True.

BuildFolder=folderPath

Specify the path folderPath where Polyspace® stores the build artifacts. You can specify the absolute path or the path relative to your working directory.

By default, Polyspace stores the build artifacts in the project artifacts folder, specified using the configuration option Artifacts directory.

ProfilingSelection=polyspace.test.ProfilingSelection Object

Specify the profiling mode to use instead of the profiling mode specified in the active test configuration of the project. The values of this option are:

  • polyspace.test.ProfilingSelection.NONE(default) — Calculate none of the code profile metrics.

  • polyspace.test.ProfilingSelection.COVERAGE — Calculate the code coverage metrics. You can select which code coverage metrics to calculate by using the option proj.ActiveTestConfiguration.CoverageOptions object.

  • polyspace.test.ProfilingSelection.EXECUTION — Calculate how much time the callable entities in your code take to execute.

  • polyspace.test.ProfilingSelection.STACK — Calculate stack memory usage of the callable entities.

    Polyspace Test™ does not support calculating the memory use of external tests.

  • polyspace.test.ProfilingSelection.SANITIZER – Calculate code sanitizer profiling results.

Test=["SuitName1/TestName1", ...,SuiteNameN/TestNameN

Specify the test framework and name of suites, tests, and parameters that Polyspace runs. Use this option to run tests from only one test framework (Polyspace Test or external test framework) and to filter for a subset of tests within a test framework.

See also polyspace-test -run.

Example: singleTestRes = polyspace.test.run(myProject,EnableDebugger=True, BuildFolder="/usr/local/customBuild",Test=["mySuite/oneTest"])

Output Arguments

expand all

Polyspace returns a polyspace.test.TestResults object. You can save the results as a .pstestr file or generate reports. See also polyspace.test.TestResults.

Version History

Introduced in R2024a

expand all