@@ -23,6 +23,7 @@ describe("install procedure", () => {
23
23
let matlabSetupBatchMock : jest . Mock ;
24
24
let mpmSetupMock : jest . Mock ;
25
25
let mpmInstallMock : jest . Mock ;
26
+ let mpmInstallSourceMock : jest . Mock ;
26
27
let saveStateMock : jest . Mock ;
27
28
let addPathMock : jest . Mock ;
28
29
let setOutputMock : jest . Mock ;
@@ -51,6 +52,7 @@ describe("install procedure", () => {
51
52
matlabSetupBatchMock = matlab . setupBatch as jest . Mock ;
52
53
mpmSetupMock = mpm . setup as jest . Mock ;
53
54
mpmInstallMock = mpm . install as jest . Mock ;
55
+ mpmInstallSourceMock = mpm . installFromSource as jest . Mock ;
54
56
saveStateMock = core . saveState as jest . Mock ;
55
57
addPathMock = core . addPath as jest . Mock ;
56
58
setOutputMock = core . setOutput as jest . Mock ;
@@ -92,7 +94,7 @@ describe("install procedure", () => {
92
94
matlabGetReleaseInfoMock . mockResolvedValue ( {
93
95
name : "r2020a" ,
94
96
version : "9.8.0" ,
95
- updateNumber : "latest"
97
+ updateNumber : "latest"
96
98
} ) ;
97
99
await expect ( install . install ( platform , arch , "r2020a" , products , useCache ) ) . rejects . toBeDefined ( ) ;
98
100
} ) ;
@@ -124,11 +126,22 @@ describe("install procedure", () => {
124
126
expect ( saveStateMock ) . toHaveBeenCalledTimes ( 0 ) ;
125
127
} ) ;
126
128
129
+ it ( "rejects when mpm installing from source fails" , async ( ) => {
130
+ mpmInstallSourceMock . mockRejectedValue ( Error ( "oof" ) ) ;
131
+ await expect ( install . installFromSource ( "linux" , "x64" , "bad/path" , [ "MATLAB" ] ) ) . rejects . toBeDefined ( ) ;
132
+ expect ( saveStateMock ) . toHaveBeenCalledTimes ( 0 ) ;
133
+ } ) ;
134
+
127
135
it ( "rejects when the matlab-batch install fails" , async ( ) => {
128
136
matlabSetupBatchMock . mockRejectedValueOnce ( Error ( "oof" ) ) ;
129
137
await expect ( doInstall ( ) ) . rejects . toBeDefined ( ) ;
130
138
} ) ;
131
139
140
+ it ( "installing from source rejects when the matlab-batch install fails" , async ( ) => {
141
+ matlabSetupBatchMock . mockRejectedValueOnce ( Error ( "oof" ) ) ;
142
+ await expect ( install . installFromSource ( "linux" , "x64" , "/path" , [ "MATLAB" ] ) ) . rejects . toBeDefined ( ) ;
143
+ } ) ;
144
+
132
145
it ( "Does not restore cache if useCache is false" , async ( ) => {
133
146
await expect ( doInstall ( ) ) . resolves . toBeUndefined ( ) ;
134
147
expect ( restoreMATLABMock ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -156,7 +169,7 @@ describe("install procedure", () => {
156
169
matlabGetReleaseInfoMock . mockResolvedValue ( {
157
170
name : "r2023a" ,
158
171
version : "9.14.0" ,
159
- updateNumber : "latest"
172
+ updateNumber : "latest"
160
173
} ) ;
161
174
await expect ( install . install ( "darwin" , "arm64" , "r2023a" , products , true ) ) . resolves . toBeUndefined ( ) ;
162
175
expect ( matlabInstallSystemDependenciesMock ) . toHaveBeenCalledWith ( "darwin" , "arm64" , "r2023a" ) ;
@@ -171,4 +184,34 @@ describe("install procedure", () => {
171
184
expect ( addPathMock ) . toHaveBeenCalledWith ( expect . stringContaining ( "runtime" ) ) ;
172
185
} ) ;
173
186
187
+ it ( "installs from source" , async ( ) => {
188
+ await expect ( install . installFromSource ( "linux" , "x64" , "/dummy/path" , [ "MATLAB" , "Parallel_Computing_Toolbox" ] ) )
189
+ . resolves
190
+ . toBeUndefined ( ) ;
191
+ expect ( matlabInstallSystemDependenciesMock ) . toHaveBeenCalledTimes ( 0 ) ;
192
+ expect ( matlabSetupBatchMock ) . toHaveBeenCalledTimes ( 1 ) ;
193
+ expect ( mpmSetupMock ) . toHaveBeenCalledTimes ( 1 ) ;
194
+ expect ( mpmInstallMock ) . toHaveBeenCalledTimes ( 0 ) ;
195
+ expect ( mpmInstallSourceMock ) . toHaveBeenCalledTimes ( 1 ) ;
196
+ expect ( saveStateMock ) . toHaveBeenCalledWith ( State . InstallSuccessful , 'true' ) ;
197
+ expect ( addPathMock ) . toHaveBeenCalledTimes ( 1 ) ;
198
+ expect ( setOutputMock ) . toHaveBeenCalledTimes ( 1 ) ;
199
+ } ) ;
200
+
201
+ it ( "NoOp on existing install from source" , async ( ) => {
202
+ matlabGetToolcacheDirMock . mockResolvedValue ( [ "/opt/hostedtoolcache/MATLAB/9.13.0/x64" , true ] ) ;
203
+ await expect ( install . installFromSource ( "linux" , "x64" , "/my/path" , [ "MATLAB" ] ) ) . resolves . toBeUndefined ( ) ;
204
+ expect ( mpmInstallMock ) . toHaveBeenCalledTimes ( 0 ) ;
205
+ expect ( saveStateMock ) . toHaveBeenCalledTimes ( 0 ) ;
206
+ expect ( addPathMock ) . toHaveBeenCalledTimes ( 1 ) ;
207
+ expect ( setOutputMock ) . toHaveBeenCalledTimes ( 1 ) ;
208
+ } ) ;
209
+
210
+ it ( "adds runtime path for Windows platform when installing from source" , async ( ) => {
211
+ await expect ( install . installFromSource ( "win32" , arch , "/dummy/path" , products ) ) . resolves . toBeUndefined ( ) ;
212
+ expect ( addPathMock ) . toHaveBeenCalledTimes ( 2 ) ;
213
+ expect ( addPathMock ) . toHaveBeenCalledWith ( expect . stringContaining ( "bin" ) ) ;
214
+ expect ( addPathMock ) . toHaveBeenCalledWith ( expect . stringContaining ( "runtime" ) ) ;
215
+ } ) ;
216
+
174
217
} ) ;
0 commit comments