Skip to content

Commit b908924

Browse files
committed
ci: fix WindowsOnly test filtering on non-Windows platforms
Problem: - Job names showed ugly filters: "test (ubuntu-latest, & TestCategory!=WindowsOnly)" - WindowsOnly tests were running on Ubuntu/macOS and failing - Two conflicting WindowsOnlyAttribute classes caused namespace shadowing Root cause: - Commit 3c8350b added WindowsOnlyAttribute : CategoryAttribute in TestCategory.cs - This shadowed the existing Utilities/WindowsOnlyAttribute : SkipAttribute - Tests resolved [WindowsOnly] to the CategoryAttribute version (no skip behavior) - The CI workflow was simplified to remove the extra_filter matrix Fix: - Remove Utilities/WindowsOnlyAttribute.cs (eliminates namespace conflict) - Compute filter dynamically in workflow step using $RUNNER_OS - OpenBugs: excluded on all platforms (global) - WindowsOnly: excluded only on non-Windows (conditional) Result: - Clean job names: "test (ubuntu-latest)", "test (windows-latest)", etc. - WindowsOnly tests correctly skipped on Ubuntu/macOS - Single [WindowsOnly] attribute with clear semantics
1 parent 07f908d commit b908924

3 files changed

Lines changed: 18 additions & 28 deletions

File tree

.github/workflows/build-and-release.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ env:
1818
# NU5048: PackageIconUrl deprecated — cosmetic NuGet warning
1919
DOTNET_NOWARN: CS1570%3BCS1571%3BCS1572%3BCS1573%3BCS1574%3BCS1587%3BCS1591%3BCS1711%3BCS1734%3BCS8981%3BNU5048
2020

21-
# Exclude tests by category. Tag tests with [Category("...")] (TUnit) instead of
22-
# adding individual Name!= exclusions here.
23-
# OpenBugs — known-failing bug reproductions (pass when fixed, then remove category)
24-
# WindowsOnly — require GDI+/System.Drawing.Common; auto-skipped on non-Windows via
25-
# runtime platform check in test base class
26-
TEST_FILTER: '/*/*/*/*[Category!=OpenBugs]'
27-
2821
jobs:
2922
test:
3023
strategy:
@@ -50,12 +43,21 @@ jobs:
5043

5144
# NOTE: Test project currently only targets net10.0. See TODO in NumSharp.UnitTest.csproj
5245
# to re-enable net8.0 when TUnit compatibility is resolved.
46+
#
47+
# Test filtering:
48+
# - OpenBugs: excluded on all platforms (known-failing bug reproductions)
49+
# - WindowsOnly: excluded on non-Windows (require GDI+/System.Drawing.Common)
5350
- name: Test (net10.0)
5451
shell: bash
5552
run: |
53+
FILTER='/*/*/*/*[Category!=OpenBugs'
54+
if [[ "$RUNNER_OS" != "Windows" ]]; then
55+
FILTER="$FILTER & Category!=WindowsOnly"
56+
fi
57+
FILTER="$FILTER]"
5658
dotnet run --project test/NumSharp.UnitTest/NumSharp.UnitTest.csproj \
5759
--configuration Release --no-build --framework net10.0 \
58-
-- --treenode-filter "${{ env.TEST_FILTER }}" --report-trx
60+
-- --treenode-filter "$FILTER" --report-trx
5961
6062
- name: Upload Test Results
6163
uses: actions/upload-artifact@v4

test/NumSharp.UnitTest/TestCategory.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,14 @@ public static class TestCategory
128128
///
129129
/// <para><b>CI Behavior:</b></para>
130130
/// <para>
131-
/// Should be excluded on non-Windows runners. Can use runtime platform checks
132-
/// in test base class to auto-skip, or filter with:
133-
/// <c>--treenode-filter "/*/*/*/*[Category!=WindowsOnly]"</c>
131+
/// Automatically excluded on non-Windows runners (Ubuntu, macOS) via CI workflow.
132+
/// The workflow computes the filter at runtime based on <c>RUNNER_OS</c>.
133+
/// </para>
134+
///
135+
/// <para><b>Local Development:</b></para>
136+
/// <para>
137+
/// When running tests locally on non-Windows, use the filter:
138+
/// <c>dotnet test -- --treenode-filter "/*/*/*/*[Category!=WindowsOnly]"</c>
134139
/// </para>
135140
///
136141
/// <para><b>Note:</b></para>

test/NumSharp.UnitTest/Utilities/WindowsOnlyAttribute.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)