|
1 | 1 | classdef tautotrace < matlab.unittest.TestCase |
2 | 2 | % tests for AutoTrace |
3 | 3 |
|
4 | | - % Copyright 2024 The MathWorks, Inc. |
| 4 | + % Copyright 2024-2025 The MathWorks, Inc. |
5 | 5 |
|
6 | 6 | properties |
7 | 7 | OtelConfigFile |
@@ -155,6 +155,35 @@ function testIncludeFolder(testCase) |
155 | 155 | verifyEqual(testCase, results{2}.resourceSpans.scopeSpans.spans.parentSpanId, results{3}.resourceSpans.scopeSpans.spans.spanId); |
156 | 156 | end |
157 | 157 |
|
| 158 | + function testMultipleIncludeFolders(testCase) |
| 159 | + % testMultipleIncludeFolders: specify multiple folders in AdditionalFiles |
| 160 | + |
| 161 | + % Add example folders to the path |
| 162 | + examplefolder = fullfile(fileparts(mfilename('fullpath')), "autotrace_examples", "two_subfolders_example"); |
| 163 | + testCase.applyFixture(matlab.unittest.fixtures.PathFixture(examplefolder, ... |
| 164 | + "IncludingSubfolders",true)); |
| 165 | + |
| 166 | + % set up AutoTrace, turn off automatic detection and specify |
| 167 | + % dependencies using their folder name |
| 168 | + at = opentelemetry.autoinstrument.AutoTrace(@two_subfolders_example, ... |
| 169 | + "AutoDetectFiles", false, "AdditionalFiles", fullfile(examplefolder, ["helper1" "helper2"])); |
| 170 | + |
| 171 | + % run the example |
| 172 | + [~] = beginTrace(at); |
| 173 | + |
| 174 | + % perform test comparisons |
| 175 | + results = readJsonResults(testCase); |
| 176 | + verifyNumElements(testCase, results, 6); |
| 177 | + |
| 178 | + % check span names |
| 179 | + verifyEqual(testCase, string(results{1}.resourceSpans.scopeSpans.spans.name), "subfolder_helper1_1"); |
| 180 | + verifyEqual(testCase, string(results{2}.resourceSpans.scopeSpans.spans.name), "subfolder_helper1_2"); |
| 181 | + verifyEqual(testCase, string(results{3}.resourceSpans.scopeSpans.spans.name), "subfolder_helper2_1"); |
| 182 | + verifyEqual(testCase, string(results{4}.resourceSpans.scopeSpans.spans.name), "subfolder_helper2_2"); |
| 183 | + verifyEqual(testCase, string(results{5}.resourceSpans.scopeSpans.spans.name), "subfolder_helper2_3"); |
| 184 | + verifyEqual(testCase, string(results{6}.resourceSpans.scopeSpans.spans.name), "two_subfolders_example"); |
| 185 | + end |
| 186 | + |
158 | 187 | function testExcludeFolder(testCase) |
159 | 188 | % testExcludeFolder: specify a folder in ExcludeFiles |
160 | 189 |
|
@@ -227,6 +256,28 @@ function testNonFileOptions(testCase) |
227 | 256 | end |
228 | 257 | end |
229 | 258 |
|
| 259 | + function testIgnoreUnsupportedDependencies(testCase) |
| 260 | + % testIgnoreUnsupportedDependencies: Check that File dependencies that are not |
| 261 | + % .m or .mlx files are ignored. For example, .mat file. |
| 262 | + |
| 263 | + % Add example folders to the path |
| 264 | + examplefolder = fullfile(fileparts(mfilename('fullpath')), "autotrace_examples", "matfile_example"); |
| 265 | + testCase.applyFixture(matlab.unittest.fixtures.PathFixture(examplefolder)); |
| 266 | + |
| 267 | + % set up AutoTrace |
| 268 | + at = opentelemetry.autoinstrument.AutoTrace(@matfile_example); |
| 269 | + |
| 270 | + % run the example |
| 271 | + [~] = beginTrace(at); |
| 272 | + |
| 273 | + % perform test comparisons |
| 274 | + results = readJsonResults(testCase); |
| 275 | + |
| 276 | + % should only return 1 span |
| 277 | + verifyNumElements(testCase, results, 1); |
| 278 | + verifyEqual(testCase, string(results{1}.resourceSpans.scopeSpans.spans.name), "matfile_example"); |
| 279 | + end |
| 280 | + |
230 | 281 | function testError(testCase) |
231 | 282 | % testError: handling error situation |
232 | 283 |
|
|
0 commit comments