1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
+ using HostActivation . Tests ;
4
5
using Microsoft . DotNet . Cli . Build . Framework ;
5
6
using System ;
6
7
using System . IO ;
@@ -216,12 +217,21 @@ public void GetHostFxrPath_InstallLocationFile(string value, bool shouldUseArchS
216
217
. DotNetRoot ( null )
217
218
. Execute ( ) ;
218
219
219
- result . Should ( ) . HaveStdErrContaining ( $ "Looking for install_location file in '{ registeredInstallLocationOverride . PathValueOverride } '.") ;
220
+ if ( shouldUseArchSpecificInstallLocation )
221
+ {
222
+ result . Should ( ) . HaveLookedForArchitectureSpecificInstallLocation (
223
+ registeredInstallLocationOverride . PathValueOverride ,
224
+ sharedState . RepoDirectories . BuildArchitecture ) ;
225
+ }
226
+ else
227
+ {
228
+ result . Should ( ) . HaveLookedForDefaultInstallLocation ( registeredInstallLocationOverride . PathValueOverride ) ;
229
+ }
220
230
221
231
if ( shouldPass )
222
232
{
223
233
result . Should ( ) . Pass ( )
224
- . And . HaveStdErrContaining ( $ "Using install location ' { installLocation } '." )
234
+ . And . HaveUsedConfigFileInstallLocation ( installLocation )
225
235
. And . HaveStdOutContaining ( $ "hostfxr_path: { sharedState . HostFxrPath } ". ToLower ( ) ) ;
226
236
}
227
237
else
@@ -234,35 +244,6 @@ public void GetHostFxrPath_InstallLocationFile(string value, bool shouldUseArchS
234
244
}
235
245
}
236
246
237
- [ Fact ]
238
- [ SkipOnPlatform ( TestPlatforms . Windows , "This test targets the install_location config file which is only used on Linux and macOS." ) ]
239
- public void GetHostFxrPath_GlobalInstallation_HasMoreThanOneDefaultInstallationPath ( )
240
- {
241
- string installLocation = Path . Combine ( sharedState . ValidInstallRoot , "dotnet" ) ;
242
- using ( var registeredInstallLocationOverride = new RegisteredInstallLocationOverride ( sharedState . NethostPath ) )
243
- {
244
- registeredInstallLocationOverride . SetInstallLocation ( new ( string , string ) [ ] {
245
- ( string . Empty , installLocation ) , ( string . Empty , installLocation )
246
- } ) ;
247
-
248
- CommandResult result = Command . Create ( sharedState . NativeHostPath , GetHostFxrPath )
249
- . EnableTracingAndCaptureOutputs ( )
250
- . ApplyRegisteredInstallLocationOverride ( registeredInstallLocationOverride )
251
- . EnvironmentVariable ( // Redirect the default install location to an invalid location so that it doesn't cause the test to pass
252
- Constants . TestOnlyEnvironmentVariables . DefaultInstallPath ,
253
- sharedState . InvalidInstallRoot )
254
- . DotNetRoot ( null )
255
- . Execute ( ) ;
256
-
257
- result . Should ( ) . Pass ( )
258
- . And . HaveStdErrContaining ( $ "Looking for install_location file in '{ registeredInstallLocationOverride . PathValueOverride } '.")
259
- . And . HaveStdErrContaining ( $ "Found install location path '{ installLocation } '.")
260
- . And . HaveStdErrContaining ( $ "Only the first line in '{ registeredInstallLocationOverride . PathValueOverride } ' may not have an architecture prefix.")
261
- . And . HaveStdErrContaining ( $ "Using install location '{ installLocation } '.")
262
- . And . HaveStdOutContaining ( $ "hostfxr_path: { sharedState . HostFxrPath } ". ToLower ( ) ) ;
263
- }
264
- }
265
-
266
247
[ Fact ]
267
248
[ SkipOnPlatform ( TestPlatforms . Windows , "This test targets the install_location config file which is only used on Linux and macOS." ) ]
268
249
public void GetHostFxrPath_GlobalInstallation_HasNoDefaultInstallationPath ( )
@@ -285,9 +266,10 @@ public void GetHostFxrPath_GlobalInstallation_HasNoDefaultInstallationPath()
285
266
. Execute ( ) ;
286
267
287
268
result . Should ( ) . Pass ( )
288
- . And . HaveStdErrContaining ( $ "Looking for install_location file in '{ registeredInstallLocationOverride . PathValueOverride } '.")
289
- . And . HaveStdErrContaining ( $ "Found architecture-specific install location path: '{ installLocation } ' ('{ sharedState . RepoDirectories . BuildArchitecture . ToLower ( ) } ').")
290
- . And . HaveStdErrContaining ( $ "Using install location '{ installLocation } '.")
269
+ . And . HaveLookedForArchitectureSpecificInstallLocation (
270
+ registeredInstallLocationOverride . PathValueOverride ,
271
+ sharedState . RepoDirectories . BuildArchitecture )
272
+ . And . HaveUsedConfigFileInstallLocation ( installLocation )
291
273
. And . HaveStdOutContaining ( $ "hostfxr_path: { sharedState . HostFxrPath } ". ToLower ( ) ) ;
292
274
}
293
275
}
@@ -314,10 +296,10 @@ public void GetHostFxrPath_GlobalInstallation_ArchitectureSpecificPathIsPickedOv
314
296
. Execute ( ) ;
315
297
316
298
result . Should ( ) . Pass ( )
317
- . And . HaveStdErrContaining ( $ "Looking for install_location file in ' { registeredInstallLocationOverride . PathValueOverride } '." )
318
- . And . HaveStdErrContaining ( $ "Found install location path ' { installLocation } /a/b/c'." )
319
- . And . HaveStdErrContaining ( $ "Found architecture-specific install location path: ' { installLocation } ' (' { sharedState . RepoDirectories . BuildArchitecture . ToLower ( ) } ')." )
320
- . And . HaveStdErrContaining ( $ "Using install location ' { installLocation } '." )
299
+ . And . HaveLookedForArchitectureSpecificInstallLocation (
300
+ registeredInstallLocationOverride . PathValueOverride ,
301
+ sharedState . RepoDirectories . BuildArchitecture )
302
+ . And . HaveUsedConfigFileInstallLocation ( installLocation )
321
303
. And . HaveStdOutContaining ( $ "hostfxr_path: { sharedState . HostFxrPath } ". ToLower ( ) ) ;
322
304
}
323
305
}
0 commit comments