-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtParallelizableBuildSummaryPlugin.m
More file actions
111 lines (80 loc) · 3.3 KB
/
Copy pathtParallelizableBuildSummaryPlugin.m
File metadata and controls
111 lines (80 loc) · 3.3 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
classdef tParallelizableBuildSummaryPlugin < matlab.unittest.TestCase
% Copyright 2026 The MathWorks, Inc.
properties
TempFolder
Plugin
Runner
end
methods (TestClassSetup)
function setupPath(testCase)
import matlab.unittest.fixtures.PathFixture;
testCase.assumeFalse(isMATLABReleaseOlderThan("R2026a"));
testCase.applyFixture(PathFixture(fileparts(fileparts(mfilename("fullpath")))));
end
end
methods (TestMethodSetup)
function createPlugin(testCase)
import matlab.unittest.fixtures.WorkingFolderFixture;
testCase.applyFixture(WorkingFolderFixture);
testCase.TempFolder = pwd();
testCase.Plugin = ParallelizableBuildSummaryPlugin(TempFolder=testCase.TempFolder);
testCase.Runner = matlab.buildtool.BuildRunner.withNoPlugins();
testCase.Runner.addPlugin(testCase.Plugin);
end
end
methods (Test)
function runningBuildCreatesSummaryArtifact(testCase)
plan = buildplan();
plan("t1") = Task();
plan("t2") = Task();
testCase.Runner.run(plan, ["t1", "t2"]);
name = "buildSummary" + getenv("GITHUB_RUN_ID") + ".json";
testCase.verifyTrue(isfile(fullfile(testCase.TempFolder, name)));
end
function runningBuildCreatesSummaryArtifactWithExpectedTasks(testCase)
plan = buildplan();
plan("t1") = Task();
plan("t2") = Task();
testCase.Runner.run(plan, ["t1", "t2"]);
name = "buildSummary" + getenv("GITHUB_RUN_ID") + ".json";
f = fullfile(testCase.TempFolder, name);
testCase.assertTrue(isfile(f));
s = readstruct(f);
testCase.verifySize(s, [1 2]);
testCase.verifyEqual(s(1).name, "t1");
testCase.verifyEqual(s(2).name, "t2");
end
function summaryArtifactStatusesAreCorrect(testCase)
plan = buildplan();
plan("t1") = Task();
plan("t2") = Task(Actions=@()error("bam"));
testCase.Runner.run(plan, ["t1", "t2"]);
name = "buildSummary" + getenv("GITHUB_RUN_ID") + ".json";
f = fullfile(testCase.TempFolder, name);
testCase.assertTrue(isfile(f));
s = readstruct(f);
testCase.verifySize(s, [1 2]);
testCase.verifyFalse(s(1).failed);
testCase.verifyFalse(s(1).skipped);
testCase.verifyTrue(s(2).failed);
testCase.verifyFalse(s(2).skipped);
end
function runningBuildCreatesSummaryForTaskGroups(testCase)
plan = buildplan();
plan("g:t") = Task();
testCase.Runner.run(plan, "g:t");
name = "buildSummary" + getenv("GITHUB_RUN_ID") + ".json";
f = fullfile(testCase.TempFolder, name);
testCase.assertTrue(isfile(f));
s = readstruct(f);
testCase.verifySize(s, [1 1]);
testCase.verifyEqual(s(1).name, "g:t");
end
end
end
function plugin = ParallelizableBuildSummaryPlugin(varargin)
plugin = buildframework.ParallelizableBuildSummaryPlugin(varargin{:});
end
function task = Task(varargin)
task = matlab.buildtool.Task(varargin{:});
end