-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added badge to repo. Removed old startup files from project.
- Loading branch information
Showing
16 changed files
with
162 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"schemaVersion":1,"label":"tested with","message":"","color":"success"} | ||
{"schemaVersion":1,"label":"Tested with","color":"success","message":"R2022a | R2022b | R2023a | R2023b | R2024a"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
classdef CheckTestResults < matlab.unittest.TestCase | ||
|
||
properties (SetAccess = protected) | ||
end | ||
|
||
properties (ClassSetupParameter) | ||
Project = {''}; | ||
end | ||
|
||
properties (TestParameter) | ||
Version | ||
end | ||
|
||
|
||
methods (TestParameterDefinition,Static) | ||
|
||
function Version = GetResults(Project) | ||
RootFolder = currentProject().RootFolder; | ||
Version = dir(fullfile(RootFolder,"SoftwareTests","TestResults*.txt")); | ||
Version = extractBetween([Version.name],"TestResults_",".txt"); | ||
end | ||
|
||
end | ||
|
||
methods (TestClassSetup) | ||
|
||
function SetUpSmokeTest(testCase,Project) | ||
try | ||
currentProject; | ||
catch | ||
error("Project is not loaded.") | ||
end | ||
end | ||
|
||
end | ||
|
||
methods(Test) | ||
|
||
function CheckResults(testCase,Version) | ||
File = fullfile("SoftwareTests","TestResults_"+Version+".txt"); | ||
Results = readtable(File,TextType="string"); | ||
testCase.verifyTrue(all(Results.Passed)); | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,28 @@ | ||
% Run these tests with runMyTests | ||
% All tests so far are on code expected to run without errors | ||
% If/when we end up with a version that _should_ error, | ||
% please add it to this set of examples | ||
classdef CreateBadge < matlab.unittest.TestCase | ||
|
||
properties | ||
rootProject | ||
results | ||
end | ||
|
||
|
||
methods (TestClassSetup) | ||
|
||
function setUpPath(testCase) | ||
|
||
try | ||
project = currentProject; | ||
testCase.rootProject = project.RootFolder; | ||
cd(testCase.rootProject) | ||
catch | ||
error("Load project prior to run tests") | ||
end | ||
|
||
testCase.log("Running in " + version) | ||
|
||
end % function setUpPath | ||
|
||
function readResults(testCase) | ||
Release = string([]); | ||
Passed = []; | ||
testCase.results = table(Release,Passed); | ||
|
||
ResultFiles = dir("SoftwareTests"+filesep+"TestResults_*"); | ||
for kFiles = 1:size(ResultFiles) | ||
Results = readtable(fullfile(ResultFiles(kFiles).folder,ResultFiles(kFiles).name),... | ||
Delimiter=",",TextType="string"); | ||
Release = Results.Version(1); | ||
Passed = all(Results.Status == "passed"); | ||
testCase.results(end+1,:) = table(Release,Passed); | ||
end | ||
end | ||
|
||
end % methods (TestClassSetup) | ||
|
||
methods(Test) | ||
|
||
function writeBadge(testCase) | ||
|
||
% Create JSON | ||
badgeInfo = struct; | ||
badgeInfo.schemaVersion = 1; | ||
badgeInfo.label = "tested with"; | ||
badgeInfo.message = ""; | ||
|
||
% Check that results exist: | ||
if size(testCase.results,1) == 0 | ||
badgeInfo.message = "None"; | ||
badgeInfo.color = "failed"; | ||
else | ||
for i = 1:size(testCase.results,1) | ||
if testCase.results.Passed(i) | ||
if badgeInfo.message ~= "" | ||
badgeInfo.message = badgeInfo.message + " | "; | ||
end | ||
badgeInfo.message = badgeInfo.message + string(testCase.results.Release(i)); | ||
end | ||
end | ||
badgeInfo.color = "success"; | ||
end | ||
|
||
% Write JSON file out | ||
badgeJSON = jsonencode(badgeInfo); | ||
fid = fopen(fullfile("Images","TestedWith.json"),"w"); | ||
fwrite(fid,badgeJSON); | ||
fclose(fid); | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
% Create the test suite with SmokeTest and Function test if they exist | ||
Suite = testsuite("CheckTestResults"); | ||
|
||
% Create a runner with no plugins | ||
Runner = matlab.unittest.TestRunner.withNoPlugins; | ||
|
||
% Run the test suite | ||
Results = Runner.run(Suite); | ||
|
||
% Format the results in a table and save them | ||
Results = table(Results'); | ||
Results = Results(Results.Passed,:); | ||
Version = extractBetween(string(Results.Name),"Version=",")"); | ||
|
||
|
||
% Format the JSON file | ||
Badge = struct; | ||
Badge.schemaVersion = 1; | ||
Badge.label = "Tested with"; | ||
if size(Results,1) >= 1 | ||
Badge.color = "success" | ||
Badge.message = join(Version," | "); | ||
else | ||
Badge.color = "failure"; | ||
Badge.message = "Pipeline fails"; | ||
end | ||
Badge = jsonencode(Badge); | ||
writelines(Badge,fullfile("Images","TestedWith.json")); |
Oops, something went wrong.