mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-13 11:20:31 +00:00
Mode env variables to FrameworkEnvironment
This commit is contained in:
22
osu.Framework/FrameworkEnvironment.cs
Normal file
22
osu.Framework/FrameworkEnvironment.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Platform;
|
||||
|
||||
namespace osu.Framework
|
||||
{
|
||||
public static class FrameworkEnvironment
|
||||
{
|
||||
public static readonly ExecutionMode? STARTUP_EXECUTION_MODE;
|
||||
public static readonly bool NO_TEST_TIMEOUT;
|
||||
public static readonly bool FORCE_TEST_GC;
|
||||
|
||||
static FrameworkEnvironment()
|
||||
{
|
||||
STARTUP_EXECUTION_MODE = Enum.TryParse<ExecutionMode>(Environment.GetEnvironmentVariable("OSU_EXECUTION_MODE"), true, out var mode) ? mode : null;
|
||||
NO_TEST_TIMEOUT = Environment.GetEnvironmentVariable("OSU_TESTS_NO_TIMEOUT") == "1";
|
||||
FORCE_TEST_GC = Environment.GetEnvironmentVariable("OSU_TESTS_FORCED_GC") == "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,10 +52,10 @@ namespace osu.Framework.Platform
|
||||
|
||||
base.SetupConfig(defaultOverrides);
|
||||
|
||||
if (Enum.TryParse<ExecutionMode>(Environment.GetEnvironmentVariable("OSU_EXECUTION_MODE"), out var mode))
|
||||
if (FrameworkEnvironment.STARTUP_EXECUTION_MODE != null)
|
||||
{
|
||||
Config.SetValue(FrameworkSetting.ExecutionMode, mode);
|
||||
Logger.Log($"Startup execution mode set to {mode} from envvar");
|
||||
Config.SetValue(FrameworkSetting.ExecutionMode, FrameworkEnvironment.STARTUP_EXECUTION_MODE);
|
||||
Logger.Log($"Startup execution mode set to {FrameworkEnvironment.STARTUP_EXECUTION_MODE} from envvar");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace osu.Framework.Testing.Drawables.Steps
|
||||
|
||||
private int invocations;
|
||||
|
||||
private static readonly int max_attempt_milliseconds = Environment.GetEnvironmentVariable("OSU_TESTS_NO_TIMEOUT") == "1" ? int.MaxValue : 10000;
|
||||
private static readonly int max_attempt_milliseconds = FrameworkEnvironment.NO_TEST_TIMEOUT ? int.MaxValue : 10000;
|
||||
|
||||
public override int RequiredRepetitions => success ? 0 : int.MaxValue;
|
||||
|
||||
|
||||
@@ -470,7 +470,7 @@ namespace osu.Framework.Testing
|
||||
runner.RunTestBlocking(this);
|
||||
checkForErrors();
|
||||
|
||||
if (Environment.GetEnvironmentVariable("OSU_TESTS_FORCED_GC") == "1")
|
||||
if (FrameworkEnvironment.FORCE_TEST_GC)
|
||||
{
|
||||
// Force any unobserved exceptions to fire against the current test run.
|
||||
// Without this they could be delayed until a future test scene is running, making tracking down the cause difficult.
|
||||
|
||||
Reference in New Issue
Block a user