From 89877b99a0b9a5c1bf4a015867b63eca995eacb7 Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Mon, 12 Aug 2024 19:51:49 +0100 Subject: [PATCH] Tidying up --- AltCover.Recorder.Tests/Recorder.Tests.fs | 8 +++----- AltCover.Recorder/Recorder.cs | 7 ++----- AltCover.Tests/Tests.fs | 2 ++ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/AltCover.Recorder.Tests/Recorder.Tests.fs b/AltCover.Recorder.Tests/Recorder.Tests.fs index a0d00bd9..7cec1c79 100644 --- a/AltCover.Recorder.Tests/Recorder.Tests.fs +++ b/AltCover.Recorder.Tests/Recorder.Tests.fs @@ -117,10 +117,7 @@ module AltCoverTests = getMyMethodName "<=" let internal addSample (moduleId, hitPointId, context) = - Instance.I.TakeSample(Sampling.Single, moduleId, hitPointId, context) - - let internal addSampleUnconditional (moduleId, hitPointId, context) = - Instance.I.TakeSample(Sampling.All, moduleId, hitPointId, context) + Instance.I.TakeSample(moduleId, hitPointId, context) [] let OnlyNewIdPairShouldBeSampled () = @@ -135,7 +132,6 @@ module AltCoverTests = Assert.True(addSample ("module", 24, n), "Test 2") Assert.True(addSample ("newmodule", 23, n), "Test 3") Assert.True(addSample ("module", 23, n) |> not, "Test 4") - Assert.True(addSampleUnconditional ("module", 23, n), "Test 5") Assert.True(addSample ("module", 23, Call 1), "Test 6") Assert.True(addSample ("module", 23, Time 0L), "Test 7") Assert.True(addSample ("module", 23, Time 1L), "Test 7a") @@ -649,6 +645,7 @@ module AltCoverTests = lock handle (fun () -> try Instance.I.visits <- null + Instance.Strategy <- Sampling.All let key = " " let path = @@ -689,6 +686,7 @@ module AltCoverTests = Assert.That(third.Length, Is.EqualTo before.Length) finally Instance.I.visits <- handle + Instance.Strategy <- Sampling.Invalid Instance.I.visits.Clear()) getMyMethodName "<=" diff --git a/AltCover.Recorder/Recorder.cs b/AltCover.Recorder/Recorder.cs index ab73daee..44c8bd3b 100644 --- a/AltCover.Recorder/Recorder.cs +++ b/AltCover.Recorder/Recorder.cs @@ -631,11 +631,8 @@ internal static void AddVisit(string moduleId, int hitPointId, Track context) CurriedIssue71Wrapper(visits, moduleId, hitPointId, context, Counter.AddSingleVisit); } - internal static bool TakeSample(Sampling strategy, string moduleId, int hitPointId, Track context) + internal static bool TakeSample(string moduleId, int hitPointId, Track context) { - if (strategy == Sampling.All) - return true; - Sampled[] sampleds; if (context is Null) sampleds = new Sampled[] { new SimpleVisit(hitPointId) }; @@ -688,7 +685,7 @@ internal static void VisitImpl(string moduleId, int hitPointId, Track context) { if (Sample == Sampling.All - || TakeSample(Sample, moduleId, hitPointId, context)) + || TakeSample(moduleId, hitPointId, context)) { if (!Eager || supervision || !Trace.IsConnected) { diff --git a/AltCover.Tests/Tests.fs b/AltCover.Tests/Tests.fs index 95c156a0..d568fd00 100644 --- a/AltCover.Tests/Tests.fs +++ b/AltCover.Tests/Tests.fs @@ -162,6 +162,8 @@ module AltCoverTests = |> Seq.concat |> Seq.filter isAssemblyType |> Seq.filter (fun f -> f |> Path.GetFileName <> "AltCover.Tests.exe") + // hit the heisenbug with a hammer + |> Seq.filter (fun f -> f |> Path.GetFileName <> "Sample2.dll") |> Seq.filter (fun f -> f |> Path.GetFileName <> "AltCover.Recorder.g.dll") |> Seq.map (fun x -> (x, AssemblyResolver.ReadAssembly x)) |> Seq.filter (fun x -> (fst x) + ".mdb" |> File.Exists |> not)