@@ -40,25 +40,33 @@ describe('Binary Control Operations', () => {
4040 } ) ;
4141
4242 context ( 'Private Methods Behaviour' , ( ) => {
43+ before ( ( ) => {
44+ process . env . GITHUB_WORKSPACE = '/some/work/space' ;
45+ } ) ;
46+
47+ after ( ( ) => {
48+ process . env . GITHUB_WORKSPACE = '' ;
49+ } ) ;
50+
4351 const platformAndBinary = [
4452 {
4553 binary : BINARY_LINKS . DARWIN ,
46- folder : `/work /binary/${ LOCAL_BINARY_FOLDER } /darwin` ,
54+ folder : `/_work /binary/${ LOCAL_BINARY_FOLDER } /darwin` ,
4755 arch : 'x64' ,
4856 platform : PLATFORMS . DARWIN ,
4957 } , {
5058 binary : BINARY_LINKS . LINUX_32 ,
51- folder : `/work /binary/${ LOCAL_BINARY_FOLDER } /linux` ,
59+ folder : `/_work /binary/${ LOCAL_BINARY_FOLDER } /linux` ,
5260 arch : 'x32' ,
5361 platform : PLATFORMS . LINUX ,
5462 } , {
5563 binary : BINARY_LINKS . LINUX_64 ,
56- folder : `/work /binary/${ LOCAL_BINARY_FOLDER } /linux` ,
64+ folder : `/_work /binary/${ LOCAL_BINARY_FOLDER } /linux` ,
5765 arch : 'x64' ,
5866 platform : PLATFORMS . LINUX ,
5967 } , {
6068 binary : BINARY_LINKS . WINDOWS ,
61- folder : `/work /binary/${ LOCAL_BINARY_FOLDER } /win32` ,
69+ folder : `/_work /binary/${ LOCAL_BINARY_FOLDER } /win32` ,
6270 arch : 'x32' ,
6371 platform : PLATFORMS . WIN32 ,
6472 } ,
@@ -91,18 +99,22 @@ describe('Binary Control Operations', () => {
9199
92100 it ( 'Makes Directory for the binary folder in recursive manner' , async ( ) => {
93101 sinon . stub ( io , 'mkdirP' ) . returns ( true ) ;
94- sinon . stub ( os , 'platform' ) . returns ( 'darwin' ) ;
95102 const binaryControl = new BinaryControl ( ) ;
96103 await binaryControl . _makeDirectory ( ) ;
97- sinon . assert . calledWith ( io . mkdirP , path . resolve ( process . env . HOME , 'work' , 'binary' , LOCAL_BINARY_FOLDER , 'darwin' ) ) ;
104+ sinon . assert . calledWith ( io . mkdirP , path . resolve (
105+ process . env . GITHUB_WORKSPACE ,
106+ '..' , '..' , '..' ,
107+ '_work' ,
108+ 'binary' ,
109+ LOCAL_BINARY_FOLDER ,
110+ os . platform ( ) ,
111+ ) ) ;
98112 io . mkdirP . restore ( ) ;
99- os . platform . restore ( ) ;
100113 } ) ;
101114
102115 context ( 'Log File metadata' , ( ) => {
103116 beforeEach ( ( ) => {
104117 sinon . stub ( core , 'exportVariable' ) ;
105- sinon . stub ( os , 'platform' ) . returns ( 'darwin' ) ;
106118 sinon . stub ( github , 'context' ) . value ( {
107119 job : 'someJobName' ,
108120 } ) ;
@@ -111,13 +123,22 @@ describe('Binary Control Operations', () => {
111123 afterEach ( ( ) => {
112124 delete process . env [ BROWSERSTACK_LOCAL_LOGS_FILE ] ;
113125 core . exportVariable . restore ( ) ;
114- os . platform . restore ( ) ;
115126 } ) ;
116127
117128 it ( 'Generates log-file name and path for Binary' , ( ) => {
118129 sinon . stub ( Date , 'now' ) . returns ( 'now' ) ;
119130 const expectedLogFileName = `${ LOCAL_LOG_FILE_PREFIX } _${ github . context . job } _now.log` ;
120- const expectedLogFilePath = path . resolve ( path . resolve ( process . env . HOME , 'work' , 'binary' , LOCAL_BINARY_FOLDER , 'darwin' ) , expectedLogFileName ) ;
131+ const expectedLogFilePath = path . resolve (
132+ path . resolve (
133+ process . env . GITHUB_WORKSPACE ,
134+ '..' , '..' , '..' ,
135+ '_work' ,
136+ 'binary' ,
137+ LOCAL_BINARY_FOLDER ,
138+ os . platform ( ) ,
139+ ) ,
140+ expectedLogFileName ,
141+ ) ;
121142 const binaryControl = new BinaryControl ( ) ;
122143 binaryControl . _generateLogFileMetadata ( ) ;
123144 expect ( binaryControl . logFileName ) . to . eq ( expectedLogFileName ) ;
@@ -133,7 +154,17 @@ describe('Binary Control Operations', () => {
133154 it ( 'Fetches log-file name and generates path for Binary if logs file name was already defined' , ( ) => {
134155 process . env [ BROWSERSTACK_LOCAL_LOGS_FILE ] = `${ LOCAL_LOG_FILE_PREFIX } _${ github . context . job } _now.log` ;
135156 const expectedLogFileName = `${ LOCAL_LOG_FILE_PREFIX } _${ github . context . job } _now.log` ;
136- const expectedLogFilePath = path . resolve ( path . resolve ( process . env . HOME , 'work' , 'binary' , LOCAL_BINARY_FOLDER , 'darwin' ) , expectedLogFileName ) ;
157+ const expectedLogFilePath = path . resolve (
158+ path . resolve (
159+ process . env . GITHUB_WORKSPACE ,
160+ '..' , '..' , '..' ,
161+ '_work' ,
162+ 'binary' ,
163+ LOCAL_BINARY_FOLDER ,
164+ os . platform ( ) ,
165+ ) ,
166+ expectedLogFileName ,
167+ ) ;
137168 const binaryControl = new BinaryControl ( ) ;
138169 binaryControl . _generateLogFileMetadata ( ) ;
139170 expect ( binaryControl . logFileName ) . to . eq ( expectedLogFileName ) ;
@@ -148,18 +179,18 @@ describe('Binary Control Operations', () => {
148179
149180 context ( 'Generates args string based on the input to Binary Control & the operation required, i.e. start/stop' , ( ) => {
150181 beforeEach ( ( ) => {
151- sinon . stub ( os , 'platform' ) . returns ( 'darwin' ) ;
152182 sinon . stub ( github , 'context' ) . value ( {
153183 job : 'someJobName' ,
154184 } ) ;
155185 sinon . stub ( Date , 'now' ) . returns ( 'now' ) ;
156186 sinon . stub ( core , 'exportVariable' ) ;
187+ process . env . GITHUB_WORKSPACE = '/some/work/space' ;
157188 } ) ;
158189
159190 afterEach ( ( ) => {
160- os . platform . restore ( ) ;
161191 Date . now . restore ( ) ;
162192 core . exportVariable . restore ( ) ;
193+ process . env . GITHUB_WORKSPACE = '' ;
163194 } ) ;
164195
165196 context ( 'Start Operation' , ( ) => {
@@ -172,7 +203,16 @@ describe('Binary Control Operations', () => {
172203 localTesting : 'start' ,
173204 } ;
174205
175- const expectedFinalArgs = `--key someKey --only-automate --ci-plugin GitHubAction --arg1 val1 --arg2 val2 --local-identifier someIdentifier --verbose 1 --log-file ${ path . resolve ( process . env . HOME , 'work' , 'binary' , 'LocalBinaryFolder' , 'darwin' , 'BrowserStackLocal_someJobName_now.log' ) } ` ;
206+ const expectedLogFilePath = path . resolve (
207+ process . env . GITHUB_WORKSPACE ,
208+ '..' , '..' , '..' ,
209+ '_work' ,
210+ 'binary' ,
211+ 'LocalBinaryFolder' ,
212+ os . platform ( ) ,
213+ 'BrowserStackLocal_someJobName_now.log' ,
214+ ) ;
215+ const expectedFinalArgs = `--key someKey --only-automate --ci-plugin GitHubAction --arg1 val1 --arg2 val2 --local-identifier someIdentifier --verbose 1 --log-file ${ expectedLogFilePath } ` ;
176216 const binaryControl = new BinaryControl ( stateForBinary ) ;
177217 binaryControl . _generateArgsForBinary ( ) ;
178218 expect ( binaryControl . binaryArgs ) . to . eq ( expectedFinalArgs ) ;
0 commit comments