Skip to content

Commit 44a659c

Browse files
author
Andrew Hall
authored
Add conditional skip for integration tests (#8811)
Add an attribute that uses an environment variable to allow the test to run, and add the environment variable to our regularly scheduled integration runs that are on a rolling cadence in the dart lab
1 parent 6dff364 commit 44a659c

File tree

4 files changed

+49
-5
lines changed

4 files changed

+49
-5
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
"[json]": {
1313
"editor.tabSize": 2
1414
},
15+
"dotnet.defaultSolution": "Razor.sln",
1516
"omnisharp.defaultLaunchSolution": "Razor.sln"
1617
}

azure-pipelines-integration-dartlab.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ variables:
2929
value: $(Build.SourcesDirectory)\artifacts\log\$(_configuration)
3030
- name: __VSNeverShowWhatsNew
3131
value: 1
32+
- name: RAZOR_RUN_ALL_TESTS
33+
value: 'true'
3234

3335
stages:
3436
- template: \stages\visual-studio\agent.yml@DartLabTemplates
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT license. See License.txt in the project root for license information.
3+
4+
using System;
5+
using Xunit;
6+
7+
namespace Microsoft.VisualStudio.Razor.IntegrationTests;
8+
9+
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
10+
public class ConditionalSkipIdeFactAttribute : IdeFactAttribute
11+
{
12+
private readonly Lazy<bool> _runFlakyTests = new(() => Environment.GetEnvironmentVariable("RAZOR_RUN_ALL_TESTS")?.ToLower() == "true");
13+
14+
public ConditionalSkipIdeFactAttribute()
15+
{
16+
}
17+
18+
private string _issue = "";
19+
public string Issue
20+
{
21+
get => _issue;
22+
set
23+
{
24+
_issue = value;
25+
26+
if (!_runFlakyTests.Value)
27+
{
28+
#pragma warning disable CS0618
29+
Skip = _issue;
30+
#pragma warning restore CS0618
31+
}
32+
}
33+
}
34+
35+
[Obsolete("Use Issue instead of Skip")]
36+
public new string Skip
37+
{
38+
get => base.Skip;
39+
set => base.Skip = value;
40+
}
41+
}

src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/DiagnosticTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.VisualStudio.Razor.IntegrationTests;
88

99
public class DiagnosticTests : AbstractRazorEditorTest
1010
{
11-
[IdeFact(Skip = "https://github.com/dotnet/razor/issues/8150")]
11+
[ConditionalSkipIdeFact(Issue = "https://github.com/dotnet/razor/issues/8150")]
1212
public async Task Diagnostics_ShowErrors_Razor()
1313
{
1414
// Arrange
@@ -48,7 +48,7 @@ public void Function(){
4848
});
4949
}
5050

51-
[IdeFact(Skip = "https://github.com/dotnet/razor/issues/8150")]
51+
[ConditionalSkipIdeFact(Issue = "https://github.com/dotnet/razor/issues/8150")]
5252
public async Task Diagnostics_ShowErrors_Html()
5353
{
5454
// Arrange
@@ -80,7 +80,7 @@ await TestServices.Editor.SetTextAsync(@"
8080
});
8181
}
8282

83-
[IdeFact(Skip = "https://github.com/dotnet/razor/issues/8150")]
83+
[ConditionalSkipIdeFact(Issue = "https://github.com/dotnet/razor/issues/8150")]
8484
public async Task Diagnostics_ShowErrors_CSharp()
8585
{
8686
// Arrange
@@ -112,7 +112,7 @@ await TestServices.Editor.SetTextAsync(@"
112112
});
113113
}
114114

115-
[IdeFact(Skip = "https://github.com/dotnet/razor/issues/8150")]
115+
[ConditionalSkipIdeFact(Issue = "https://github.com/dotnet/razor/issues/8150")]
116116
public async Task Diagnostics_ShowErrors_CSharp_NoDocType()
117117
{
118118
// Why this test, when we have the above test, and they seem so similar, and we also have Diagnostics_ShowErrors_CSharpAndHtml you ask? Well I'll tell you!
@@ -152,7 +152,7 @@ await TestServices.Editor.SetTextAsync(@"
152152
});
153153
}
154154

155-
[IdeFact(Skip = "https://github.com/dotnet/razor/issues/8150")]
155+
[ConditionalSkipIdeFact(Issue = "https://github.com/dotnet/razor/issues/8150")]
156156
public async Task Diagnostics_ShowErrors_CSharpAndHtml()
157157
{
158158
// Arrange

0 commit comments

Comments
 (0)