Skip to content

Commit

Permalink
Tidying up
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Aug 12, 2024
1 parent 25870a6 commit 89877b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
8 changes: 3 additions & 5 deletions AltCover.Recorder.Tests/Recorder.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

[<Test>]
let OnlyNewIdPairShouldBeSampled () =
Expand All @@ -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")
Expand Down Expand Up @@ -649,6 +645,7 @@ module AltCoverTests =
lock handle (fun () ->
try
Instance.I.visits <- null
Instance.Strategy <- Sampling.All
let key = " "

let path =
Expand Down Expand Up @@ -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 "<="
Expand Down
7 changes: 2 additions & 5 deletions AltCover.Recorder/Recorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) };
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions AltCover.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 89877b9

Please sign in to comment.