@@ -40,25 +40,33 @@ describe('Binary Control Operations', () => {
40
40
} ) ;
41
41
42
42
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
+
43
51
const platformAndBinary = [
44
52
{
45
53
binary : BINARY_LINKS . DARWIN ,
46
- folder : `/work /binary/${ LOCAL_BINARY_FOLDER } /darwin` ,
54
+ folder : `/_work /binary/${ LOCAL_BINARY_FOLDER } /darwin` ,
47
55
arch : 'x64' ,
48
56
platform : PLATFORMS . DARWIN ,
49
57
} , {
50
58
binary : BINARY_LINKS . LINUX_32 ,
51
- folder : `/work /binary/${ LOCAL_BINARY_FOLDER } /linux` ,
59
+ folder : `/_work /binary/${ LOCAL_BINARY_FOLDER } /linux` ,
52
60
arch : 'x32' ,
53
61
platform : PLATFORMS . LINUX ,
54
62
} , {
55
63
binary : BINARY_LINKS . LINUX_64 ,
56
- folder : `/work /binary/${ LOCAL_BINARY_FOLDER } /linux` ,
64
+ folder : `/_work /binary/${ LOCAL_BINARY_FOLDER } /linux` ,
57
65
arch : 'x64' ,
58
66
platform : PLATFORMS . LINUX ,
59
67
} , {
60
68
binary : BINARY_LINKS . WINDOWS ,
61
- folder : `/work /binary/${ LOCAL_BINARY_FOLDER } /win32` ,
69
+ folder : `/_work /binary/${ LOCAL_BINARY_FOLDER } /win32` ,
62
70
arch : 'x32' ,
63
71
platform : PLATFORMS . WIN32 ,
64
72
} ,
@@ -91,18 +99,22 @@ describe('Binary Control Operations', () => {
91
99
92
100
it ( 'Makes Directory for the binary folder in recursive manner' , async ( ) => {
93
101
sinon . stub ( io , 'mkdirP' ) . returns ( true ) ;
94
- sinon . stub ( os , 'platform' ) . returns ( 'darwin' ) ;
95
102
const binaryControl = new BinaryControl ( ) ;
96
103
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
+ ) ) ;
98
112
io . mkdirP . restore ( ) ;
99
- os . platform . restore ( ) ;
100
113
} ) ;
101
114
102
115
context ( 'Log File metadata' , ( ) => {
103
116
beforeEach ( ( ) => {
104
117
sinon . stub ( core , 'exportVariable' ) ;
105
- sinon . stub ( os , 'platform' ) . returns ( 'darwin' ) ;
106
118
sinon . stub ( github , 'context' ) . value ( {
107
119
job : 'someJobName' ,
108
120
} ) ;
@@ -111,13 +123,22 @@ describe('Binary Control Operations', () => {
111
123
afterEach ( ( ) => {
112
124
delete process . env [ BROWSERSTACK_LOCAL_LOGS_FILE ] ;
113
125
core . exportVariable . restore ( ) ;
114
- os . platform . restore ( ) ;
115
126
} ) ;
116
127
117
128
it ( 'Generates log-file name and path for Binary' , ( ) => {
118
129
sinon . stub ( Date , 'now' ) . returns ( 'now' ) ;
119
130
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
+ ) ;
121
142
const binaryControl = new BinaryControl ( ) ;
122
143
binaryControl . _generateLogFileMetadata ( ) ;
123
144
expect ( binaryControl . logFileName ) . to . eq ( expectedLogFileName ) ;
@@ -133,7 +154,17 @@ describe('Binary Control Operations', () => {
133
154
it ( 'Fetches log-file name and generates path for Binary if logs file name was already defined' , ( ) => {
134
155
process . env [ BROWSERSTACK_LOCAL_LOGS_FILE ] = `${ LOCAL_LOG_FILE_PREFIX } _${ github . context . job } _now.log` ;
135
156
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
+ ) ;
137
168
const binaryControl = new BinaryControl ( ) ;
138
169
binaryControl . _generateLogFileMetadata ( ) ;
139
170
expect ( binaryControl . logFileName ) . to . eq ( expectedLogFileName ) ;
@@ -148,18 +179,18 @@ describe('Binary Control Operations', () => {
148
179
149
180
context ( 'Generates args string based on the input to Binary Control & the operation required, i.e. start/stop' , ( ) => {
150
181
beforeEach ( ( ) => {
151
- sinon . stub ( os , 'platform' ) . returns ( 'darwin' ) ;
152
182
sinon . stub ( github , 'context' ) . value ( {
153
183
job : 'someJobName' ,
154
184
} ) ;
155
185
sinon . stub ( Date , 'now' ) . returns ( 'now' ) ;
156
186
sinon . stub ( core , 'exportVariable' ) ;
187
+ process . env . GITHUB_WORKSPACE = '/some/work/space' ;
157
188
} ) ;
158
189
159
190
afterEach ( ( ) => {
160
- os . platform . restore ( ) ;
161
191
Date . now . restore ( ) ;
162
192
core . exportVariable . restore ( ) ;
193
+ process . env . GITHUB_WORKSPACE = '' ;
163
194
} ) ;
164
195
165
196
context ( 'Start Operation' , ( ) => {
@@ -172,7 +203,16 @@ describe('Binary Control Operations', () => {
172
203
localTesting : 'start' ,
173
204
} ;
174
205
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 } ` ;
176
216
const binaryControl = new BinaryControl ( stateForBinary ) ;
177
217
binaryControl . _generateArgsForBinary ( ) ;
178
218
expect ( binaryControl . binaryArgs ) . to . eq ( expectedFinalArgs ) ;
0 commit comments