Skip to content

Commit d7d16bf

Browse files
Make a skipped test impossible to write
`MEOS.NET.Tests/BannedSymbols.txt` names every construct MSTest offers for stopping a test from asserting — the `[Ignore]` attribute and the three `Assert.Inconclusive` overloads — and `RS0030` is an error in the test project, so each one fails the build rather than reaching a reviewer, a log or a count. A skipped test asserts nothing and reads as a pass in the conclusion, which is why the construct is refused at the compiler rather than tallied afterwards. Deleting a test is then the only remaining way to stop running it, and that leaves no skip behind. What moves is the total, so the workflow reads the run through `MobilityDB/MEOS-API/.github/actions/check-test-outcome` against a floor of 67: the same rules every other binding in the ecosystem is held to, from the one runnable definition, so the CI answer and the answer a developer gets by hand cannot differ. The run the floor is taken from collects the whole suite — the snapshot step above it narrows with `--filter` deliberately and no count is read from that one. Four refuters, each measured. `[Ignore("refuter")]` on a test takes `error RS0030: The symbol 'IgnoreAttribute' is banned in this project`, and `Assert.Inconclusive("refuter")` in a body takes the same error naming `Assert.Inconclusive(string?)`; both read `Build FAILED`. Against the suite's own log the guard reads `total=67 skipped=0 floor=67` and passes, while a floor of 68 is refused as a shrinking suite and a log whose summary carries `Skipped: 1` is refused as a skip. Without all four the pair would be configuration rather than enforcement. The suite passes 67 of 67 with none skipped, and the build takes 0 warnings.
1 parent 300e7e1 commit d7d16bf

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,25 @@ jobs:
5353
- name: Build solution
5454
run: dotnet build MEOS.NET.sln -c Release
5555

56+
# No --filter here: this run is the one the floor below is read from, so it
57+
# collects the whole suite. The snapshot step above narrows deliberately and
58+
# its result is not what any count is taken from.
5659
- name: Run tests
57-
run: dotnet test MEOS.NET.sln -c Release --no-build
60+
run: dotnet test MEOS.NET.sln -c Release --no-build 2>&1 | tee test.log
5861
env:
5962
LD_LIBRARY_PATH: ${{ steps.provision.outputs.libmeos-prefix }}/lib
6063

64+
# A skip is already impossible to WRITE — MEOS.NET.Tests/BannedSymbols.txt
65+
# makes [Ignore] and Assert.Inconclusive compile errors. Deleting a test is
66+
# the remaining way to stop running it, and that leaves no skip behind, so
67+
# the total carries a floor. Raise it when the suite grows; lowering it is a
68+
# deliberate act belonging to the commit that removes the tests.
69+
- name: Refuse a skipped test and a shrinking suite
70+
uses: MobilityDB/MEOS-API/.github/actions/check-test-outcome@master
71+
with:
72+
log: test.log
73+
min-tests: "67"
74+
6175
- name: Smoke-test the FFI
6276
run: dotnet run --project ExampleApp/ExampleApp.csproj -c Release --no-build
6377
env:

‎MEOS.NET.Tests/BannedSymbols.txt‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; Every way MSTest lets a test stop asserting while the run still reports success.
2+
; BannedApiAnalyzers resolves each entry to a symbol and RS0030 is an ERROR here, so a
3+
; skip does not reach a reviewer, a CI log or a floor — it fails to compile.
4+
;
5+
; A skipped test asserts nothing and reads as a pass in the conclusion, which is the
6+
; whole reason the construct is banned rather than merely counted. Deleting a test is
7+
; then the only remaining way to stop running it, and that moves the total, which the
8+
; floor in the workflow refuses.
9+
;
10+
; Format: <documentation-comment ID>;<message shown at the error>.
11+
T:Microsoft.VisualStudio.TestTools.UnitTesting.IgnoreAttribute;A test that does not run asserts nothing. Fix or delete the test — the suite carries no skips.
12+
M:Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Inconclusive;Inconclusive reports as skipped and reads as a pass. Assert the real outcome, or delete the test.
13+
M:Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Inconclusive(System.String);Inconclusive reports as skipped and reads as a pass. Assert the real outcome, or delete the test.
14+
M:Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Inconclusive(System.String,System.Object[]);Inconclusive reports as skipped and reads as a pass. Assert the real outcome, or delete the test.

‎MEOS.NET.Tests/MEOS.NET.Tests.csproj‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,28 @@
77

88
<IsPackable>false</IsPackable>
99
<IsTestProject>true</IsTestProject>
10+
11+
<!-- A banned symbol is an ERROR, not a warning: a warning is a thing a build
12+
prints and a reader scrolls past, so it leaves the skip reachable. RS0030
13+
is the diagnostic BannedApiAnalyzers raises for every entry in
14+
BannedSymbols.txt. -->
15+
<WarningsAsErrors>$(WarningsAsErrors);RS0030</WarningsAsErrors>
1016
</PropertyGroup>
1117

1218
<ItemGroup>
1319
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
1420
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
1521
<PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
1622
<PackageReference Include="coverlet.collector" Version="6.0.2" />
23+
<!-- Resolves BannedSymbols.txt and refuses every construct it names. -->
24+
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4">
25+
<PrivateAssets>all</PrivateAssets>
26+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
27+
</PackageReference>
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<AdditionalFiles Include="BannedSymbols.txt" />
1732
</ItemGroup>
1833

1934
<ItemGroup>

0 commit comments

Comments
 (0)