@@ -110,36 +110,43 @@ private static async Task InitializeInstance(ITestOutputHelper output)
110
110
psi . Arguments = $ "/c npm { psi . Arguments } ";
111
111
}
112
112
113
- // It's important that we get the folder value before we start the process to prevent
114
- // untracked processes when the tracking folder is not correctly configure.
115
- var trackingFolder = GetProcessTrackingFolder ( ) ;
116
-
117
- if ( ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "helix" ) ) )
118
- {
119
- // Just create a random tracking folder on helix
120
- trackingFolder = Path . Combine ( Directory . GetCurrentDirectory ( ) , Path . GetRandomFileName ( ) ) ;
121
- Directory . CreateDirectory ( trackingFolder ) ;
122
- }
123
-
124
- if ( ! Directory . Exists ( trackingFolder ) )
125
- {
126
- throw new InvalidOperationException ( $ "Invalid tracking folder. Set the 'SeleniumProcessTrackingFolder' MSBuild property to a valid folder.") ;
127
- }
128
-
129
113
Process process = null ;
130
114
Process sentinel = null ;
131
115
string pidFilePath = null ;
132
- try
116
+ if ( ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "helix" ) ) )
133
117
{
134
- process = Process . Start ( psi ) ;
135
- pidFilePath = await WriteTrackingFileAsync ( output , trackingFolder , process ) ;
136
- sentinel = StartSentinelProcess ( process , pidFilePath , SeleniumProcessTimeout ) ;
118
+ // It's important that we get the folder value before we start the process to prevent
119
+ // untracked processes when the tracking folder is not correctly configure.
120
+ var trackingFolder = GetProcessTrackingFolder ( ) ;
121
+
122
+ if ( ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "helix" ) ) )
123
+ {
124
+ // Just create a random tracking folder on helix
125
+ trackingFolder = Path . Combine ( Directory . GetCurrentDirectory ( ) , Path . GetRandomFileName ( ) ) ;
126
+ Directory . CreateDirectory ( trackingFolder ) ;
127
+ }
128
+
129
+ if ( ! Directory . Exists ( trackingFolder ) )
130
+ {
131
+ throw new InvalidOperationException ( $ "Invalid tracking folder. Set the 'SeleniumProcessTrackingFolder' MSBuild property to a valid folder.") ;
132
+ }
133
+
134
+ try
135
+ {
136
+ process = Process . Start ( psi ) ;
137
+ pidFilePath = await WriteTrackingFileAsync ( output , trackingFolder , process ) ;
138
+ sentinel = StartSentinelProcess ( process , pidFilePath , SeleniumProcessTimeout ) ;
139
+ }
140
+ catch
141
+ {
142
+ ProcessCleanup ( process , pidFilePath ) ;
143
+ ProcessCleanup ( sentinel , pidFilePath : null ) ;
144
+ throw ;
145
+ }
137
146
}
138
- catch
147
+ else
139
148
{
140
- ProcessCleanup ( process , pidFilePath ) ;
141
- ProcessCleanup ( sentinel , pidFilePath : null ) ;
142
- throw ;
149
+ process = Process . Start ( psi ) ;
143
150
}
144
151
145
152
// Log output for selenium standalone process.
0 commit comments