Enable parallel test execution, mark timing-sensitive test as non-parallel, and use Interlocked for TaskId

This commit is contained in:
Stone_Red
2026-03-05 23:39:44 +01:00
parent 38e8ac9b13
commit 491eedf77e
3 changed files with 6 additions and 1 deletions
+3
View File
@@ -0,0 +1,3 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)]
@@ -76,6 +76,7 @@ public class ConsoleStatementsTests
} }
[TestMethod] [TestMethod]
[DoNotParallelize] // timing-sensitive: relies on Thread.Sleep to let the interpreter reach %read_key
public void ReadKeyCanBeInterruptedByStopTest() public void ReadKeyCanBeInterruptedByStopTest()
{ {
YesNtInterpreter interpreter = new YesNtInterpreter(); YesNtInterpreter interpreter = new YesNtInterpreter();
@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using YesNt.Interpreter.Utilities; using YesNt.Interpreter.Utilities;
@@ -191,7 +192,7 @@ internal sealed class RuntimeInformation
IsLocalSearch = false; IsLocalSearch = false;
LineNumber = 0; LineNumber = 0;
#pragma warning disable S2696 // internalTaskId is a shared counter intentionally incremented by each Reset call #pragma warning disable S2696 // internalTaskId is a shared counter intentionally incremented by each Reset call
TaskId = ++internalTaskId; TaskId = Interlocked.Increment(ref internalTaskId);
#pragma warning restore S2696 #pragma warning restore S2696
} }