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 SVN 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.
1. Run the following commands to create and open a working copy of the "sldemo_slproject_airframe" example.
Simulink.ModelManagement.Project.projectDemo('airframe', 'svn'); rebuild_s_functions('no_progress_dialog');
Creating sandbox for project. Created temporary example files in "/tmp/BR2015bd_259410_35349/slexamples/airframe4" Initializing: Project Path Identifying shadowed project files Running: /tmp/BR2015bd_259410_35349/slexamples/airframe4/utilities/set_up_project.m Loading: /tmp/BR2015bd_259410_35349/slexamples/airframe4/data/buses.mat Loading: /tmp/BR2015bd_259410_35349/slexamples/airframe4/data/f14_digital_data.mat 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 SVN 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. In the Dependency Analysis view, click Analyze.
The dependency graph displays the structure of your project. Each box in the graph represents a file, and each arrow is a dependency.
4. 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.
5. On the Dependency Analysis tab, click Group By > SVN.
The color of each file in the graph now represents its source control status. The status that each color represents is shown in the SVN 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 tools on the Dependency Analysis tab to analyze the graph to find impacted and required files. You choose the files to analyze, and the files to find. The tool filters the graph to show only the files found in the analysis. You can clear the filter using the X button on the filter bar.
6. On the Dependency Analysis tab, click Select > Modified Files, followed by Find > Files Impacted by Selection.
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. This includes a Test label that is used to identify which files are tests.
7. On the Dependency Analysis tab, click Group By > 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 Test file. 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 send files to other tools using the Export menu on the Dependency Analysis tab. 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.
8. Click Test in the Classification legend to select all test files.
9. On the Dependency Analysis tab, click Export > Send to Batch Job.
The view changes to the Batch Job view. The test files you exported from the impact analysis are selected.
10. 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 Dependency Analysis view you can select the Save to Workspace export option. This creates a cell array of file paths to the exported files.
If you want to view the impacted files in the Files view, in the Dependency Analysis view you can select the Show in Files View export option. This changes the view to the Files view and selects the exported files.