Skip to content

Commit

Permalink
Adjsut equivTest
Browse files Browse the repository at this point in the history
  • Loading branch information
acampbel committed Mar 22, 2024
1 parent 774effb commit 6974df8
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Publish to pages
on:
# This workflow requires enabling pages in the repository settings.
# Therefore not running automatically on push and pr
# push: # Uncomment to runs on push events
push: # Uncomment to runs on push events
# pull_request: # Runs on pull requests
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab

Expand Down
72 changes: 36 additions & 36 deletions buildfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,25 @@
Description="Produce a fully qualified toolbox for release");


% %% Build a MATLAB Production Server archive
% % Ad hoc task, task action defined in toolboxTask local function
% plan("ctf").Dependencies = ["lint","test"];
% plan("ctf").Inputs = ["code", "pcode", "buildutils/simulateSystemFunctionSignatures.json"];
% plan("ctf").Outputs = [...
% resultsFolder + "/ctf-archive/MassSpringDamperService.ctf", ...
% resultsFolder + "/ctf-build-results.mat", ...
% resultsFolder + "/ctf-archive"];
%% Build a MATLAB Production Server archive
% Ad hoc task, task action defined in toolboxTask local function
plan("ctf").Dependencies = ["lint","test"];
plan("ctf").Inputs = ["code", "pcode", "buildutils/simulateSystemFunctionSignatures.json"];
plan("ctf").Outputs = [...
resultsFolder + "/ctf-archive/MassSpringDamperService.ctf", ...
resultsFolder + "/ctf-build-results.mat", ...
resultsFolder + "/ctf-archive"];


% %% Integration tests - back-to-back equivalence tests for the production server archive
% plan("ctfIntegTest") = TestTask("integTests/equivalence",SourceFiles=["code","pcode"], ...
% Description="Run integration tests against CTF archive.", ...
% Dependencies="ctf");
%% Integration tests - back-to-back equivalence tests for the production server archive
plan("ctfIntegTest") = TestTask("integTests/equivalence",SourceFiles=["code","pcode"], ...
Description="Run integration tests against CTF archive.", ...
Dependencies="ctf");


% %% Create the deploy task - does nothing but depends on other tasks
% plan("deploy") = matlab.buildtool.Task(Dependencies="ctfIntegTest", ...
% Description="Produce and test a ctf archive to deploy to a MATLAB Production Server");
%% Create the deploy task - does nothing but depends on other tasks
plan("deploy") = matlab.buildtool.Task(Dependencies="ctfIntegTest", ...
Description="Produce and test a ctf archive to deploy to a MATLAB Production Server");


%% Produce HTML from workshop live scripts to publish to GitHub pages
Expand Down Expand Up @@ -163,27 +163,27 @@ function toolboxTask(context,version)
end


% %% The "ctf" task action
% function ctfTask(context)
% % Create a deployable archive for MATLAB Production Server
%
% ctfArchive = context.Task.Outputs(1).paths;
% ctfBuildResults = context.Task.Outputs(2).paths;
%
% % Create the archive options for the build.
% [ctfFolder, ctfFile] = fileparts(ctfArchive);
% opts = compiler.build.ProductionServerArchiveOptions(...
% ["code/simulateSystem.m", "pcode/springMassDamperDesign.m"], ...
% FunctionSignatures="buildutils/simulateSystemFunctionSignatures.json", ...
% OutputDir=ctfFolder, ...
% ArchiveName=ctfFile, ...
% ObfuscateArchive="on");
%
% % Build the archive
% buildResults = compiler.build.productionServerArchive(opts);
%
% save(ctfBuildResults,"buildResults");
% end
%% The "ctf" task action
function ctfTask(context)
% Create a deployable archive for MATLAB Production Server

ctfArchive = context.Task.Outputs(1).paths;
ctfBuildResults = context.Task.Outputs(2).paths;

% Create the archive options for the build.
[ctfFolder, ctfFile] = fileparts(ctfArchive);
opts = compiler.build.ProductionServerArchiveOptions(...
["code/simulateSystem.m", "pcode/springMassDamperDesign.m"], ...
FunctionSignatures="buildutils/simulateSystemFunctionSignatures.json", ...
OutputDir=ctfFolder, ...
ArchiveName=ctfFile, ...
ObfuscateArchive="on");

% Build the archive
buildResults = compiler.build.productionServerArchive(opts);

save(ctfBuildResults,"buildResults");
end


%% The "workshop" task action
Expand Down
37 changes: 23 additions & 14 deletions integTests/equivalence/MPSEquivalenceTest.m
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
classdef MPSEquivalenceTest < matlabtest.compiler.TestCase

methods(TestClassSetup)
function filterOnMac(testCase)
testCase.assumeReturnsTrue(@() ~ismac, ...
"MPS equivalence tests not supported on the mac");
end
end

properties(TestParameter)

resultsFile = {getBuildResultsFile};

% Can define different runtime inputs for the equivalence test
% For now we will just run against 1 data point
damping = struct(...
"OverDamped", 5e5, ...
"UnderDamped", 1e4, ...
"CriticallyDamped", 5.477225575051661e4)
end


methods(TestClassSetup)
function filterOnMac(testCase)
testCase.assumeReturnsTrue(@() ~ismac, ...
"MPS equivalence tests not supported on the mac");
end
end

methods (Test)
function mpsShouldBeEquivalentForDamping(testCase, damping)
function mpsShouldBeEquivalentForDamping(testCase, resultsFile, damping)
% Validate that MPS execution is equivalent to MATLAB for
% various damping coefficient designs

% Load the data we built via the build process
disp("Loading MPS build results")
prj = currentProject;
loadedData = load(fullfile(prj.RootFolder,"results", computer("arch"), "ctf-build-results.mat"));

% Load the results built in a prior build step
disp("Load the build results from the ""ctf"" task")
loadedData = load(resultsFile);
buildResults = loadedData.buildResults;

% Execute the runtime inputs (damping) on the server
Expand All @@ -39,3 +42,9 @@ function mpsShouldBeEquivalentForDamping(testCase, damping)
end
end
end

function resultsFile = getBuildResultsFile
prj = currentProject;
resultsFile = fullfile(prj.RootFolder,...
"results", computer("arch"), "ctf-build-results.mat");
end

This file was deleted.

This file was deleted.

51 changes: 0 additions & 51 deletions untitled.m

This file was deleted.

Binary file modified workshop/Chapter_3.mlx
Binary file not shown.

0 comments on commit 6974df8

Please sign in to comment.