Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into restore_env_variabl…
Browse files Browse the repository at this point in the history
…e_controls
  • Loading branch information
dupdob committed Nov 24, 2024
2 parents f89d546 + f3d18d2 commit ac908c6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
17 changes: 10 additions & 7 deletions src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,20 +542,20 @@ private static StringBuilder BuildReferenceChoice(IEnumerable<string> projectRef

private sealed class DynamicEnumerableQueue<T>
{
private readonly Queue<T> _queue;
private readonly HashSet<T> _cache;
private readonly ConcurrentQueue<T> _queue;
private readonly ConcurrentDictionary<T, bool> _cache;

public DynamicEnumerableQueue(IEnumerable<T> init)
{
_cache = [.. init];
_queue = new Queue<T>(_cache);
_cache = new(init.ToDictionary(x => x, x => true));
_queue = new (_cache.Keys);
}

public bool Empty => _queue.Count == 0;
public bool Empty => _queue.IsEmpty;

public void Add(T entry)
{
if (!_cache.Add(entry))
if (!_cache.TryAdd(entry, true))
{
return;
}
Expand All @@ -566,7 +566,10 @@ public IEnumerable<T> Consume()
{
while (_queue.Count > 0)
{
yield return _queue.Dequeue();
if (_queue.TryDequeue(out var entry))
{
yield return entry;
}
}
}
}
Expand Down
15 changes: 11 additions & 4 deletions src/Stryker.Core/Stryker.Core/InjectedHelpers/MutantControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,21 @@ public static bool IsActive(int id)
#pragma warning disable CS8600
// get the environment variable storign the mutation id
string environmentVariableName = System.Environment.GetEnvironmentVariable("STRYKER_CONTROL_VAR");
string environmentVariable = System.Environment.GetEnvironmentVariable(environmentVariableName);
if (string.IsNullOrEmpty(environmentVariable))
if (environmentVariableName != null)
{
ActiveMutant = -1;
string environmentVariable = System.Environment.GetEnvironmentVariable(environmentVariableName);
if (string.IsNullOrEmpty(environmentVariable))
{
ActiveMutant = -1;
}
else
{
ActiveMutant = int.Parse(environmentVariable);
}
}
else
{
ActiveMutant = int.Parse(environmentVariable);
ActiveMutant = -1;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Stryker.Core/Stryker.Core/libman.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"defaultProvider": "jsdelivr",
"libraries": [
{
"library": "mutation-testing-elements@3.3.0",
"library": "mutation-testing-elements@3.4.0",
"files": [
"dist/mutation-test-elements.js"
],
Expand Down

0 comments on commit ac908c6

Please sign in to comment.