diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs index 587b274a1..b14c2bf78 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs @@ -24,10 +24,6 @@ namespace SixLabors.ImageSharp.Tests private static readonly Lazy SolutionDirectoryFullPathLazy = new Lazy(GetSolutionDirectoryFullPathImpl); - private static readonly Lazy RunsOnCiLazy = new Lazy(() => bool.TryParse(Environment.GetEnvironmentVariable("CI"), out bool isCi) && isCi); - - private static readonly Lazy RunsWithCodeCoverageLazy = new Lazy(() => bool.TryParse(Environment.GetEnvironmentVariable("codecov"), out bool isCodeCov) && isCodeCov); - private static readonly Lazy NetCoreVersionLazy = new Lazy(GetNetCoreVersion); static TestEnvironment() => PrepareRemoteExecutor(); @@ -42,12 +38,20 @@ namespace SixLabors.ImageSharp.Tests /// /// Gets a value indicating whether test execution runs on CI. /// - internal static bool RunsOnCI => RunsOnCiLazy.Value; +#if ENV_CI + internal static bool RunsOnCI => true; +#else + internal static bool RunsOnCI => false; +#endif /// /// Gets a value indicating whether test execution is running with code coverage testing enabled. /// - internal static bool RunsWithCodeCoverage => RunsWithCodeCoverageLazy.Value; +#if ENV_CODECOV + internal static bool RunsWithCodeCoverage => true; +#else + internal static bool RunsWithCodeCoverage => false; +#endif internal static string SolutionDirectoryFullPath => SolutionDirectoryFullPathLazy.Value; @@ -66,14 +70,14 @@ namespace SixLabors.ImageSharp.Tests } catch (Exception ex) { - throw new Exception( + throw new DirectoryNotFoundException( $"Unable to find ImageSharp solution directory from {TestAssemblyFile} because of {ex.GetType().Name}!", ex); } if (directory == null) { - throw new Exception($"Unable to find ImageSharp solution directory from {TestAssemblyFile}!"); + throw new DirectoryNotFoundException($"Unable to find ImageSharp solution directory from {TestAssemblyFile}!"); } }