Skip to content

Commit e5ae467

Browse files
committed
Refactored for clarity + disable undesired mutations in mutation testing.
Disabled mutations won't be effective until Stryker 1.0.0 is released.
1 parent ca13bd1 commit e5ae467

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

codecov.yml .github/codecov.yml

File renamed without changes.

.github/shared.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ definitions:
4343
mutation-test: &mutation-test
4444
name: Mutation Test
4545
run: |
46-
dotnet tool install --global dotnet-stryker --version 0.22.0
46+
dotnet tool install --global dotnet-stryker
4747
cd tests/UnitTests
4848
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
4949
dotnet stryker \

.github/workflows/continuous-delivery.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777

7878
- name: Mutation Test
7979
run: |
80-
dotnet tool install --global dotnet-stryker --version 0.22.0
80+
dotnet tool install --global dotnet-stryker
8181
cd tests/UnitTests
8282
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
8383
dotnet stryker \

.github/workflows/continuous-integration.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777

7878
- name: Mutation Test
7979
run: |
80-
dotnet tool install --global dotnet-stryker --version 0.22.0
80+
dotnet tool install --global dotnet-stryker
8181
cd tests/UnitTests
8282
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then
8383
dotnet stryker \

src/Verlite.Core/HeightCalculator.cs

+15-6
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private static IEnumerable<TaggedVersion> SelectWhereSemver(
5858
if (head is null)
5959
return (1, null);
6060

61+
// Stryker disable once all: used for logging only
6162
return await FromCommit(
6263
commit: head.Value,
6364
commitDescriptor: "HEAD",
@@ -103,7 +104,9 @@ public FromCommitOptions(
103104
{
104105
var (current, height, rootDescriptor, heightSinceBranch) = toVisit.Pop();
105106

107+
// Stryker disable all: used for logging only
106108
var descriptor = heightSinceBranch == 0 ? rootDescriptor : $"{rootDescriptor}~{heightSinceBranch}";
109+
// Stryker restore all
107110

108111
// already visited in an ultimately prior parent
109112
if (!visited.Add(current))
@@ -156,17 +159,23 @@ public FromCommitOptions(
156159
}
157160
else
158161
{
159-
for (int i = parents.Count; i-- > 0;)
162+
// commits to visit must be added in the reverse order, so the earlier parents are visited first
163+
for (int i = parents.Count; i --> 0;)
160164
{
161-
if (i == 0)
162-
toVisit.Push((parents[i], height + 1, rootDescriptor, heightSinceBranch + 1));
163-
else
164-
toVisit.Push((parents[i], height + 1, $"{rootDescriptor}^{i + 1}", 0));
165+
var parent = parents[i];
166+
var parentHeight = height + 1;
167+
// Stryker disable all: used for logging only
168+
var isDiverging = i == 0;
169+
var parentDescriptor = isDiverging ? $"{rootDescriptor}^{i + 1}" : rootDescriptor;
170+
var parentHeightSinceBranch = isDiverging ? 0 : heightSinceBranch + 1;
171+
// Stryker restore all
172+
173+
toVisit.Push((parents[i], height + 1, parentDescriptor, parentHeightSinceBranch));
165174
}
166175
}
167176
}
168177

169-
Debug.Assert(candidates.Count > 0);
178+
Debug.Assert(candidates.Count != 0);
170179

171180
return candidates
172181
.OrderByDescending(x => x.version is not null)

0 commit comments

Comments
 (0)