-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtinstall.m
More file actions
63 lines (53 loc) · 2.39 KB
/
Copy pathtinstall.m
File metadata and controls
63 lines (53 loc) · 2.39 KB
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
classdef tinstall < matlab.unittest.TestCase
properties (TestParameter)
% This is not the complete list of allowed products, it is just a
% small sample to smoke test license checkout.
allowed = {'matlab', 'simulink', 'signal_toolbox', 'statistics_toolbox', ...
'optimization_toolbox', 'symbolic_toolbox', 'image_toolbox', 'control_toolbox', ...
'signal_blocks', 'curve_fitting_toolbox'}
restricted = {'rtw_embedded_coder', 'filter_design_hdl_coder', 'gpu_coder', ...
'simulink_hdl_coder', 'matlab_coder', 'real-time_workshop', 'simulink_plc_coder'}
example = {'matlab/intro', 'optim/SolveAConstrainedNonlinearProblemProblemBasedExample', ...
'curvefit/FitPolynomialExample', 'simulink_general/sldemo_bounceExample'}
end
methods (Test)
function testCheckoutAllowedLicense(testCase, allowed)
[status, msg] = license('checkout', allowed);
testCase.verifyThat(logical(status), IsTrue, msg);
end
function testFailToCheckoutRestrictedLicense(testCase, restricted)
import matlab.unittest.diagnostics.Diagnostic;
[status, msg] = license('checkout', restricted);
testCase.verifyThat(logical(status), IsFalse, Diagnostic.join([restricted ' should not checkout'], msg));
end
function testRunExample(testCase, example)
meta = findExample(example);
testCase.assumeTrue(isfolder(fullfile(meta.componentDir, 'main')), 'Demo not available');
testCase.applyFixture(PathFixture(meta.componentDir));
startingFigs = findall(groot, 'Type','figure');
testCase.addTeardown(@() close(setdiff(findall(groot, 'Type','figure'), startingFigs)));
[log, ex] = evalc('runDemo(fullfile(meta.componentDir, ''main'', meta.main));');
if ~isempty(ex)
disp(log);
rethrow(ex);
end
end
end
end
function ex = runDemo(demo) %#ok<DEFNU> evalc
try
run(demo)
ex = MException.empty;
catch ex
end
end
% imports
function c = IsTrue(varargin)
c = matlab.unittest.constraints.IsTrue(varargin{:});
end
function c = IsFalse(varargin)
c = matlab.unittest.constraints.IsFalse(varargin{:});
end
function c = PathFixture(varargin)
c = matlab.unittest.fixtures.PathFixture(varargin{:});
end