This example shows how to use the Simulink Project dependency analysis tools to perform file-level impact analysis. Starting with an existing project that is already checked into source control, this example shows how to determine which files are impacted by modifications to the project. This workflow can help you find and run the tests needed to validate a change to your design.
|On this page…|
1. Run the following commands to create and open a working copy of the "sldemo_slproject_airframe" example.
Creating sandbox for project. Adding files to source control. Created temporary Simulink Project example files in "/tmp/R2014ad_357_3462/20140117T184821/airframe" Building with 'gcc'. MEX completed successfully.
The project example copies files to your temporary folder so that you can edit them and put them under local version control.
The Simulink Project Tool opens and loads the project already under version control.
Run a dependency analysis on the files in your project.
2. Click the Dependency Analysis node.
3. Click the Analyze button.
4. Select the Impact node to view the dependency graph.
The dependency graph displays the structure of your project. Each box in the graph represents a file, and each arrow is a dependency.
5. Make a modification to vertical_channel.slx and save the model. This can be a trivial modification such as moving a block.
The project can determine the source control status of each file. You can display this information in the dependency graph by changing the file highlighting.
6. Right-click the graph and select Highlight Files > Modifications.
The color of each file in the graph now represents its source control status. The status that each color represents is shown in the Modifications legend in the top left of the view. For vertical_channel.slx the source control status is Modified, because you made a change to the file.
You can use the Impact Analysis tool in the bottom left of the dependency graph to analyze the graph to find impacted and required files. You choose the files to analyze, and the files to find, using the drop-down lists. The tool filters the graph to show only the files found in the analysis. You can clear the filter using the Clear button.
7. Select Modified Files in the Analyze list, Impacted Files in the Find list, and click Find.
The files displayed in the graph are filtered to show only those impacted by the modifications that you have made to the project.
The labels that are attached to each file can be displayed on the graph by changing the file highlighting. You can use this to display information about each file.
All projects come with a Classification label category that contains some common file classifications. The example project contains extra labels that have been added to the category, including a Test label that identifies which files are tests.
8. Right-click the graph and select Highlight Files > Classification.
Each file in the graph is now colored by its file Classification. For the files impacted by the change to vertical_channel.slx there are some Design files and a couple of Test files. This identifies the tests that are impacted by the modification. These are the tests that need to be run to validate the design changes.
You can use the Export tool in the bottom right of the dependency graph to send files to other tools. If no files are selected, you export all files in the currently filtered view, otherwise only the selected files are exported. You can click items in the legends to select groups of files to export.
9. Click Test in the Classification legend to select all test files.
10. Click Send to Batch Job in the export tool.
The view changes to the Batch Job view. The test files you exported from the impact analysis are selected.
11. To run the selected tests, in the bottom right of the Batch Job view click Select > Testing > Run Unit Tests. Click Run Batch Job.
The Run Unit Tests batch job runs MATLAB unit tests and creates a simple summary report. Look in the Batch Job Results pane to see the report for each test file run.
If you want to export the impacted files to the workspace, in the Impact view you can select the Save to Workspace export option. This creates a cell array of file paths to the exported files.