diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ccd70be7..0e87585d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -25,7 +25,7 @@ about: Something behaves differently from what is documented **Versions** - `MattLorimor.ProbabilisticDataStructures`: -- Target framework (e.g. net10.0): +- Target framework (e.g. net11.0): - OS: **Which structure?** diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efeb5f55..1e987cb4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,9 +53,13 @@ jobs: - name: Check out uses: actions/checkout@v7 + # global.json's SDK, which builds both frameworks, and a .NET 10 SDK beside it + # for the .NET 10 runtime the net10.0 suite runs on. setup-dotnet installs the + # versions from both inputs. - name: Set up .NET uses: actions/setup-dotnet@v6 with: + dotnet-version: 10.0.x global-json-file: global.json - name: Restore @@ -64,10 +68,13 @@ jobs: - name: Build run: dotnet build --configuration Release --no-restore -warnaserror + # Runs the suite once per target framework, and fails if either run fails. A + # prefix rather than a file name, because each framework writes its own results + # and a fixed name keeps only whichever finished last. - name: Test run: >- dotnet test --configuration Release --no-build - --logger "trx;LogFileName=test-results.trx" + --logger "trx;LogFilePrefix=test-results" --results-directory ${{ github.workspace }}/test-results - name: Upload test results diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2e984ab4..2336a168 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,9 +24,12 @@ jobs: # must be present for the version check below. fetch-depth: 0 + # As in CI: global.json's SDK builds both frameworks, and the .NET 10 SDK beside + # it brings the runtime the net10.0 suite runs on. - name: Set up .NET uses: actions/setup-dotnet@v6 with: + dotnet-version: 10.0.x global-json-file: global.json # A tag that disagrees with VersionPrefix would publish a package whose diff --git a/Benchmarks/Benchmarks.csproj b/Benchmarks/Benchmarks.csproj index 5b5f6158..a0ef0745 100644 --- a/Benchmarks/Benchmarks.csproj +++ b/Benchmarks/Benchmarks.csproj @@ -2,6 +2,9 @@ Exe + net10.0 false diff --git a/CHANGELOG.md b/CHANGELOG.md index 9899fcc8..6b396b2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- **A build for .NET 11 beside the one for .NET 10.** The package carries `lib/net10.0` and + `lib/net11.0`, built from the same source with the same API, and the suite runs on both + frameworks, each on its own runtime, on every CI runner: Linux and Windows on x64 and + arm64, and macOS on arm64. .NET 10 is an LTS release and .NET 11 an STS one, and both + are supported until 2028-11-14, so neither build is dropped for the other. +

