-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPostSmokeTest.m
66 lines (53 loc) · 1.67 KB
/
PostSmokeTest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function PostSmokeTest(ShowReport)
arguments
ShowReport (1,1) logical = false;
end
import matlab.unittest.plugins.TestRunnerPlugin;
% Create the runner:
Runner = matlab.unittest.TestRunner.withTextOutput;
% Create report folder:
Folder = fullfile(currentProject().RootFolder,"public");
if ~isfolder(Folder)
mkdir(Folder)
end
% Add HTML plugin:
Plugin = matlab.unittest.plugins.TestReportPlugin.producingHTML(Folder,...
"IncludingPassingDiagnostics",true,...
"IncludingCommandWindowText",false,...
"LoggingLevel",matlab.automation.Verbosity(1));
Runner.addPlugin(Plugin);
% Create Test Suite
Suite = testsuite("CheckTestResults");
% Run the test suite
Results = Runner.run(Suite);
% Format the results in a table and save them
Results = table(Results');
Version = extractBetween(string(Results.Name),"Version=",")");
Passed = Results.Passed;
% Add link to other report
File = fileread(fullfile("public","index.html"));
for iVer = 1:length(Version)
File = replace(File,"Version="+Version(iVer),...
sprintf('<a href="%s/index.html">%s</a>',Version(iVer),"Version="+Version(iVer)));
end
writelines(File,fullfile("public","index.html"),"WriteMode","overwrite");
% Format the JSON file
Badge = struct;
Badge.schemaVersion = 1;
Badge.label = "Test Status";
if all(Passed)
Badge.color = "success";
Badge.message = join("R"+Version," | ");
elseif any(Passed)
Badge.color = "yellowgreen";
Badge.message = join("R")
elseif all(~Passed)
Badge.color = "critical";
Badge.message = join("R"+Version," | ");
end
Badge = jsonencode(Badge);
writelines(Badge,fullfile("Images","TestedWith.json"));
if ShowReport
web(fullfile(Folder,"index.html"))
end
end