Skip to content

Commit 2f71906

Browse files
Copilotadamsitnik
andcommitted
Fix build errors - complete migration from custom test attributes
- Convert MarkItDownConditionAttribute from ITestCondition to static helper class - Update MarkItDownReaderTests to use ConditionalFact with static property reference - Fix ResourceHealthCheckExtensionsTests: OSSkipCondition → PlatformSpecific(~TestPlatforms.OSX) - Fix LinuxResourceHealthCheckTests: OSSkipCondition → PlatformSpecific(TestPlatforms.Linux) - Remove all remaining references to ITestCondition, OSSkipCondition, and OperatingSystems - All test projects now build successfully Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
1 parent 4624b78 commit 2f71906

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownConditionAttribute.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,17 @@
55
using System.ComponentModel;
66
using System.Diagnostics;
77
using System.Text;
8-
using Microsoft.DotNet.XUnitExtensions;
98

109
namespace Microsoft.Extensions.DataIngestion.Readers.Tests;
1110

1211
/// <summary>
13-
/// This class exists because currently the local copy of <see cref="ConditionalTheoryAttribute"/> can't ignore tests that throw <see cref="SkipTestException"/>.
12+
/// Helper class for checking if MarkItDown is installed.
1413
/// </summary>
15-
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
16-
public class MarkItDownConditionAttribute : Attribute, ITestCondition
14+
public static class MarkItDownCondition
1715
{
1816
internal static readonly Lazy<bool> IsInstalled = new(CanInvokeMarkItDown);
1917

20-
public bool IsMet => IsInstalled.Value;
21-
22-
public string SkipReason => "MarkItDown is not installed or not accessible.";
18+
public static bool IsMarkItDownInstalled => IsInstalled.Value;
2319

2420
private static bool CanInvokeMarkItDown()
2521
{

test/Libraries/Microsoft.Extensions.DataIngestion.Tests/Readers/MarkItDownReaderTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
using System;
55
using System.Linq;
66
using System.Threading.Tasks;
7+
78
using Microsoft.DotNet.XUnitExtensions;
89
using Xunit;
910

1011
namespace Microsoft.Extensions.DataIngestion.Readers.Tests;
1112

12-
[MarkItDownCondition]
1313
public class MarkItDownReaderTests : DocumentReaderConformanceTests
1414
{
1515
protected override IngestionDocumentReader CreateDocumentReader(bool extractImages = false)
16-
=> MarkItDownConditionAttribute.IsInstalled.Value
16+
=> MarkItDownCondition.IsInstalled.Value
1717
? new MarkItDownReader(extractImages: extractImages)
1818
: throw new SkipTestException("MarkItDown is not installed");
1919

@@ -40,7 +40,7 @@ protected override void SimpleAsserts(IngestionDocument document, string source,
4040
// The original purpose of the MarkItDown library was to support text-only LLMs.
4141
// Source: https://github.com/microsoft/markitdown/issues/56#issuecomment-2546357264
4242
// It can extract images, but the support is limited to some formats like docx.
43-
[ConditionalFact]
43+
[ConditionalFact(nameof(MarkItDownCondition.IsMarkItDownInstalled))]
4444
public override Task SupportsImages() => SupportsImagesCore(
4545
new("https://winprotocoldocs-bhdugrdyduf5h2e4.b02.azurefd.net/MC-SQLR/%5bMC-SQLR%5d-240423.docx")); // SQL Server Resolution Protocol.
4646
}

test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/Linux/LinuxResourceHealthCheckTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ public class LinuxResourceHealthCheckTests
141141
},
142142
};
143143

144-
[ConditionalTheory]
144+
[Theory]
145145
[MemberData(nameof(Data))]
146-
[OSSkipCondition(OperatingSystems.Windows | OperatingSystems.MacOSX, SkipReason = "Linux-specific test.")]
146+
[PlatformSpecific(TestPlatforms.Linux)]
147147
public async Task TestCpuAndMemoryChecks_WithMetrics(
148148
HealthStatus expected, double utilization, ulong memoryUsed, ulong totalMemory,
149149
ResourceUsageThresholds cpuThresholds, ResourceUsageThresholds memoryThresholds,

test/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests/ResourceHealthCheckExtensionsTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.Diagnostics.Metrics;
77
using System.Threading.Tasks;
8+
89
using Microsoft.Extensions.Configuration;
910
using Microsoft.Extensions.DependencyInjection;
1011
using Microsoft.Extensions.Diagnostics.ResourceMonitoring;
@@ -19,10 +20,10 @@
1920

2021
namespace Microsoft.Extensions.Diagnostics.HealthChecks.Test;
2122

22-
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Not supported on MacOs.")]
23+
[PlatformSpecific(~TestPlatforms.OSX)]
2324
public class ResourceHealthCheckExtensionsTests
2425
{
25-
[ConditionalFact]
26+
[Fact]
2627
public async Task AddResourceHealthCheck()
2728
{
2829
var dataTracker = new Mock<IResourceMonitor>();
@@ -463,9 +464,9 @@ public void TestNullChecks()
463464
Assert.Throws<ArgumentNullException>(() => ((IHealthChecksBuilder)null!).AddResourceUtilizationHealthCheck((IConfigurationSection)null!));
464465
}
465466

466-
[ConditionalTheory]
467+
[Theory]
467468
[ClassData(typeof(HealthCheckTestData))]
468-
[OSSkipCondition(OperatingSystems.Linux | OperatingSystems.MacOSX, SkipReason = "Windows-specific test.")]
469+
[PlatformSpecific(TestPlatforms.Windows)]
469470
public async Task TestCpuAndMemoryChecks_WithMetrics(
470471
HealthStatus expected, double utilization, ulong memoryUsed, ulong totalMemory,
471472
ResourceUsageThresholds cpuThresholds, ResourceUsageThresholds memoryThresholds,

0 commit comments

Comments
 (0)