+ Each build depends on the `System.IO.Hashing` released with its own .NET: 10.0.15 for + net10.0, and 11.0.0 for net11.0. An application on .NET 10 keeps a dependency on the + 10.0 line, where 6.2.0 had 10.0.11. + - **`ReadOptions`, a memory budget for reading.** Every structure gains `ReadFrom(Stream, ReadOptions)` and `ReadFrom(Stream, Func, ulong>, ReadOptions)`, and `Persistence.FromByteArray` the same two. The budget is the most @@ -752,14 +762,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 by 16 to 440 bytes read as a byte array, measured in a no-GC region; the four kilobytes of slack the read-budget tests allowed had absorbed all of it. The stream `FromByteArray` reads through, 64 bytes, and the read's own budget, 48, were charged - nowhere, and a checksum's state was charged as a small object of 64 bytes where it is 24. + nowhere, and a checksum's state was charged as a small object of 64 bytes where it is 24 + with System.IO.Hashing 10. Most readers made objects they did not charge, their structure's own among them; some made objects only to replace them, and a `MementoFilter` read gathered each run into a list that grew to the longest run in the table. Now a read is charged the stream and the budget once, and a read nested in it neither; a checksum's state is charged what it - allocates; and each reader charges each object it makes where it makes it, at its size - measured on a 64-bit runtime or as a small object where that is larger, with its price - pricing the same charge, so the two still come to the same sum. The objects made only to + allocates with the System.IO.Hashing loaded, 24 bytes with 10 and 32 with 11, whose + `Crc32` holds one field more; and each reader charges each object it makes where it + makes it, at its size measured on a 64-bit runtime or as a small object where that is + larger, with its price pricing the same charge, so the two still come to the same sum. The objects made only to be replaced are no longer made, and a `MementoFilter` run is checked through one view of the table's slots. A read from a stream is charged the stream it did not make, 64 bytes past what it allocates, since nothing tells the two reads apart. Measured as a byte diff --git a/CLAUDE.md b/CLAUDE.md index 781102d6..b0cf6a08 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,7 +1,7 @@ # ProbabilisticDataStructures Probabilistic data structures for C#. Managed IL throughout — no `unsafe`, no pointers, -no hardware intrinsics — targeting `net10.0` with one dependency, `System.IO.Hashing`. +no hardware intrinsics — targeting `net10.0` and `net11.0` with one dependency, `System.IO.Hashing`. ## Read these before writing anything diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5b826621..794baf95 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,6 +53,12 @@ MSBuild thinks is up to date, so an incremental `-warnaserror` build can report on code that will not compile from scratch — which is exactly how a real defect got through several green checks in a row. +The library and the suite target net10.0 and net11.0. Building takes the .NET 11 SDK that +`global.json` names, and testing takes the .NET 10 runtime as well, since the suite runs +once on each. In a tree last restored for other target frameworks, such as one from before +net11.0 was added, `dotnet clean` fails with NETSDK1005 until a restore has run, and the +`&&` above then skips the build: run `dotnet restore` first. + New structures follow the pattern of the existing ones: a class with the same shape of API, span overloads beside the array ones, persistence with a golden fixture, an entry in the README's decision table, a row in its table of how much each one holds and a note diff --git a/ProbabilisticDataStructures/PersistenceFormat.cs b/ProbabilisticDataStructures/PersistenceFormat.cs index e1354435..324606a0 100644 --- a/ProbabilisticDataStructures/PersistenceFormat.cs +++ b/ProbabilisticDataStructures/PersistenceFormat.cs @@ -1941,10 +1941,32 @@ internal static long NestedEnvelopeCost(ulong length) => ReadBudget.Sum( /// /// What a checksum's state allocates: a , which holds its running - /// value, measured at 24 bytes on a 64-bit runtime. It was charged as a small object - /// of 64, 40 more than it takes (#346). + /// value, measured on a 64-bit runtime at 24 bytes with System.IO.Hashing 10 and 32 + /// with 11. It was charged as a small object of 64, 40 more than it takes with 10 + /// (#346). /// - internal const long ChecksumStateCost = 24; + /// + /// The size is the package's, not the runtime's. System.IO.Hashing 11.0.0's + /// adds a field, ParameterSet, beside its running value and + /// its hash length, and one allocates 32 bytes with 11.0.0 and 24 with 10.0.14 and + /// 10.0.15, on .NET 10 and .NET 11 alike: 11.0.0's own net10.0 build on .NET 10 is 32, + /// and 10.0.15 on .NET 11 is 24. Each of this library's target frameworks depends on a + /// different major of the package, but the application decides which one loads, and a + /// .NET 10 application that takes 11.x runs the net10.0 build with the larger state. So + /// the cost is read once from the version of the assembly loaded, not from the + /// framework the library was built for. + /// + internal static readonly long ChecksumStateCost = + ChecksumStateCostFor(typeof(Crc32).Assembly.GetName().Version); + + /// + /// What a allocates with the System.IO.Hashing of + /// , its assembly version: 24 bytes before 11 and 32 from 11 + /// on (). A version that cannot be read is charged the + /// larger, since a read may be charged more than it allocates but never less. + /// + internal static long ChecksumStateCostFor(Version? hashing) => + hashing is null || hashing.Major >= 11 ? 32 : 24; /// /// What a read makes once, around everything it reads, whatever it holds, and a read diff --git a/ProbabilisticDataStructures/ProbabilisticDataStructures.csproj b/ProbabilisticDataStructures/ProbabilisticDataStructures.csproj index 4a3777bb..31db460e 100644 --- a/ProbabilisticDataStructures/ProbabilisticDataStructures.csproj +++ b/ProbabilisticDataStructures/ProbabilisticDataStructures.csproj @@ -1,7 +1,9 @@ - net10.0 + + net10.0;net11.0 true + + + + + diff --git a/README.md b/README.md index 3e0c3b5a..34631e89 100644 --- a/README.md +++ b/README.md @@ -279,7 +279,7 @@ building at the scale it describes, which is the measurement as of commit 426348 dotnet add package MattLorimor.ProbabilisticDataStructures ``` -Requires .NET 10 or later. See [CHANGELOG.md](CHANGELOG.md) for what changed in each +Targets .NET 10 and .NET 11. See [CHANGELOG.md](CHANGELOG.md) for what changed in each release. The package ID carries a prefix, but the assembly and namespace do not: diff --git a/TESTING.md b/TESTING.md index 92b8c185..18cdb942 100644 --- a/TESTING.md +++ b/TESTING.md @@ -580,7 +580,9 @@ file `--out` gets Stryker's JSON and HTML reports, its log, the tests it ran, an `summary.txt`: the mutants by verdict, then every Survived, Timeout and NoCoverage one with its line and mutation. `--jobs` sets how many tests run at once while it finds them, and options after `--` go to Stryker. The settings are `stryker-config.json`'s; -the script adds the scope and the test filter. +the script adds the scope, the test filter and the framework. A sweep is of one +framework's build, net10.0 unless `--framework` names the other: Stryker picks one at +random for a project that targets several, and every sweep recorded here ran on net10.0. Scope every run. Stryker is not part of any build, the whole library generates more than twelve thousand mutants (12,512 at master 7e339df), and the output needs human @@ -697,9 +699,14 @@ Stryker mutator does, so they stay as #179 records them, held by probes at scale the suite; the fourth, `Allocate` without its size check, Stryker does make, and the test #179 added for it kills it. -`mutate.sh` reports a run whose test host crashed as SURVIVED with no count after it, -where a real survivor reads "SURVIVED (all N passed)". Read that as the crash it is, -which is a detection, and confirm it by running the suite with the mutant in. +`mutate.sh` reads the summary of every target framework, since a mutant can fail one +framework's suite and pass the other's, and the last line is whichever finished last. A +mutant either fails is killed, and the verdict says where: "killed (10 tests on net11.0; +all 131 on net10.0 passed)". A real survivor reads "SURVIVED (all N on net10.0, all N on +net11.0 passed)". A run that failed with no failing summary, from a test host that crashed +or a runtime that is not installed, reads "SURVIVED (no failing summary, but dotnet test +exited N; summaries from: ...)". Read a crash as the detection it is, and confirm it by +running the suite with the mutant in. **Before 5.0.0, Stryker and this suite's parallelism did not mix.** The test assembly declares `[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]`, and Stryker @@ -912,9 +919,11 @@ rest of a message survives, as it should, and one that deletes the guard does no room. One that a collection ended is measured again, so measured work must be repeatable and rebuild what it changes before each attempt, and work that cannot get a region fails saying so rather than being counted without one. A room must be one - every runner gives: macOS collects on segments, which refuse a region of more than - 255,637,165 bytes there, where the regions Linux and Windows collect on refuse none - that size, so `NoGCRegion` refuses a larger room on every runner and not only on macOS. + every runner gives under each framework. Under .NET 10 macOS collects on segments, which + refuse a region of more than 255,637,165 bytes there; under .NET 11 it collects on + regions (dotnet/runtime#125416), as Linux and Windows do under both, and regions refuse + none that size. So `NoGCRegion` refuses a larger room on every runner and framework, not + only on macOS under .NET 10: what segments give one region is a room both collectors give. `TestAReadIsMeasuredExactlyWithABackgroundCollectionRunning` starts a background collection before each repeat of that read and asks for the quiet figure, and its guard needs the same read, counted without a region, to come out high, so that a @@ -1051,6 +1060,12 @@ dotnet test -c Release # what CI runs, -warnaserror dotnet run -c Release --project Benchmarks -- study # accuracy studies ``` +The suite runs once for each target framework, net10.0 on the .NET 10 runtime and net11.0 +on .NET 11, so both runtimes have to be installed; `--framework net10.0` runs one. Either +failing fails the run. A framework whose runtime is missing fails it too, with the host's +"You must install or update .NET", and only the exit code says so: the other framework's +summary still reads `Passed!`. + **A clean build is the only build that verifies.** Analyzers do not run on a project MSBuild considers up to date, so a `-warnaserror` build after a small edit can report zero errors on code that does not compile from scratch. A CA2014 — a `stackalloc` diff --git a/TestProbabilisticDataStructures/NoGCRegion.cs b/TestProbabilisticDataStructures/NoGCRegion.cs index 32c8996c..c5432d59 100644 --- a/TestProbabilisticDataStructures/NoGCRegion.cs +++ b/TestProbabilisticDataStructures/NoGCRegion.cs @@ -54,15 +54,23 @@ internal static class NoGCRegion /// /// The largest room every runner the suite runs on gives one region: what a 64-bit - /// workstation collector on segments, the one macOS runs, allows on 16 KiB pages. + /// workstation collector on segments, the one macOS runs under .NET 10, allows on + /// 16 KiB pages. /// /// - /// macOS builds of the runtime collect on segments rather than regions: gcpriv.h - /// defines USE_REGIONS only for a 64-bit host that is not __APPLE__ or - /// __sun, and not for a standalone collector (dotnet/runtime v10.0.14). On - /// segments, gc_heap::prepare_for_no_gc_region (gc.cpp) refuses as too large a - /// room past (soh_segment_size - segment_info_size - eph_gen_starts_size) / 1.05. - /// A workstation collector's segment is INITIAL_ALLOC, 256 MiB on a 64-bit host + /// Under .NET 10, macOS builds of the runtime collect on segments rather than regions: + /// gcpriv.h defines USE_REGIONS only for a 64-bit host that is not + /// __APPLE__ or __sun, and not for a standalone collector (dotnet/runtime + /// v10.0.14). Under .NET 11 macOS collects on regions, as Linux and Windows do: the + /// guard admits HOST_OSX and still excludes the other Apple platforms (gcpriv.h at + /// v11.0.0, from dotnet/runtime#125416, first shipped in 11.0.0-preview.3). The suite + /// runs on both, so the room is the one segments give. That holds under .NET 11 too, + /// where every runner is on regions, and + /// TestTheLargestRoomEveryRunnerGivesIsGiven enters a region of exactly this + /// room on every runner under each framework. On segments, + /// gc_heap::prepare_for_no_gc_region (gc.cpp) refuses as too large a room past + /// (soh_segment_size - segment_info_size - eph_gen_starts_size) / 1.05. A + /// workstation collector's segment is INITIAL_ALLOC, 256 MiB on a 64-bit host /// whatever its processors or memory, unless a hard limit or GCSegmentSize sets /// another (get_valid_segment_size); the segment's own information takes one OS /// page, 16 KiB on Apple silicon; and the generations' starts take two of the smallest diff --git a/TestProbabilisticDataStructures/TestAllocationMeasurement.cs b/TestProbabilisticDataStructures/TestAllocationMeasurement.cs index cb1c7e9d..25f0f1d7 100644 --- a/TestProbabilisticDataStructures/TestAllocationMeasurement.cs +++ b/TestProbabilisticDataStructures/TestAllocationMeasurement.cs @@ -158,7 +158,9 @@ public void TestARoomPastTheLargestEveryRunnerGivesFailsOnEveryRunnerSayingSo() /// /// The largest room is given: work is counted in a region of exactly /// , so the bound refuses no room a runner gives. On - /// macOS, whose collector refuses a room past it, this checks its derivation. + /// macOS under .NET 10, whose collector refuses a room past it, this checks its + /// derivation; under .NET 11, where macOS collects on regions, it checks the bound still + /// holds there. /// [TestMethod] public void TestTheLargestRoomEveryRunnerGivesIsGiven() @@ -176,7 +178,7 @@ public void TestTheDefaultRoomIsOneEveryRunnerGives() { Assert.IsLessThanOrEqualTo(NoGCRegion.Largest, NoGCRegion.Room, $"the default room, {NoGCRegion.Room:N0} bytes, is more than the {NoGCRegion.Largest:N0} " + - "macOS gives one region, so every measurement that takes it is refused there"); + "macOS gives one region under .NET 10, so every measurement that takes it is refused there"); } /// diff --git a/TestProbabilisticDataStructures/TestProbabilisticDataStructures.csproj b/TestProbabilisticDataStructures/TestProbabilisticDataStructures.csproj index d932069f..b0dd8f28 100644 --- a/TestProbabilisticDataStructures/TestProbabilisticDataStructures.csproj +++ b/TestProbabilisticDataStructures/TestProbabilisticDataStructures.csproj @@ -1,7 +1,9 @@  - net10.0 + + net10.0;net11.0 false diff --git a/TestProbabilisticDataStructures/TestReadChargesAreUpperBounds.cs b/TestProbabilisticDataStructures/TestReadChargesAreUpperBounds.cs index 5d7eea84..32163138 100644 --- a/TestProbabilisticDataStructures/TestReadChargesAreUpperBounds.cs +++ b/TestProbabilisticDataStructures/TestReadChargesAreUpperBounds.cs @@ -436,11 +436,15 @@ public void TestWhatEveryReadMakesOnceIsChargedWhatItAllocates() ("the stream a byte array is read through", PersistenceFormat.ByteArrayStreamCost, () => new MemoryStream(bytes, writable: false)), ]; + // The checksum's state is a System.IO.Hashing object, whose size is the package's + // and not the runtime's, so a failure says which one was loaded. + var hashing = typeof(Crc32).Assembly.GetName().Version; foreach (var (what, charged, make) in made) { make(); Assert.AreEqual(charged, TestReadBudget.LeastAllocated(make, Repeats, null), - $"{what} is charged {charged:N0} bytes, and that is not what one allocates"); + $"{what} is charged {charged:N0} bytes, and that is not what one allocates " + + $"(System.IO.Hashing {hashing} loaded, on .NET {Environment.Version})"); } } } diff --git a/global.json b/global.json index 512142d2..e26c590b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.100", + "version": "11.0.100", "rollForward": "latestFeature" } } diff --git a/scripts/mutate.sh b/scripts/mutate.sh index a57598d5..d21dc825 100755 --- a/scripts/mutate.sh +++ b/scripts/mutate.sh @@ -193,24 +193,51 @@ open(path, "w", encoding="utf-8").write(src.replace(old, new)) return 0 fi - local output + local output rc if [ -n "$MUTATION_FILTER" ]; then - output="$(dotnet test -c "$MUTATION_CONFIG" --no-build --filter "$MUTATION_FILTER" 2>&1 | tail -1)" + output="$(dotnet test -c "$MUTATION_CONFIG" --no-build --filter "$MUTATION_FILTER" 2>&1)" else - output="$(dotnet test -c "$MUTATION_CONFIG" --no-build 2>&1 | tail -1)" + output="$(dotnet test -c "$MUTATION_CONFIG" --no-build 2>&1)" fi + rc=$? - local counts - counts="$(echo "$output" | sed -n 's/.*Failed: *\([0-9]*\), Passed: *\([0-9]*\).*/\1 of \1+\2/p')" - if echo "$output" | grep -q "^Failed!"; then - printf ' %-38s killed %s\n' "$name" \ - "$(echo "$output" | sed -n 's/.*Failed: *\([0-9]*\),.*/(\1 tests)/p')" - MUTATION_KILLED=$((MUTATION_KILLED + 1)) - else - printf ' %-38s SURVIVED %s\n' "$name" \ - "$(echo "$output" | sed -n 's/.*Total: *\([0-9]*\).*/(all \1 passed)/p')" - MUTATION_SURVIVED=$((MUTATION_SURVIVED + 1)) - fi + # dotnet test prints a summary for each target framework, "Passed!" or "Failed!" + # and ending in the framework's name, in the order the frameworks finish. Reading + # only the last line called a mutant that one framework's suite catches a survivor + # whenever the other framework finished last. So every summary is read: a mutant is + # killed when any framework's suite fails it, as it fails CI, and survives only when + # the run exited cleanly with every summary a pass. A run that failed with no + # failing summary -- a test host that crashed, a runtime that is not installed -- is + # still counted as surviving, as it always was, but says so, with the exit code and + # the frameworks that did report, so that it cannot be read as a survivor. + local verdict + verdict="$(printf '%s\n' "$output" | awk -v rc="$rc" ' + /^(Passed|Failed)!/ { + tfm = $NF; gsub(/[()]/, "", tfm) + failed = $0; sub(/.*Failed: */, "", failed); sub(/,.*/, "", failed) + total = $0; sub(/.*Total: */, "", total); sub(/,.*/, "", total) + if ($1 == "Failed!") { + killed = killed (killed == "" ? "" : ", ") failed " tests on " tfm + } else { + passed = passed (passed == "" ? "" : ", ") "all " total " on " tfm + } + seen = seen (seen == "" ? "" : ", ") tfm + } + END { + if (killed != "") { + print "killed (" killed (passed == "" ? "" : "; " passed " passed") ")" + } else if (rc == 0 && passed != "") { + print "SURVIVED (" passed " passed)" + } else { + print "SURVIVED (no failing summary, but dotnet test exited " rc \ + "; summaries from: " (seen == "" ? "none" : seen) ")" + } + }')" + printf ' %-38s %s\n' "$name" "$verdict" + case "$verdict" in + killed*) MUTATION_KILLED=$((MUTATION_KILLED + 1)) ;; + *) MUTATION_SURVIVED=$((MUTATION_SURVIVED + 1)) ;; + esac } mutation_done() { diff --git a/scripts/stryker-file.sh b/scripts/stryker-file.sh index 1b07554b..c81ec0f3 100755 --- a/scripts/stryker-file.sh +++ b/scripts/stryker-file.sh @@ -15,6 +15,10 @@ # Default: one per CPU. # --out DIR where the reports go; it must be empty or new. Default: a new # directory under ${TMPDIR:-/tmp}, named when the run ends. +# --framework TFM the target framework whose build is swept. Default: net10.0. One, +# because Stryker picks one at random for a project with several, and +# net10.0 because every sweep recorded before net11.0 was added ran +# there, so a new one stays comparable with them. # -- ... everything after it goes to every Stryker run as it is. # # For each file, // ends up holding Stryker's reports/mutation-report.json and @@ -53,7 +57,7 @@ die() { } usage() { - sed -n '5,24p' "$0" | sed 's/^# \{0,1\}//' >&2 + sed -n '5,28p' "$0" | sed 's/^# \{0,1\}//' >&2 exit 2 } @@ -61,6 +65,7 @@ cpus="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)" concurrency="$cpus" jobs="$cpus" out="" +framework="net10.0" targets=() stryker_args=() @@ -69,6 +74,7 @@ while [ $# -gt 0 ]; do --concurrency) [ $# -ge 2 ] || usage; concurrency="$2"; shift 2 ;; --jobs) [ $# -ge 2 ] || usage; jobs="$2"; shift 2 ;; --out) [ $# -ge 2 ] || usage; out="$2"; shift 2 ;; + --framework) [ $# -ge 2 ] || usage; framework="$2"; shift 2 ;; --) shift; stryker_args=("$@"); break ;; -h|--help) usage ;; -*) die "unknown option $1 (Stryker's own options go after --)" ;; @@ -176,7 +182,12 @@ copy_head "$base" || die "cannot copy HEAD" echo "stryker-file: building and running the suite" (cd "$base" && dotnet build -c Release) > "$out/build.log" 2>&1 \ || die "the commit does not build; see $out/build.log" -(cd "$base" && dotnet test -c Release --no-build --logger "trx;LogFileName=$work/suite.trx") \ +# The framework is checked against what the build wrote, not a list kept here. +[ -d "$base/TestProbabilisticDataStructures/bin/Release/$framework" ] \ + || die "the test project has no $framework build; it has: $(ls "$base/TestProbabilisticDataStructures/bin/Release" | tr '\n' ' ')" +echo "stryker-file: sweeping the $framework build" +(cd "$base" && dotnet test -c Release --no-build --framework "$framework" \ + --logger "trx;LogFileName=$work/suite.trx") \ > "$out/suite.log" 2>&1 \ || die "the suite does not pass; see $out/suite.log" @@ -225,7 +236,7 @@ cat > "$reach/coverage.runsettings" <<'EOF' EOF i=1 while [ "$i" -le "$jobs" ]; do - cp -a "$base/TestProbabilisticDataStructures/bin/Release/net10.0" "$reach/slot$i" \ + cp -a "$base/TestProbabilisticDataStructures/bin/Release/$framework" "$reach/slot$i" \ || die "cannot copy the build output" i=$((i + 1)) done @@ -310,9 +321,9 @@ for t in "${rel[@]}"; do tree="$work/$name" mkdir -p "$dest" copy_head "$tree" || die "cannot copy HEAD for $name" - REACH="$reach" TREE="$tree" TARGET="$t" DEST="$dest" python3 - <<'EOF' || die "cannot write the config for $t" + REACH="$reach" TREE="$tree" TARGET="$t" DEST="$dest" FRAMEWORK="$framework" python3 - <<'EOF' || die "cannot write the config for $t" import os, json, glob -reach, tree, target, dest = (os.environ[k] for k in ("REACH", "TREE", "TARGET", "DEST")) +reach, tree, target, dest, framework = (os.environ[k] for k in ("REACH", "TREE", "TARGET", "DEST", "FRAMEWORK")) for path in glob.glob(os.path.join(tree, "ProbabilisticDataStructures", "**", "*.cs"), recursive=True): if os.path.normpath(os.path.relpath(path, tree)) != os.path.normpath(target): text = open(path, encoding="utf-8-sig").read() @@ -338,6 +349,8 @@ path = os.path.join(tree, "TestProbabilisticDataStructures", "stryker-config.jso config = json.load(open(path)) c = config["stryker-config"] c["mutate"] = ["**/" + os.path.basename(target)] +# The build the tests that reach the file were found in; left out, Stryker picks one. +c["target-framework"] = framework c["test-case-filter"] = "|".join(f"FullyQualifiedName={m}" for m in keep) c["reporters"] = sorted(set(c.get("reporters", [])) | {"json", "html"}) json.dump(config, open(os.path.join(tree, "TestProbabilisticDataStructures", "stryker-file.json"), "w"), indent=2)