Tests: C# refusal lines carry their source and the gate counts them distinct

The console logger repeated each line, so a raw count was 28 for 14 refusals. Names now prints the source (committed or live) and the gate counts distinct 'OLD-READER <runtime> refused <label>' lines.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-27 09:35:23 +01:00
commit fc74cf6f41
2 changed files with 12 additions and 12 deletions

View file

@ -88,10 +88,10 @@ namespace GameCult.Caching.Tests
.Select(file => Path.GetRelativePath(root, file) + " " + Convert.ToHexString(SHA256.HashData(File.ReadAllBytes(file))))
.ToArray();
private static void Names(Exception? error, string format, string what)
private static void Names(Exception? error, string format, string what, string source)
{
Assert.That(error, Is.Not.Null, what);
TestContext.Out.WriteLine($"OLD-READER csharp refused {what}: " + error!.Message);
TestContext.Out.WriteLine($"OLD-READER csharp refused {what} [{source}]: " + error!.Message);
Assert.That(error.ToString(), Does.Contain(format), what);
}
@ -101,7 +101,7 @@ namespace GameCult.Caching.Tests
var file = CopySingle(source, "attach.cc");
var before = File.ReadAllBytes(file);
using var cache = new CultCache();
Names(Assert.Catch(() => cache.AddBackingStore(new SingleFileMessagePackBackingStore(file))), "cultcache.store.v3", "attach");
Names(Assert.Catch(() => cache.AddBackingStore(new SingleFileMessagePackBackingStore(file))), "cultcache.store.v3", "attach", source);
Assert.That(File.ReadAllBytes(file), Is.EqualTo(before));
}
@ -111,7 +111,7 @@ namespace GameCult.Caching.Tests
var file = CopySingle(source, "detached.cc");
var before = File.ReadAllBytes(file);
var store = new SingleFileMessagePackBackingStore(file);
Names(Assert.Catch(() => store.PushAll()), "cultcache.store.v3", "PushAll of a detached store");
Names(Assert.Catch(() => store.PushAll()), "cultcache.store.v3", "PushAll of a detached store", source);
Assert.That(File.ReadAllBytes(file), Is.EqualTo(before));
}
@ -126,9 +126,9 @@ namespace GameCult.Caching.Tests
File.Copy(Path.Combine(SourceRoot(source), SingleName), file, overwrite: true);
var before = File.ReadAllBytes(file);
Names(Assert.Catch(() => cache.FlushAllBackingStores()), "cultcache.store.v3", "flush after a swap");
Names(Assert.Catch(() => cache.FlushAllBackingStores()), "cultcache.store.v3", "flush after a swap", source);
Assert.That(File.ReadAllBytes(file), Is.EqualTo(before));
Names(Assert.Catch(() => store.PushAll()), "cultcache.store.v3", "PushAll after a swap");
Names(Assert.Catch(() => store.PushAll()), "cultcache.store.v3", "PushAll after a swap", source);
Assert.That(File.ReadAllBytes(file), Is.EqualTo(before));
}
@ -138,7 +138,7 @@ namespace GameCult.Caching.Tests
var manifest = CopyDirectory(source, "attach-directory");
var before = Tree(Path.GetDirectoryName(manifest)!);
using var cache = new CultCache();
Names(Assert.Catch(() => cache.AddBackingStore(new DirectoryMessagePackBackingStore(manifest))), "cultcache.store.v5", "directory attach");
Names(Assert.Catch(() => cache.AddBackingStore(new DirectoryMessagePackBackingStore(manifest))), "cultcache.store.v5", "directory attach", source);
Assert.That(Tree(Path.GetDirectoryName(manifest)!), Is.EqualTo(before));
}
@ -155,9 +155,9 @@ namespace GameCult.Caching.Tests
CopyTree(Path.Combine(SourceRoot(source), DirectoryName), root);
var before = Tree(root);
Names(Assert.Catch(() => cache.FlushAllBackingStores()), "cultcache.store.v5", "directory flush after a swap");
Names(Assert.Catch(() => cache.FlushAllBackingStores()), "cultcache.store.v5", "directory flush after a swap", source);
Assert.That(Tree(root), Is.EqualTo(before));
Names(Assert.Catch(() => store.PushAll()), "cultcache.store.v5", "directory PushAll after a swap");
Names(Assert.Catch(() => store.PushAll()), "cultcache.store.v5", "directory PushAll after a swap", source);
Assert.That(Tree(root), Is.EqualTo(before));
}
}

View file

@ -142,8 +142,8 @@ trx_passed() {
}
trx_unpassed() { if [ -f "$1" ]; then tr '\n' ' ' < "$1" | grep -o "<UnitTestResult [^>]*" | grep -v "outcome=\"Passed\"" | grep -o "testName=\"[^\"]*\" [^>]*outcome=\"[A-Za-z]*\"" || true; fi; }
# Refusal lines printed for runtime $2 in a log or, for C#, in the TRX (the console logger repeats each test's output in its summary, the TRX holds it once).
refused_lines() { { grep -o "OLD-READER $2 refused " "$1" || true; } | wc -l | tr -d " "; }
# Distinct refusal lines printed for runtime $2 (C# labels carry the source, so a case that ran twice prints two lines; the console logger and the TRX repeat each line, which sort -u folds).
refused_lines() { { grep -o "OLD-READER $2 refused [^:]*" "$1" || true; } | sort -u | wc -l | tr -d " "; }
# Python's runner says "Ran N tests" even when some were skipped or expected to fail; those forms are not passes.
python_unrun() { grep -E '(skipped|expected failures|unexpected successes)=' "$1" || true; }
@ -183,7 +183,7 @@ gate() {
probe_staged csharp 2>&1 | tee "$out/reader.log" || failures+=" 2.0.1-reader"
expect 2.0.1-reader "$EXPECT_READER_GATE+$EXPECT_READER_REFLIST" "$(trx_passed "$trx/reader.trx" OldReaderGateProbe)+$(trx_passed "$trx/reader.trx" OldReaderRefListProbe)"
unpassed 2.0.1-reader "$trx/reader.trx"
refused csharp "$EXPECT_REFUSED_CSHARP" "$trx/reader.trx" 2.0.1-reader
refused csharp "$EXPECT_REFUSED_CSHARP" "$out/reader.log" 2.0.1-reader
CULTLIB_GATE_OLD_STORE="$out/v1-0-60-ref-list.cc" dotnet test tests/GameCult.Caching.Tests --filter "FullyQualifiedName~RefListDriftTests.A_1_0_60_Written_Store_Opens_Like_2_0_1" --logger "console;verbosity=detailed" --logger "trx;LogFileName=head.trx" --results-directory "$trx" 2>&1 | tee "$out/head.log" || failures+=" head-ref-list"
expect head-ref-list "$EXPECT_HEAD_REFLIST" "$(trx_passed "$trx/head.trx" RefListDriftTests)"
unpassed head-ref-list "$trx/head.trx"