Test Tasks and Queries
With the CI/CD Automation for Simulink Check support package, you can define a development and verification process by adding tasks to a process model and using queries to find relevant artifacts like models, requirements, and test cases. If you are trying to debug or test a task or query, it can be helpful to run the task or query directly from the MATLAB® Command Window. To test a task, you can find the ID for a specific task iteration and use the runprocess
function to run that task iteration. To test a query, you can create an instance of the query and use the run
method to get the artifacts that the query returned.
This example shows how to test a built-in query and then use the artifacts that the query returns to test a built-in task. For more information on built-in tasks and queries, see the Built-In Tasks and Built-In Queries. To evaluate the task inputs and outputs defined by your process model, you can dry run tasks as shown in Dry Run Tasks to Test Process Model.
Open Project
Open a project. For this example, you can open the Process Advisor example project.
processAdvisorExampleStart
Find Artifacts Using Query
Suppose that you want to test the built-in query padv.builtin.query.FindModels
.
In the MATLAB Command Window, create an instance of the query.
q = padv.builtin.query.FindModels;
To see which artifacts the query returns, run the query by using the
run
method.artifacts = run(q)
In this example, the query returns the five models in the example project. If you open theartifacts = 1×5 Artifact array with properties: Type Parent ArtifactAddress Alias
Alias
property, you can see the names of each of the models returned by thepadv.builtin.query.FindModels
query.artifacts.Alias
To filter the artifacts returned by the query, you can modify the behavior of the query using the name-value arguments. For example, to exclude artifacts that contain
Control
in the file path, you would specify:q = padv.builtin.query.FindModels(ExcludePath = "Control");
Re-run the query to see the updated query results.
artifacts = run(q)
For this example, the query returns a single Simulink® model,artifacts = Artifact with properties: Type: "sl_model_file" Parent: [0×0 padv.Artifact] ArtifactAddress: [1×1 padv.util.ArtifactAddress] Alias: "AHRS_Voter.slx"
AHRS_Voter.slx
, sinceAHRS_Voter.slx
is the only model that does not containControl
in its file path.artifacts.ArtifactAddress
If the artifact is in a referenced project, theans = ArtifactAddress FileAddress: "02_Models/AHRS_Voter/specification/AHRS_Voter.slx" OwningProject: "ProcessAdvisorExample" IsSubFileArtifact: 0
OwningProject
returns the name of the referenced project. If you need to know which project contains an artifact, you can use thegetOwningProject
function on the artifact address object. For more information, seepadv.util.ArtifactAddress
.
Run Task for Specific Artifacts
Suppose that you want to run the task padv.builtin.task.GenerateSimulinkWebView
on the AHRS_Voter
model returned by a query.
You can run a specific task iteration by specifying the Tasks
and FilterArtifact
name-value arguments for the runprocess
function.
runprocess(... Tasks = "padv.builtin.task.GenerateSimulinkWebView",... FilterArtifact = artifacts(1))
You can use the other name-value arguments of runprocess
to specify how the task iteration runs. For example, Force = true
forces the task iteration to run, even if the results are already up-to-date and Isolation = true
has the task iteration run without running its dependencies.
runprocess(... Tasks = "padv.builtin.task.GenerateSimulinkWebView",... FilterArtifact = artifacts(1),... Force = true,... Isolation = true)
runprocess
.See Also
padv.Task
| padv.Query
| runprocess