Dry Run Tasks to Test Process Model
With the CI/CD Automation for Simulink Check support package, you can define a development and verification process model. Add tasks to the process model and use queries to find relevant artifacts like models, requirements, and test cases. As you set up your process model, you can quickly test your process model by performing dry runs. In a dry run, you make sure that your process model is set up as expected by validating task inputs and generating representative task outputs without actually running the tasks.
Dry Run Tasks
In the Process Advisor app, you can:
Perform a dry run for a specific task by pointing to the task, opening the options menu (...), and then clicking Dry Run Task.
Perform a dry runs for all tasks in the process by clicking Run All > Dry Run All in the toolstrip.
By default, these dry run buttons appear in the options menu and toolstrip. But if you frequently use dry runs, you can set dry runs as the default task execution mode by clicking Run All > Set Dry Run as Default. When you do so, you can:
Perform a dry run for a specific task by pointing to the task and clicking the dry run button
.
Perform a dry runs for all tasks in the process by clicking Dry Run All in the Process Advisor toolstrip.
The Set Dry Run as Default option is stored in
the DryRunDefaultMode
property in the user settings and applies
only to the current MATLAB® session. For more information, see padv.UserSettings
.
Alternatively, you can dry run tasks programmatically by using the
runprocess
function. Use the DryRun
argument to perform a dry run. Use the DryRunLicenseCheckout
argument to specify whether the dry run automatically checks out the licenses
associated with the tasks. For CI systems, dry runs can help you make sure that you
have the setup and required licenses available on your CI agent and that your
pipeline appears as expected. For more information, see runprocess
and Tips for Setting Up CI Agents.
Dry Run Results
When you dry run a task, the task can validate task inputs and generate representative task
outputs. In the Process Advisor app, dry run results have a beaker icon
next to the task status. For example, a passing
dry run result shows the passing icon with the beaker icon
. If you point to the task results in the
I/O column, you can see the inputs, placeholder outputs,
and dependencies for the task. The results from the dry run are placeholders and are
not valid results. Do not use dry run results for anything other than testing your
process model and its file management.
When you point to the status icon next to a task, a pop-up shows details like the task name, status, and duration. If the task was a dry run, the status includes (Dry Run).
Note that Process Advisor and the build system treat the dry run results as normal task run results. If a task has up to date dry run results and you rerun the task, the build system automatically skips rerunning the task because the dry run results are already up-to-date. If you dry run a task and then want to perform a normal run of the task, you need to clean the task results before trying to rerun the task. To clean the results for a specific task, point to that task, open the options menu (...), and click Clear results and delete outputs.
Specify Dry Run Functionality for Tasks
Each built-in task has a specialized dryRun
method to help you evaluate the setup of task inputs and outputs for that task in the process model. For custom tasks, you can either inherit the default dry run behavior or create specialized dry run functionality for your task. Optionally, you can change how your tasks perform dry runs by:
Overriding the
dryRun
method for class-based tasks.Specifying the task property
DryRunAction
for function-based tasks.Changing the default dry run results for tasks in your process model by modifying the
DefaultDryRunResults
property forpadv.ProcessModel
. If you do not define a dry run functionality for a task, the task returns these default dry run results.
Override dryRun
Method
To define a different dry-run functionality for a class-based custom task, you can override
the dryRun
method. You can use the dryRun
method to define validation criteria for your task iterations, inputs, and
outputs. Inside the classdef
block, in the methods,
you can add a ClassName
...enddryRun
function that can perform your custom
dry run functionality. In general, the dryRun
method should use
the following method
signature:
function taskResult = dryRun(obj,input) ... end
For example, the following code defines a dry-run method that takes the current iteration
artifact and checks if the artifact is a model
(sl_model_file
). If the artifact is a model, then the dry run
generates placeholder output text files for the task. Otherwise, the task
returns a failing task
status.
function taskResult = dryRun(obj,input) taskResult = padv.TaskResult; iterationArtifact = input{1}; if ismember('sl_model_file',iterationArtifact.Type) % If input is model, output text file with same name as model modelName = iterationArtifact.Alias; taskResult.OutputPaths = fullfile(obj.resolvePath(obj.OutputDirectory), ... modelName+".txt"); else taskResult.Status = padv.TaskStatus.Fail; disp('Invalid input. Expected SLX model file.') end end
Change Default Dry-Run Results
By default, if a task does not have dry-run functionality defined, the task
returns the default dry run results specified by the
padv.ProcessModel
property
DefaultDryRunResults
. You can create a different set of
default dry run results by creating and using a padv.TaskResult
object with different property values. For
example, use failing task results with specific result values in the
Details column. To do so, create a
padv.TaskResult
object and update the value of the
DefaultDryRunResults
property.
res = padv.TaskResult; res.Status = padv.TaskStatus.Fail; res.Values = struct( ... "Pass",1, ... "Warn",2, ... "Fail",3); pm.DefaultDryRunResults = res;
See Also
padv.ProcessModel
| padv.Task
| padv.TaskResult