使用 Python API 实现服务器上的工作流自动化
R2026b使用适用于 Polyspace® 的 Python® API 自动化 CI 的测试工作流,然后将结果上传到 Polyspace Access™ 以进行基于 Web 的审查:
import polyspace.project, polyspace.test
import subprocess
proj = polyspace.project.Project("myproject")
proj.Code.Files.add("src/utils.c")
proj.Tests.Files.add("tests/test.c")
res = polyspace.test.run(proj)
res.save("results/ps_test.pstestr")
subprocess.run(["polyspace-access", "-upload", "results/ps_test.pstestr", "-parent-project", "myproject", <SERVER_AND_LOGIN_INFO>])在开始之前,请确保您的 Python 版本满足与 Polyspace Test Server 结合使用的要求。有关详细信息,请参阅Set Up Python API for Polyspace。
polyspace 包
polyspace.__install_path__ | (Python) Get Polyspace installation folder |
polyspace.ErrorWithLog | (Python) Get error logs from actions on a Polyspace project |
polyspace.project 模块
polyspace.test 模块
主题
- Set Up Python API for Polyspace
Import
polyspacemodules in Python to create and manage Polyspace projects and results. - Python API for Polyspace 快速入门
创建和配置工程、编译和运行测试、生成报告。
- Calculate Code Coverage of C/C++ Code Using Python API for Polyspace
Run code profiling of C/C++ code using Python API for Polyspace.
- Generate Reports of C/C++ Test Results Using Python API for Polyspace
Save Polyspace Test™ results as XML or HTML reports.
- Create Project from Build System Using Python API for Polyspace
Dynamically generate source and build information for a project by tracing your build commands.
- Author Graphical Tests Using Python API for Polyspace
Create test suites and test cases, add assessments, build and run tests.
- Test Functions Containing Complex Data Types Using Python API for Polyspace
Create test suites, test cases, and test steps for functions with complex data types.
- Modularize Existing Project by Using Polyspace Python API
Use Python scripts to modularize existing projects by converting configurations and graphical tests to files referenced by the project.
- Create Project Dynamically by Using Polyspace Python API
Use Python scripts to dynamically generate projects from sources, configurations, and tests.
- Supported Operations on Sequences and Sets in Python API for Polyspace
Supported Python operations on sequence and set collection types in the Python API for Polyspace.