aboutsummaryrefslogtreecommitdiff
path: root/src/test/burn/WixTestTools/LongRuntimeFactAttribute.cs
blob: 1da10df830d91130ac0e61f776a85c4801416d11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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.";
            }
        }
    }
}