From 031991f32f059b64374e6d257cbe573304dd577f Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 13 May 2022 11:40:45 -0500 Subject: Add ability to skip tests at runtime, and skip long running cache tests 6665 --- .../burn/WixTestTools/LongRuntimeFactAttribute.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/test/burn/WixTestTools/LongRuntimeFactAttribute.cs (limited to 'src/test/burn/WixTestTools/LongRuntimeFactAttribute.cs') diff --git a/src/test/burn/WixTestTools/LongRuntimeFactAttribute.cs b/src/test/burn/WixTestTools/LongRuntimeFactAttribute.cs new file mode 100644 index 00000000..1da10df8 --- /dev/null +++ b/src/test/burn/WixTestTools/LongRuntimeFactAttribute.cs @@ -0,0 +1,27 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixTestTools +{ + using System; + + public class LongRuntimeFactAttribute : RuntimeFactAttribute + { + const string RequiredEnvironmentVariableName = "LongRuntimeTestsEnabled"; + + public static bool LongRuntimeTestsEnabled { get; } + + static LongRuntimeFactAttribute() + { + var testsEnabledString = Environment.GetEnvironmentVariable(RequiredEnvironmentVariableName); + LongRuntimeTestsEnabled = Boolean.TryParse(testsEnabledString, out var testsEnabled) && testsEnabled; + } + + public LongRuntimeFactAttribute() + { + if (!LongRuntimeTestsEnabled) + { + this.Skip = $"These tests take a long time to run, so the {RequiredEnvironmentVariableName} environment variable must be set to true."; + } + } + } +} -- cgit v1.2.3-55-g6feb