Skip to content

Commit 7fb1b98

Browse files
committed
Update tests for R2025b maintenance
1 parent 739c1af commit 7fb1b98

File tree

121 files changed

+403
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+403
-28
lines changed

README.md

Lines changed: 2 additions & 2 deletions

README.mlx

-16 Bytes
Binary file not shown.

SoftwareTests/PostSmokeTest.m

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ function PostSmokeTest(ShowReport)
3131

3232
% Format the results in a table and save them
3333
Results = table(Results');
34-
Results = Results(Results.Passed,:);
3534
Version = extractBetween(string(Results.Name),"Version=",")");
35+
Passed = logical(Results.Passed);
3636

3737
% Add link to other report
3838
File = fileread(fullfile("public","index.html"));
@@ -45,13 +45,16 @@ function PostSmokeTest(ShowReport)
4545
% Format the JSON file
4646
Badge = struct;
4747
Badge.schemaVersion = 1;
48-
Badge.label = "Tested with";
49-
if size(Results,1) >= 1
50-
Badge.color = "success"
48+
Badge.label = "Test Status";
49+
if all(Passed)
50+
Badge.color = "success";
51+
Badge.message = join("R"+Version," | ");
52+
elseif any(Passed)
53+
Badge.color = "yellowgreen";
54+
Badge.message = join("R"+Version(Passed)," | ");
55+
elseif all(~Passed)
56+
Badge.color = "critical";
5157
Badge.message = join("R"+Version," | ");
52-
else
53-
Badge.color = "failure";
54-
Badge.message = "Pipeline fails";
5558
end
5659
Badge = jsonencode(Badge);
5760
writelines(Badge,fullfile("Images","TestedWith.json"));

SoftwareTests/SmokeTests.m

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
properties
44
RootFolder
5-
end
5+
sparedEditors % Files already open when the test starts
6+
end % properties
67

78
properties (ClassSetupParameter)
89
Project = {currentProject()};
9-
end
10+
end % ClassSetupParameter
1011

1112
properties (TestParameter)
1213
File;
13-
end
14+
end % TestParameter
1415

1516
methods (TestParameterDefinition,Static)
1617

@@ -21,7 +22,7 @@
2122
File = {File.name};
2223
end
2324

24-
end
25+
end % Static TestParameterDefinition
2526

2627
methods (TestClassSetup)
2728

@@ -37,8 +38,28 @@ function SetUpSmokeTest(testCase,Project) %#ok<INUSD>
3738
testCase.log("Running in " + version)
3839
end
3940

40-
end
41+
end % TestClassSetup
42+
43+
methods(TestMethodSetup)
44+
function recordEditorsToSpare(testCase)
45+
testCase.sparedEditors = matlab.desktop.editor.getAll;
46+
testCase.sparedEditors = {testCase.sparedEditors.Filename};
47+
end
48+
end % TestMethodSetup
4149

50+
methods(TestMethodTeardown)
51+
function closeOpenedEditors_thenDeleteWorkingDir(testCase)
52+
openEditors = matlab.desktop.editor.getAll;
53+
for editor=openEditors(1:end)
54+
if any(strcmp(editor.Filename, testCase.sparedEditors))
55+
continue;
56+
end
57+
% if not on our list, close the file
58+
editor.close();
59+
end
60+
end
61+
end % TestMethodTeardown
62+
4263
methods(Test)
4364

4465
function SmokeRun(testCase,File)
@@ -90,7 +111,7 @@ function SmokeRun(testCase,File)
90111

91112
end
92113

93-
end
114+
end % Test Methods
94115

95116

96117
methods (Access = private)
@@ -125,6 +146,6 @@ function SmokeRun(testCase,File)
125146
Path = PostFilePath;
126147
end
127148

128-
end
149+
end % Private Methods
129150

130-
end
151+
end % Smoketests

SoftwareTests/SolnSmokeTests.m

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,47 @@
33
properties
44
RootFolder
55
isSolnOnPath
6-
end
6+
sparedEditors % Track open files
7+
end % properties
78

89
properties (ClassSetupParameter)
910
Project = {currentProject()};
10-
end
11+
end % ClassSetupParameter
12+
13+
methods(TestMethodSetup)
14+
function recordEditorsToSpare(testCase)
15+
testCase.sparedEditors = matlab.desktop.editor.getAll;
16+
testCase.sparedEditors = {testCase.sparedEditors.Filename};
17+
end
18+
end % TestMethodSetup
19+
20+
methods(TestMethodTeardown)
21+
function closeOpenedEditors_thenDeleteWorkingDir(testCase)
22+
openEditors = matlab.desktop.editor.getAll;
23+
for editor=openEditors(1:end)
24+
if any(strcmp(editor.Filename, testCase.sparedEditors))
25+
continue;
26+
end
27+
% if not on our list, close the file
28+
editor.close();
29+
end
30+
end
31+
end % TestMethodTeardown
1132

1233
properties (TestParameter)
1334
File;
14-
end
35+
end % TestParameter
1536

1637
methods (TestParameterDefinition,Static)
1738

1839
function File = GetScriptName(Project)
1940
% Retrieve student template files:
2041
RootFolder = Project.RootFolder;
2142
File = dir(fullfile(RootFolder,"Scripts","*.mlx"));
22-
File = {File.name};
43+
File = {File.name};
2344
end
2445

25-
end
46+
end % Static TestParameterDefinition
2647

2748
methods (TestClassSetup)
2849

@@ -34,7 +55,7 @@ function SetUpPath(testCase,Project)
3455
% Check that solutions are on path:
3556
testCase.isSolnOnPath = isfolder("Solutions");
3657
if testCase.isSolnOnPath == 0
37-
addpath(fullfile(testCase.RootFolder,"InstructorResources","Solutions"))
58+
addpath(genpath(fullfile(testCase.RootFolder,"InstructorResources","Solutions")))
3859
end
3960

4061
% Close the StartUp app if still open:
@@ -54,7 +75,7 @@ function SetUpPath(testCase,Project)
5475
function ExistSolns(testCase,File)
5576
SolutionName = replace(string(File),".mlx","Soln.mlx");
5677
assert(exist(SolutionName,"file"),"Missing solutions for "+File);
57-
end
78+
end
5879

5980

6081
function SmokeRun(testCase,File)
@@ -106,8 +127,8 @@ function SmokeRun(testCase,File)
106127

107128
end
108129

109-
end
110-
130+
end % Test Methods
131+
111132
methods (Access = private)
112133

113134
function Path = CheckPreFile(testCase,Filename)
@@ -140,6 +161,16 @@ function SmokeRun(testCase,File)
140161
Path = PostFilePath;
141162
end
142163

143-
end
164+
end % Private Access Methods
165+
166+
methods (TestClassTeardown)
167+
168+
function ResetPath(testCase)
169+
if ~testCase.isSolnOnPath && exist("Solutions","dir")
170+
rmpath(genpath(fullfile(currentProject().RootFolder,"InstructorResources","Solutions")))
171+
end
172+
end
173+
174+
end % TestClassTeardown
144175

145-
end
176+
end % SolnSmokeTests
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="MagnetometerReadings.mp4" type="File"/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info location="AccelerometerReadings.mp4" type="File"/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Info/>

0 commit comments

Comments
 (0)