@@ -9,43 +9,28 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests;
9
9
10
10
internal static class Config
11
11
{
12
- public const string DotNetDirectoryEnv = "SMOKE_TESTS_DOTNET_DIR" ;
13
- public const string ExcludeOmniSharpEnv = "SMOKE_TESTS_EXCLUDE_OMNISHARP" ;
14
- public const string IncludeArtifactsSizeEnv = "SMOKE_TESTS_INCLUDE_ARTIFACTSSIZE" ;
15
- public const string MsftSdkTarballPathEnv = "SMOKE_TESTS_MSFT_SDK_TARBALL_PATH" ;
16
- public const string PoisonReportPathEnv = "SMOKE_TESTS_POISON_REPORT_PATH" ;
17
- public const string PortableRidEnv = "SMOKE_TESTS_PORTABLE_RID" ;
18
- public const string PrereqsPathEnv = "SMOKE_TESTS_PREREQS_PATH" ;
19
- public const string CustomPackagesPathEnv = "SMOKE_TESTS_CUSTOM_PACKAGES_PATH" ;
20
- public const string SdkTarballPathEnv = "SMOKE_TESTS_SDK_TARBALL_PATH" ;
21
- public const string SourceBuiltArtifactsPathEnv = "SMOKE_TESTS_SOURCEBUILT_ARTIFACTS_PATH" ;
22
- public const string TargetRidEnv = "SMOKE_TESTS_TARGET_RID" ;
23
- public const string WarnSdkContentDiffsEnv = "SMOKE_TESTS_WARN_SDK_CONTENT_DIFFS" ;
24
- public const string WarnLicenseScanDiffsEnv = "SMOKE_TESTS_WARN_LICENSE_SCAN_DIFFS" ;
25
- public const string RunningInCIEnv = "SMOKE_TESTS_RUNNING_IN_CI" ;
26
- public const string LicenseScanPathEnv = "SMOKE_TESTS_LICENSE_SCAN_PATH" ;
12
+ const string ConfigSwitchPrefix = "Microsoft.DotNet.SourceBuild.SmokeTests." ;
27
13
28
- public static string DotNetDirectory { get ; } =
29
- Environment . GetEnvironmentVariable ( DotNetDirectoryEnv ) ?? Path . Combine ( Directory . GetCurrentDirectory ( ) , ".dotnet" ) ;
30
- public static string ? MsftSdkTarballPath { get ; } = Environment . GetEnvironmentVariable ( MsftSdkTarballPathEnv ) ;
31
- public static string ? PoisonReportPath { get ; } = Environment . GetEnvironmentVariable ( PoisonReportPathEnv ) ;
32
- public static string PortableRid { get ; } = Environment . GetEnvironmentVariable ( PortableRidEnv ) ??
33
- throw new InvalidOperationException ( $ "'{ Config . PortableRidEnv } ' must be specified") ;
34
- public static string ? PrereqsPath { get ; } = Environment . GetEnvironmentVariable ( PrereqsPathEnv ) ;
35
- public static string ? CustomPackagesPath { get ; } = Environment . GetEnvironmentVariable ( CustomPackagesPathEnv ) ;
36
- public static string ? SdkTarballPath { get ; } = Environment . GetEnvironmentVariable ( SdkTarballPathEnv ) ;
37
- public static string ? SourceBuiltArtifactsPath { get ; } = Environment . GetEnvironmentVariable ( SourceBuiltArtifactsPathEnv ) ;
38
- public static string TargetRid { get ; } = Environment . GetEnvironmentVariable ( TargetRidEnv ) ??
39
- throw new InvalidOperationException ( $ "'{ Config . TargetRidEnv } ' must be specified") ;
40
- public static string TargetArchitecture { get ; } = TargetRid . Split ( '-' ) [ 1 ] ;
41
- public static bool WarnOnSdkContentDiffs { get ; } =
42
- bool . TryParse ( Environment . GetEnvironmentVariable ( WarnSdkContentDiffsEnv ) , out bool warnOnSdkContentDiffs ) && warnOnSdkContentDiffs ;
43
- public static bool WarnOnLicenseScanDiffs { get ; } =
44
- bool . TryParse ( Environment . GetEnvironmentVariable ( WarnLicenseScanDiffsEnv ) , out bool warnOnLicenseScanDiffs ) && warnOnLicenseScanDiffs ;
14
+ public static string DotNetDirectory => ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( DotNetDirectory ) ) ?? throw new InvalidOperationException ( "DotNetDirectory must be specified" ) ;
15
+ public static string PortableRid => ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( PortableRid ) ) ?? throw new InvalidOperationException ( "Portable RID must be specified" ) ;
16
+ public static string TargetRid => ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( TargetRid ) ) ?? throw new InvalidOperationException ( "Target RID must be specified" ) ;
17
+
18
+ public static string ? CustomPackagesPath => ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( CustomPackagesPath ) ) ;
19
+ public static bool ExcludeOmniSharpTests => bool . TryParse ( ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( ExcludeOmniSharpTests ) ) , out bool excludeOmniSharpTests ) && excludeOmniSharpTests ;
20
+ public static bool IncludeArtifactsSize => bool . TryParse ( ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( IncludeArtifactsSize ) ) , out bool includeArtifactsSize ) && includeArtifactsSize ;
21
+ public static string ? LicenseScanPath => ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( LicenseScanPath ) ) ;
22
+ public static string ? MsftSdkTarballPath => ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( MsftSdkTarballPath ) ) ;
23
+ public static string ? PoisonReportPath => ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( PoisonReportPath ) ) ;
24
+ public static string ? PrereqsPath => ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( PrereqsPath ) ) ;
25
+ public static string ? SdkTarballPath => ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( SdkTarballPath ) ) ;
26
+ public static string ? SourceBuiltArtifactsPath => ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( SourceBuiltArtifactsPath ) ) ;
27
+ public static bool WarnOnLicenseScanDiffs => bool . TryParse ( ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( WarnOnLicenseScanDiffs ) ) , out bool warnOnLicenseScanDiffs ) && warnOnLicenseScanDiffs ;
28
+ public static bool WarnOnSdkContentDiffs => bool . TryParse ( ( string ) AppContext . GetData ( ConfigSwitchPrefix + nameof ( WarnOnSdkContentDiffs ) ) , out bool warnOnSdkContentDiffs ) && warnOnSdkContentDiffs ;
45
29
46
30
// Indicates whether the tests are being run in the context of a CI pipeline
47
- public static bool RunningInCI { get ; } =
48
- bool . TryParse ( Environment . GetEnvironmentVariable ( RunningInCIEnv ) , out bool runningInCI ) && runningInCI ;
49
-
50
- public static string ? LicenseScanPath { get ; } = Environment . GetEnvironmentVariable ( LicenseScanPathEnv ) ;
31
+ public static bool RunningInCI => ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "DOTNET_CI" ) ) ||
32
+ ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "HELIX_WORKITEM_ROOT" ) ) ||
33
+ ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "AGENT_OS" ) ) ;
34
+
35
+ public static string TargetArchitecture => TargetRid . Split ( '-' ) [ 1 ] ;
51
36
}
0 commit comments