Skip to content

Commit 8e08102

Browse files
Tests: count the channel rig's executes atomically (#167)
The every-rung channel test starts two feeds at once, so two readers can be created on different threads. The rig counted them with a plain increment, which can lose one: CI saw 4 of 5 on master. The count is now an Interlocked increment read with Volatile.Read. The library is unchanged. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 36947db commit 8e08102

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • Tests/Open.Database.Extensions.Core.Tests/TestHelpers

‎Tests/Open.Database.Extensions.Core.Tests/TestHelpers/ChannelRig.cs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,12 @@ internal sealed class ChannelRig
122122

123123
/// <summary>
124124
/// How many readers were created: how often the command ran.
125+
/// Counted atomically: feeds that start at once run on
126+
/// different threads.
125127
/// </summary>
126-
public int Executes { get; private set; }
128+
public int Executes => Volatile.Read(ref _executes);
129+
130+
int _executes;
127131

128132
/// <summary>Only the Command view has a connection.</summary>
129133
public FakeDbConnection? Connection { get; private set; }
@@ -198,7 +202,7 @@ public static ChannelRig Create(
198202
var rig = new ChannelRig();
199203
DbDataReader Make()
200204
{
201-
rig.Executes++;
205+
Interlocked.Increment(ref rig._executes);
202206
return rig.Reader = make();
203207
}
204208

0 commit comments

Comments
 (0)