|
4 | 4 | TestData
|
5 | 5 | end
|
6 | 6 |
|
| 7 | +properties (TestParameter) |
| 8 | +file = get_files() |
| 9 | +end |
| 10 | + |
7 | 11 | methods (TestClassSetup)
|
8 | 12 |
|
9 | 13 | function get_files(tc)
|
10 | 14 | import matlab.unittest.constraints.IsFile
|
11 | 15 | import matlab.unittest.constraints.IsFolder
|
12 | 16 |
|
13 | 17 | cwd = fileparts(mfilename('fullpath'));
|
14 |
| -folder = fullfile(cwd, '..'); |
15 | 18 | cfg_file = fullfile(cwd, "MLint.txt");
|
16 | 19 |
|
17 |
| -tc.assumeThat(folder, IsFolder) |
18 | 20 | tc.assumeThat(cfg_file, IsFile)
|
19 | 21 |
|
20 |
| -tc.TestData.folder = folder; |
21 | 22 | tc.TestData.cfg_file = cfg_file;
|
22 | 23 |
|
23 |
| -flist = dir(tc.TestData.folder + "/**/*.m"); |
24 |
| -N = length(flist); |
25 |
| -tc.assumeGreaterThan(N, 0) |
26 |
| - |
27 |
| -tc.TestData.flist = flist; |
28 |
| -tc.TestData.N = N; |
29 | 24 | end
|
30 | 25 |
|
31 | 26 | end
|
32 | 27 |
|
33 |
| -methods (Test) |
34 |
| - |
35 |
| -function test_lint(tc) |
36 |
| - |
37 |
| -flist = tc.TestData.flist; |
38 | 28 |
|
39 |
| -for i = 1:tc.TestData.N |
40 |
| - file = fullfile(flist(i).folder, flist(i).name); |
| 29 | +methods (Test) |
41 | 30 |
|
42 |
| - res = checkcode(file, "-config=" + tc.TestData.cfg_file, "-fullpath"); |
| 31 | +function test_lint(tc, file) |
| 32 | +res = checkcode(file, "-config=" + tc.TestData.cfg_file, "-fullpath"); |
43 | 33 |
|
44 |
| - for j = 1:length(res) |
45 |
| - tc.verifyFail(append(file, ":", int2str(res(j).line), " ", res(j).message)) |
46 |
| - end |
| 34 | +for j = 1:length(res) |
| 35 | + tc.verifyFail(append(file, ":", int2str(res(j).line), " ", res(j).message)) |
| 36 | +end |
47 | 37 | end
|
48 | 38 |
|
49 | 39 | end
|
50 | 40 |
|
51 | 41 | end
|
52 | 42 |
|
| 43 | + |
| 44 | +function filenames = get_files() |
| 45 | +cwd = fileparts(mfilename('fullpath')); |
| 46 | +flist = dir(fullfile(cwd, '/**/*.m')); |
| 47 | +for i = 1:length(flist) |
| 48 | + filenames{i} = fullfile(flist(i).folder, flist(i).name); %#ok<AGROW> |
| 49 | +end |
53 | 50 | end
|
0 commit comments