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 by adding tasks to a process model and using 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. A dry run can help you test your process model by validating task inputs and generating representative task outputs without actually running the tasks. Dry runs can be helpful for quickly testing your process model and CI pipelines to help make sure they are set up as expected.
Dry Run Tasks
In the Process Advisor app, you can:
Dry run a specific task by pointing to the task, opening the options menu (...), and then clicking Dry Run Task.
Dry run each task 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. This allows you to:
Dry run a specific task by pointing to the task and clicking the dry run button .
Dry run each task in the process by clicking Dry Run All directly in the Process Advisor toolstrip.
The Set Dry Run as Default option is stored
in the DryRunDefaultMode
property in the user settings and
only applies 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. When you
programmatically perform a dry run, you can also specify whether the dry run
automatically checks out the licenses associated with the tasks, you can specify
the DryRunLicenseCheckout
. For CI systems, dry runs can
help you make sure that you have the correct 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, the 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 re-run the task, the build system automatically skips re-running 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 re-run the task. To clean the results for a specific task, you can 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 tasksSpecifying the task property
DryRunAction
for function-based tasksChanging the default dry run results for tasks in your process model by modifying the
DefaultDryRunResults
property forpadv.ProcessModel
. If a task does not have a dry run functionality defined, the task returns these default dry run results.
Override dryRun
Method
To override the 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
, in the methods, you can add a
dryRun
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 a 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, to have the default dry run results be failing task results with
specific result values in the Details column, in your
process model you can 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