33import * as assert from "assert" ;
44import * as taskLib from "azure-pipelines-task-lib/task" ;
55import * as toolLib from "azure-pipelines-tool-lib/tool" ;
6+ import * as fs from "fs" ;
67import * as sinon from "sinon" ;
78import * as install from "../src/install" ;
89import * as matlab from "../src/matlab" ;
@@ -19,6 +20,7 @@ export default function suite() {
1920 let stubMpmSetup : sinon . SinonStub ;
2021 let stubMpmInstall : sinon . SinonStub ;
2122 let stubPrependPath : sinon . SinonStub ;
23+ let stubExistsSync : sinon . SinonStub ;
2224
2325 const platform = "linux" ;
2426 const architecture = "x64" ;
@@ -44,6 +46,7 @@ export default function suite() {
4446 stubMpmSetup = sinon . stub ( mpm , "setup" ) ;
4547 stubMpmInstall = sinon . stub ( mpm , "install" ) ;
4648 stubPrependPath = sinon . stub ( toolLib , "prependPath" ) ;
49+ stubExistsSync = sinon . stub ( fs , "existsSync" ) ;
4750 } ) ;
4851
4952 afterEach ( ( ) => {
@@ -55,6 +58,7 @@ export default function suite() {
5558 stubMpmSetup . restore ( ) ;
5659 stubMpmInstall . restore ( ) ;
5760 stubPrependPath . restore ( ) ;
61+ stubExistsSync . restore ( ) ;
5862 } ) ;
5963
6064 it ( "ideally works" , async ( ) => {
@@ -102,5 +106,13 @@ export default function suite() {
102106 assert ( stubSetupBatch . calledWith ( "darwin" , "x64" ) ) ;
103107 assert ( stubMpmSetup . calledWith ( "darwin" , "x64" ) ) ;
104108 } ) ;
109+
110+ // Update the test cases
111+ it ( "adds MATLAB Runtime to system path on Windows if directory exists" , async ( ) => {
112+ stubExistsSync . returns ( true ) ;
113+ await install . install ( "win32" , "x64" , release , products ) ;
114+ assert ( stubPrependPath . calledWith ( `${ toolcacheDir } /runtime/win64` ) ) ;
115+ } ) ;
116+
105117 } ) ;
106118}
0 commit comments