Skip to content

Commit a9df517

Browse files
committed
parametrize lint
1 parent e458c4f commit a9df517

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

+hdf5nc/TestALint.m

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,47 @@
44
TestData
55
end
66

7+
properties (TestParameter)
8+
file = get_files()
9+
end
10+
711
methods (TestClassSetup)
812

913
function get_files(tc)
1014
import matlab.unittest.constraints.IsFile
1115
import matlab.unittest.constraints.IsFolder
1216

1317
cwd = fileparts(mfilename('fullpath'));
14-
folder = fullfile(cwd, '..');
1518
cfg_file = fullfile(cwd, "MLint.txt");
1619

17-
tc.assumeThat(folder, IsFolder)
1820
tc.assumeThat(cfg_file, IsFile)
1921

20-
tc.TestData.folder = folder;
2122
tc.TestData.cfg_file = cfg_file;
2223

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;
2924
end
3025

3126
end
3227

33-
methods (Test)
34-
35-
function test_lint(tc)
36-
37-
flist = tc.TestData.flist;
3828

39-
for i = 1:tc.TestData.N
40-
file = fullfile(flist(i).folder, flist(i).name);
29+
methods (Test)
4130

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");
4333

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
4737
end
4838

4939
end
5040

5141
end
5242

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
5350
end

0 commit comments

Comments
 (0)