diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index 680710735..33cc1ae3e 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
- "version": "5.3.0",
+ "version": "5.3.6",
"commands": [
"reportgenerator"
],
@@ -38,7 +38,7 @@
"rollForward": false
},
"nbgv": {
- "version": "3.6.133",
+ "version": "3.6.139",
"commands": [
"nbgv"
],
diff --git a/AltCover.Avalonia/AltCover.Avalonia.fsproj b/AltCover.Avalonia/AltCover.Avalonia.fsproj
index f879efc91..2575da3b2 100644
--- a/AltCover.Avalonia/AltCover.Avalonia.fsproj
+++ b/AltCover.Avalonia/AltCover.Avalonia.fsproj
@@ -10,6 +10,7 @@
AVALONIA;$(TOGGLE)
True
$(ProjectDir)../AltCover.Visualizer/Resource.res
+ NU1902,NU1903,NU1904
diff --git a/AltCover.Fake.DotNet.Testing.AltCover/AltCover.Fake.DotNet.Testing.AltCover.fsproj b/AltCover.Fake.DotNet.Testing.AltCover/AltCover.Fake.DotNet.Testing.AltCover.fsproj
index 31bbe7005..9bc58f23b 100644
--- a/AltCover.Fake.DotNet.Testing.AltCover/AltCover.Fake.DotNet.Testing.AltCover.fsproj
+++ b/AltCover.Fake.DotNet.Testing.AltCover/AltCover.Fake.DotNet.Testing.AltCover.fsproj
@@ -7,7 +7,7 @@
NoCanonicalDirectories;FAKEAPI
MSB3277;MSB3245
- NU1701;NU1605
+ NU1701;NU1605;NU1902,NU1903,NU1904
diff --git a/AltCover.Fake/AltCover.Fake.fsproj b/AltCover.Fake/AltCover.Fake.fsproj
index 6f2aba8e3..f5f6e1ed3 100644
--- a/AltCover.Fake/AltCover.Fake.fsproj
+++ b/AltCover.Fake/AltCover.Fake.fsproj
@@ -5,7 +5,7 @@
AltCover.Fake
AltCover.Fake
RUNNER
- NU1701;NU1605
+ NU1701;NU1605;NU1902,NU1903,NU1904
diff --git a/AltCover.Recorder.Tests/Adapter.cs b/AltCover.Recorder.Tests/Adapter.cs
deleted file mode 100644
index e69de29bb..000000000
diff --git a/AltCover.Recorder.Tests/Adapter.fs b/AltCover.Recorder.Tests/Adapter.fs
deleted file mode 100644
index 750cd1106..000000000
--- a/AltCover.Recorder.Tests/Adapter.fs
+++ /dev/null
@@ -1,202 +0,0 @@
-namespace AltCover.Recorder
-
-open System.Collections.Generic
-
-#if DEBUG
-[]
-module Adapter =
- let DoPause () = Instance.I.doPause
- let DoResume () = Instance.I.doResume
- let DoUnload () = Instance.I.doUnload
- let DoExit () = Instance.I.doExit
-
- let VisitsClear () =
- Instance.I.Clear()
- Counter.branchVisits <- 0L
- Counter.totalVisits <- 0L
-
- let SamplesClear () =
- Instance.I.samples <- Instance.I.MakeSamples()
-
- let private reset () =
- Instance.I.isRunner <- false
- VisitsClear()
- SamplesClear()
-
- let ModuleReset (m: string array) =
- Instance.Modules <- m
- reset ()
-
- let HardReset () =
- Instance.Modules <- [| System.String.Empty |]
- reset ()
-
- let internal prepareName name =
- if name |> Instance.I.visits.ContainsKey |> not then
- let entry = Dictionary()
- Instance.I.visits.Add(name, entry)
-
- let internal init (n, l) =
- let tmp = PointVisit.Create()
- tmp.Count <- n
-
- tmp.Tracks.AddRange l
- tmp
-
- let VisitsAdd (name, line, number) =
- prepareName name
- let v = init (number, [])
- Instance.I.visits.[name].Add(line, v)
-
- let VisitsAddTrack (name, line, number) =
- prepareName name
- let v1 = init (number, [ Call 17; Call 42 ])
- Instance.I.visits.[name].Add(line, v1)
-
- let v2 =
- init (
- (number + 1L),
- [ Time(17L)
- Both(Pair.Create(42L, 23)) ]
- )
-
- Instance.I.visits.[name].Add(line + 1, v2)
-
- let VisitsSeq () = Instance.I.visits |> Seq.cast
-
- let VisitsEntrySeq key =
- Instance.I.visits.[key] |> Seq.cast
-
- let VisitCount (key, key2) = (Instance.I.visits.[key].[key2]).Count
- let Lock = Instance.I.visits :> obj
-
- let VisitImplNone (moduleId, hitPointId) =
- Instance.I.VisitImpl(moduleId, hitPointId, Null())
-
- let VisitImplMethod (moduleId, hitPointId, mId) =
- Instance.I.VisitImpl(moduleId, hitPointId, (Call mId))
-
- 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)
-
- let internal newBoth (time, call) = Both(Pair.Create(time, call))
-
- let internal asCall track = Call track
- let internal time at = Time at
-
- let internal untime (at: Track) =
- let r = List()
-
- match at with
- | :? Time as t -> r.Add(t.Value)
- | _ -> ()
-
- r
-
- let internal asNull () = new Null() :> Track
- let internal table t = Table t :> Track
-
- let internal untable t =
- let r = List()
-
- let n, p, (t': Track) = t
-
- match t' with
- | :? Table as d ->
- r.Add(n)
- r.Add(p)
- r.Add(d)
- | _ -> ()
-
- r
-
- let internal doFlush (visits, format, report, output) =
- let output' =
- if System.String.IsNullOrEmpty output then
- null
- else
- output
-
- Counter.DoFlushFile(ignore, (fun _ _ -> ()), true, visits, format, report, output')
-
- let internal updateReport (counts, format, coverageFile, outputFile) =
- Counter.I.UpdateReport(
- ignore,
- (fun _ _ -> ()),
- true,
- counts,
- format,
- coverageFile,
- outputFile
- )
-
- let internal payloadSelector x = Instance.I.PayloadSelector(fun _ -> x)
-
- let internal payloadControl (x, y) =
- Instance.I.PayloadControl((fun _ -> x), (fun _ -> y))
-
- let internal payloadSelection (x, y, z) =
- Instance.I.PayloadSelection((fun _ -> x), (fun _ -> y), (fun _ -> z))
-
- let internal makeNullTrace name = Tracer.Create(name)
-
- let internal makeStreamTrace s1 =
- let mutable t = Tracer.Create(null)
- // fsharplint:disable-next-line RedundantNewKeyword
- t.Stream <- new System.IO.MemoryStream()
- // fsharplint:disable-next-line RedundantNewKeyword
- t.Formatter <- new System.IO.BinaryWriter(s1)
- t.Runner <- true
- t.Definitive <- false
- t
-
- let internal invokeIssue71Wrapper<'T when 'T :> System.Exception>
- ((unique: string), (called: bool array))
- =
- let constructor =
- typeof<'T>
- .GetConstructor([| typeof |])
-
- let pitcher =
- fun _ _ _ _ ->
- constructor.Invoke([| unique |]) :?> System.Exception
- |> raise
-
- let catcher =
- fun _ _ _ (x: System.Exception) ->
- called.[0] <- true
-
- called.[1] <-
- match x with
- | :? System.ArgumentNullException as ane -> ane.ParamName = unique
- | _ -> x.Message = unique
-
- Instance.I.Issue71Wrapper((), (), (), (), catcher, pitcher)
- |> ignore
-
- let internal invokeCurriedIssue71Wrapper<'T when 'T :> System.Exception>
- (unique: string)
- =
- let constructor =
- typeof<'T>
- .GetConstructor([| typeof |])
-
- let pitcher =
- fun _ _ _ _ ->
- constructor.Invoke([| unique |]) :?> System.Exception
- |> raise
-
- Instance.I.CurriedIssue71Wrapper(
- "a",
- "b",
- "c",
- "d",
- pitcher
- )
- |> ignore
-
- let internal tracePush (a, b, c) = Instance.I.Trace.Push(a, b, c)
-#endif
\ No newline at end of file
diff --git a/AltCover.Recorder.Tests/AltCover.Recorder.Tests.fsproj b/AltCover.Recorder.Tests/AltCover.Recorder.Tests.fsproj
index 8c73f0013..3a8a34a7d 100644
--- a/AltCover.Recorder.Tests/AltCover.Recorder.Tests.fsproj
+++ b/AltCover.Recorder.Tests/AltCover.Recorder.Tests.fsproj
@@ -23,11 +23,11 @@
AssemblyVersion.fs
-
-
+
+
diff --git a/AltCover.Recorder.Tests/AssemblyInfo.cs b/AltCover.Recorder.Tests/AssemblyInfo.cs
deleted file mode 100644
index b4e1d9f96..000000000
--- a/AltCover.Recorder.Tests/AssemblyInfo.cs
+++ /dev/null
@@ -1,5 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-
-[assembly: CLSCompliant(true)]
-[assembly: ComVisible(false)]
\ No newline at end of file
diff --git a/AltCover.Recorder.Tests/Program.cs b/AltCover.Recorder.Tests/Program.cs
deleted file mode 100644
index d4c4501b5..000000000
--- a/AltCover.Recorder.Tests/Program.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-#if !NET472
-#if NET20
-namespace Tests.Recorder.Clr2
-#else
-
-namespace Tests.Recorder.Core
-#endif
-#else
-namespace Tests.Recorder.Clr4
-#endif
-{
- internal static class UnitTestStub
- {
- private static int Main()
- {
- return 0;
- }
- }
-}
\ No newline at end of file
diff --git a/AltCover.Recorder.Tests/Recorder.Tests.cs b/AltCover.Recorder.Tests/Recorder.Tests.cs
deleted file mode 100644
index 19ed2eea4..000000000
--- a/AltCover.Recorder.Tests/Recorder.Tests.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-#if !NET472
-#if NET20
-namespace Tests.Recorder.Clr2
-#else
-
-namespace Tests.Recorder.Core
-#endif
-#else
-namespace Tests.Recorder.Clr4
-#endif
-{
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.IO.Compression;
- using System.Reflection;
- using System.Runtime.CompilerServices;
- using System.Threading;
- using System.Xml;
-
- using AltCover.Recorder;
- using NUnit.Framework;
-
- public static class AltCoverTests
- {
- [Test]
- public static void ShouldCoverTrivalClass()
- {
- var mark = new InstrumentationAttribute(); // Constructor has all the instrumented code
- Assert.That(mark.Assembly, Is.EqualTo("AltCover.Recorder.g!"));
- Assert.That(mark.Configuration, Is.EqualTo("Uninstrumented!!"));
- mark.Assembly = String.Empty;
- mark.Configuration = String.Empty;
- Assert.True(String.IsNullOrEmpty(mark.Assembly));
- Assert.True(String.IsNullOrEmpty(mark.Configuration));
- }
- }
-}
\ No newline at end of file
diff --git a/AltCover.Recorder.Tests/Recorder.Tests.fs b/AltCover.Recorder.Tests/Recorder.Tests.fs
index a5d9410aa..78d49a1e9 100644
--- a/AltCover.Recorder.Tests/Recorder.Tests.fs
+++ b/AltCover.Recorder.Tests/Recorder.Tests.fs
@@ -35,30 +35,42 @@ module AltCoverTests =
// printfn "%s %s" tag
//#endif
+#if RECORDER2
let resource =
- Assembly
- .GetExecutingAssembly()
- .GetManifestResourceNames()
- |> Seq.find (fun n -> n.EndsWith("SimpleCoverage.xml", StringComparison.Ordinal))
+ "AltCover.Recorder2.Tests.SimpleCoverage.xml"
let resource2 =
- Assembly
- .GetExecutingAssembly()
- .GetManifestResourceNames()
- |> Seq.find (fun n ->
- n.EndsWith("Sample1WithModifiedOpenCover.xml", StringComparison.Ordinal))
+ "AltCover.Recorder2.Tests.Sample1WithModifiedOpenCover.xml"
let resource3 =
- Assembly
- .GetExecutingAssembly()
- .GetManifestResourceNames()
- |> Seq.find (fun n -> n.EndsWith("Sample2NCoverage.xml", StringComparison.Ordinal))
+ "AltCover.Recorder2.Tests.Sample2NCoverage.xml"
+#else
+ let resource =
+ "AltCover.Recorder.Tests.SimpleCoverage.xml"
+
+ let resource2 =
+ "AltCover.Recorder.Tests.Sample1WithModifiedOpenCover.xml"
+
+ let resource3 =
+ "AltCover.Recorder.Tests.Sample2NCoverage.xml"
+#endif
+
+ let internal updateReport0 (counts, format, coverageFile, outputFile) =
+ Counter.I.UpdateReport(
+ ignore,
+ (fun _ _ -> ()),
+ true,
+ counts,
+ format,
+ coverageFile,
+ outputFile
+ )
let private updateReport a b =
- Adapter.updateReport (a, ReportFormat.NCover, b, b)
+ updateReport0 (a, ReportFormat.NCover, b, b)
|> ignore
- let private pointVisitInit a b = Adapter.init (a, b)
+ let private pointVisitInit a b = AltCoverCoreTests.init (a, b)
[]
let ShouldCoverTrivalClass () =
@@ -95,8 +107,7 @@ module AltCoverTests =
let ShouldBeLinkingTheCorrectCopyOfThisCode () =
getMyMethodName "=>"
- let tracer =
- Adapter.makeNullTrace String.Empty
+ let tracer = Tracer.Create String.Empty
// whitelist test not recorder.g
@@ -107,62 +118,67 @@ 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)
+
[]
let OnlyNewIdPairShouldBeSampled () =
getMyMethodName "=>"
- lock Adapter.Lock (fun () ->
+ lock Instance.I.visits (fun () ->
try
- Adapter.ModuleReset [| "module"; "newmodule" |]
+ AltCoverCoreTests.ModuleReset [| "module"; "newmodule" |]
let n = Null() :> Track
- Assert.True(Adapter.addSample ("module", 23, n), "Test 1")
- Assert.True(Adapter.addSample ("module", 24, n), "Test 2")
- Assert.True(Adapter.addSample ("newmodule", 23, n), "Test 3")
- Assert.True(Adapter.addSample ("module", 23, n) |> not, "Test 4")
- Assert.True(Adapter.addSampleUnconditional ("module", 23, n), "Test 5")
- Assert.True(Adapter.addSample ("module", 23, Call 1), "Test 6")
- Assert.True(Adapter.addSample ("module", 23, Time 0L), "Test 7")
- Assert.True(Adapter.addSample ("module", 23, Time 1L), "Test 7a")
- Assert.True(Adapter.addSample ("module", 23, Time 0L) |> not, "Test 7b")
+ Assert.True(addSample ("module", 23, n), "Test 1")
+ 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")
+ Assert.True(addSample ("module", 23, Time 0L) |> not, "Test 7b")
- Assert.True(
- Adapter.addSample ("module", 24, new Both(Pair.Create(0, 1))),
- "Test 8"
- )
+ Assert.True(addSample ("module", 24, new Both(Pair.Create(0, 1))), "Test 8")
- Assert.True(
- Adapter.addSample ("module", 25, new Both(Pair.Create(0, 1))),
- "Test 9"
- )
+ Assert.True(addSample ("module", 25, new Both(Pair.Create(0, 1))), "Test 9")
- Assert.True(Adapter.addSample ("module", 25, Call 1) |> not, "Test 10")
- Assert.True(Adapter.addSample ("module", 25, Call 1) |> not, "Test 11")
- Assert.True(Adapter.addSample ("module", 25, n) |> not, "Test 12")
+ Assert.True(addSample ("module", 25, Call 1) |> not, "Test 10")
+ Assert.True(addSample ("module", 25, Call 1) |> not, "Test 11")
+ Assert.True(addSample ("module", 25, n) |> not, "Test 12")
// out of band example
- Assert.True(Adapter.addSample ("nonesuch", 25, n) |> not, "Test 12a")
+ Assert.True(addSample ("nonesuch", 25, n) |> not, "Test 12a")
Assert.Throws(fun () ->
- Adapter.addSample ("module", 23, Table null)
- |> ignore)
+ addSample ("module", 23, Table null) |> ignore)
|> ignore
finally
- Adapter.HardReset())
+ AltCoverCoreTests.HardReset())
getMyMethodName "<="
+ let VisitsEntrySeq key =
+ Instance.I.visits.[key]
+ |> Seq.cast>
+
+ let VisitCount (key, key2) = (Instance.I.visits.[key].[key2]).Count
+
[]
let RealIdShouldIncrementCount () =
getMyMethodName "=>"
- lock Adapter.Lock (fun () ->
+ lock Instance.I.visits (fun () ->
let save = Instance.I.Trace
try
let key = " "
- Adapter.ModuleReset [| key |]
- Instance.I.Trace <- Adapter.makeNullTrace null
+ AltCoverCoreTests.ModuleReset [| key |]
+ Instance.I.Trace <- Tracer.Create null
Instance.I.Recording <- false
Instance.Visit("key", 17)
@@ -176,27 +192,41 @@ module AltCoverTests =
Instance.Visit(key, -23)
- let vs = Adapter.VisitsSeq()
- Assert.True(vs |> Seq.length = 3, sprintf "Adapter.VisitsSeq() = %A" vs)
-
- let vesk = Adapter.VisitsEntrySeq key
+ let vs = AltCoverCoreTests.VisitsSeq()
Assert.True(
- vesk |> Seq.length = 1,
- sprintf "Adapter.VisitsEntrySeq %A = %A" key vesk
+ vs |> Seq.length = 3,
+ sprintf "AltCoverCoreTests.VisitsSeq() = %A" vs
)
- Assert.That(Adapter.VisitCount(key, -23), Is.EqualTo 2L)
+ let vesk = VisitsEntrySeq key
+
+ Assert.True(vesk |> Seq.length = 1, sprintf "VisitsEntrySeq %A = %A" key vesk)
+
+ Assert.That(VisitCount(key, -23), Is.EqualTo 2L)
Assert.That(Counter.totalVisits, Is.EqualTo 1L)
Assert.That(Counter.branchVisits, Is.EqualTo 1L)
finally
Instance.CoverageFormat <- ReportFormat.NCover
Instance.I.Recording <- true
- Adapter.HardReset()
+ AltCoverCoreTests.HardReset()
Instance.I.Trace <- save)
getMyMethodName "<="
+ let internal payloadSelector x = Instance.I.PayloadSelector(fun _ -> x)
+
+ let internal payloadControl (x, y) =
+ Instance.I.PayloadControl((fun _ -> x), (fun _ -> y))
+
+ let internal payloadSelection (x, y, z) =
+ Instance.I.PayloadSelection((fun _ -> x), (fun _ -> y), (fun _ -> z))
+
+ let internal untime (at: Track) =
+ match at with
+ | :? Time as t -> Some t.Value
+ | _ -> None
+
[]
let JunkUspidGivesNegativeIndex () =
let key = " "
@@ -216,47 +246,44 @@ module AltCoverTests =
||| ReportFormat.WithTracking
Assert.False(Instance.I.CallerId.HasValue)
- Assert.That(Adapter.payloadSelector false, Is.EqualTo <| Adapter.asNull ())
- Assert.That(Adapter.payloadSelector true, Is.EqualTo <| Adapter.asNull ())
+ Assert.That(payloadSelector false, Is.EqualTo <| Null())
+ Assert.That(payloadSelector true, Is.EqualTo <| Null())
Instance.Push 4321
- Assert.That(Adapter.payloadSelector false, Is.EqualTo <| Adapter.asNull ())
- Assert.That(Adapter.payloadSelector true, Is.EqualTo <| (Adapter.asCall 4321))
+ Assert.That(payloadSelector false, Is.EqualTo <| Null())
+ Assert.That(payloadSelector true, Is.EqualTo <| (Call 4321))
try
Instance.Push 6789
// 0x1234123412341234 == 1311693406324658740
let result =
- Adapter.payloadSelection (1311693406324658740L, 1000L, true)
+ payloadSelection (1311693406324658740L, 1000L, true)
let expected =
- Adapter.newBoth (1311693406324658000L, 6789)
+ AltCoverCoreTests.newBoth (1311693406324658000L, 6789)
Assert.True((result = expected))
finally
Instance.Pop()
- Assert.That(Adapter.payloadSelector true, Is.EqualTo(Adapter.asCall 4321))
+ Assert.That(payloadSelector true, Is.EqualTo(Call 4321))
finally
Instance.Pop()
Instance.CoverageFormat <- ReportFormat.NCover
let result2 =
- Adapter.payloadSelection (1311693406324658740L, 1000L, true)
+ payloadSelection (1311693406324658740L, 1000L, true)
- let expected2 =
- Adapter.time 1311693406324658000L
+ let expected2 = Time 1311693406324658000L
Assert.True((result2 = expected2))
let v1 = DateTime.UtcNow.Ticks
- let probed =
- Adapter.payloadControl (1000L, true)
+ let probed = payloadControl (1000L, true)
let v2 = DateTime.UtcNow.Ticks
- Assert.True(Adapter.asNull () |> Adapter.untime |> Seq.isEmpty)
+ Assert.True(Null() |> untime |> Option.isNone)
- let [ probe ] =
- Adapter.untime probed |> Seq.toList
+ let probe = (untime probed).Value
Assert.True(probe % 1000L = 0L)
Assert.True(probe <= v2)
@@ -267,7 +294,7 @@ module AltCoverTests =
[]
let PayloadWithEntryExitGeneratedIsAsExpected () =
- Adapter.ModuleReset [||]
+ AltCoverCoreTests.ModuleReset [||]
try
Instance.I.isRunner <- true
@@ -276,51 +303,48 @@ module AltCoverTests =
ReportFormat.OpenCover
||| ReportFormat.WithTracking
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
Assert.True(Instance.I.CallerId.HasValue |> not)
- Assert.That(Adapter.payloadSelector false, Is.EqualTo <| Adapter.asNull ())
- Assert.That(Adapter.payloadSelector true, Is.EqualTo <| Adapter.asNull ())
+ Assert.That(payloadSelector false, Is.EqualTo <| Null())
+ Assert.That(payloadSelector true, Is.EqualTo <| Null())
Instance.Push 4321
- Assert.That(Adapter.payloadSelector false, Is.EqualTo <| Adapter.asNull ())
- Assert.That(Adapter.payloadSelector true, Is.EqualTo(Adapter.asCall 4321))
+ Assert.That(payloadSelector false, Is.EqualTo <| Null())
+ Assert.That(payloadSelector true, Is.EqualTo(Call 4321))
try
Instance.Push 6789
// 0x1234123412341234 == 1311693406324658740
let result =
- Adapter.payloadSelection (1311693406324658740L, 1000L, true)
+ payloadSelection (1311693406324658740L, 1000L, true)
let expected =
- Adapter.newBoth (1311693406324658000L, 6789)
+ AltCoverCoreTests.newBoth (1311693406324658000L, 6789)
Assert.True((result = expected))
finally
Instance.Pop()
- Assert.That(Adapter.payloadSelector true, Is.EqualTo(Adapter.asCall 4321))
+ Assert.That(payloadSelector true, Is.EqualTo(Call 4321))
finally
Instance.Pop()
Instance.I.isRunner <- false
Instance.CoverageFormat <- ReportFormat.NCover
let result2 =
- Adapter.payloadSelection (1311693406324658740L, 1000L, true)
+ payloadSelection (1311693406324658740L, 1000L, true)
- let expected2 =
- Adapter.time 1311693406324658000L
+ let expected2 = Time 1311693406324658000L
Assert.True((result2 = expected2))
let v1 = DateTime.UtcNow.Ticks
- let probed =
- Adapter.payloadControl (1000L, true)
+ let probed = payloadControl (1000L, true)
let v2 = DateTime.UtcNow.Ticks
- Assert.True(Adapter.asNull () |> Adapter.untime |> Seq.isEmpty)
+ Assert.True(Null() |> untime |> Option.isNone)
- let [ probe ] =
- Adapter.untime probed |> Seq.toList
+ let probe = (untime probed).Value
Assert.True(probe % 1000L = 0L)
Assert.True(probe <= v2)
@@ -359,24 +383,24 @@ module AltCoverTests =
Assert.That(d.Tracks |> Seq.length, Is.EqualTo 1)
let a2 =
- a.Tracks |> Seq.head |> Adapter.untime |> Seq.head
+ (a.Tracks |> Seq.head |> untime).Value
let b2 =
- b.Tracks |> Seq.head |> Adapter.untime |> Seq.head
+ (b.Tracks |> Seq.head |> untime).Value
Assert.That(b2 >= a2)
let c2 =
- c.Tracks |> Seq.head |> Adapter.untime |> Seq.head
+ (c.Tracks |> Seq.head |> untime).Value
Assert.That(c2 >= b2)
let d2 =
- d.Tracks |> Seq.head |> Adapter.untime |> Seq.head
+ (d.Tracks |> Seq.head |> untime).Value
Assert.That(d2 >= c2, sprintf "%A >= %A" d2 c2)
- Adapter.HardReset()
+ AltCoverCoreTests.HardReset()
[]
let RealIdShouldIncrementCountSynchronously () =
@@ -385,12 +409,12 @@ module AltCoverTests =
lock Instance.I.visits (fun () ->
let save = Instance.I.Trace
let key = " "
- Adapter.ModuleReset [| key |]
+ AltCoverCoreTests.ModuleReset [| key |]
try
- Instance.I.Trace <- Adapter.makeNullTrace null
+ Instance.I.Trace <- Tracer.Create null
- Instance.I.VisitSelection(Adapter.asNull (), key, 23)
+ Instance.I.VisitSelection(Null(), key, 23)
Assert.That(
Instance.I.visits.Keys,
@@ -407,7 +431,7 @@ module AltCoverTests =
Assert.That(Instance.I.visits.[key].[23].Count, Is.EqualTo 1)
Assert.That(Instance.I.visits.[key].[23].Tracks, Is.Empty)
finally
- Adapter.HardReset()
+ AltCoverCoreTests.HardReset()
Instance.I.Trace <- save)
getMyMethodName "<="
@@ -418,6 +442,51 @@ module AltCoverTests =
Assert.That(all.Contains x)
all.Remove x |> ignore)
+ let internal invokeCurriedIssue71Wrapper<'T when 'T :> System.Exception>
+ (unique: string)
+ =
+ let constructor =
+ typeof<'T>
+ .GetConstructor([| typeof |])
+
+ let pitcher =
+ fun _ _ _ _ ->
+ constructor.Invoke([| unique |]) :?> System.Exception
+ |> raise
+
+ Instance.I.CurriedIssue71Wrapper(
+ "a",
+ "b",
+ "c",
+ "d",
+ pitcher
+ )
+ |> ignore
+
+ let internal invokeIssue71Wrapper<'T when 'T :> System.Exception>
+ ((unique: string), (called: bool array))
+ =
+ let constructor =
+ typeof<'T>
+ .GetConstructor([| typeof |])
+
+ let pitcher =
+ fun _ _ _ _ ->
+ constructor.Invoke([| unique |]) :?> System.Exception
+ |> raise
+
+ let catcher =
+ fun _ _ _ (x: System.Exception) ->
+ called.[0] <- true
+
+ called.[1] <-
+ match x with
+ | :? System.ArgumentNullException as ane -> ane.ParamName = unique
+ | _ -> x.Message = unique
+
+ Instance.I.Issue71Wrapper((), (), (), (), catcher, pitcher)
+ |> ignore
+
[]
let StripWorks () =
let b1 = [ "1" ]
@@ -481,7 +550,7 @@ module AltCoverTests =
let unique =
System.Guid.NewGuid().ToString()
- Adapter.invokeCurriedIssue71Wrapper unique
+ invokeCurriedIssue71Wrapper unique
let after =
Directory.GetFiles(where, "*.exn")
@@ -517,7 +586,7 @@ module AltCoverTests =
let unique =
System.Guid.NewGuid().ToString()
- Adapter.invokeIssue71Wrapper (unique, pair)
+ invokeIssue71Wrapper (unique, pair)
Assert.That(pair |> Seq.head, Is.True)
Assert.That(pair |> Seq.last, Is.True)
@@ -528,7 +597,7 @@ module AltCoverTests =
let unique =
System.Guid.NewGuid().ToString()
- Adapter.invokeIssue71Wrapper (unique, pair)
+ invokeIssue71Wrapper (unique, pair)
Assert.That(pair |> Seq.head, Is.True)
Assert.That(pair |> Seq.last, Is.True)
@@ -539,7 +608,7 @@ module AltCoverTests =
let unique =
System.Guid.NewGuid().ToString()
- Adapter.invokeIssue71Wrapper (unique, pair)
+ invokeIssue71Wrapper (unique, pair)
Assert.That(pair |> Seq.head, Is.True)
Assert.That(pair |> Seq.last, Is.True)
@@ -552,7 +621,7 @@ module AltCoverTests =
let exn =
Assert.Throws(fun () ->
- Adapter.invokeIssue71Wrapper (unique, pair))
+ invokeIssue71Wrapper (unique, pair))
Assert.That(pair |> Seq.head, Is.False)
Assert.That(pair |> Seq.last, Is.False)
@@ -577,7 +646,7 @@ module AltCoverTests =
let before =
Directory.GetFiles(where, "*.exn")
- Instance.I.VisitImpl(key, 23, Adapter.asNull ())
+ Instance.I.VisitImpl(key, 23, Null())
let after =
Directory.GetFiles(where, "*.exn")
@@ -619,16 +688,16 @@ module AltCoverTests =
lock Instance.I.visits (fun () ->
try
let key = " "
- Adapter.ModuleReset [| key; "key" |]
- Instance.I.VisitImpl(key, 23, Adapter.asNull ())
- Instance.I.VisitImpl("key", 42, Adapter.asNull ())
+ AltCoverCoreTests.ModuleReset [| key; "key" |]
+ Instance.I.VisitImpl(key, 23, Null())
+ Instance.I.VisitImpl("key", 42, Null())
Assert.That(
Instance.I.visits.Keys,
Is.EquivalentTo [ key; "key"; Track.Entry; Track.Exit ]
)
finally
- Adapter.HardReset())
+ AltCoverCoreTests.HardReset())
getMyMethodName "<="
@@ -639,9 +708,9 @@ module AltCoverTests =
lock Instance.I.visits (fun () ->
try
let key = " "
- Adapter.ModuleReset [| key |]
- Instance.I.VisitImpl(key, 23, Adapter.asNull ())
- Instance.I.VisitImpl(key, 42, Adapter.asNull ())
+ AltCoverCoreTests.ModuleReset [| key |]
+ Instance.I.VisitImpl(key, 23, Null())
+ Instance.I.VisitImpl(key, 42, Null())
Assert.That(
Instance.I.visits.Keys,
@@ -650,7 +719,7 @@ module AltCoverTests =
Assert.That(Instance.I.visits.[key].Count, Is.EqualTo 2)
finally
- Adapter.HardReset())
+ AltCoverCoreTests.HardReset())
getMyMethodName "<="
@@ -660,15 +729,15 @@ module AltCoverTests =
lock Instance.I.visits (fun () ->
let key = " "
- Adapter.ModuleReset [| key |]
+ AltCoverCoreTests.ModuleReset [| key |]
try
- Instance.I.VisitImpl(key, 23, Adapter.asNull ())
- Instance.I.VisitImpl(key, 23, Adapter.asNull ())
+ Instance.I.VisitImpl(key, 23, Null())
+ Instance.I.VisitImpl(key, 23, Null())
Assert.That(Instance.I.visits.[key].[23].Count, Is.EqualTo 2)
Assert.That(Instance.I.visits.[key].[23].Tracks, Is.Empty)
finally
- Adapter.HardReset())
+ AltCoverCoreTests.HardReset())
getMyMethodName "<="
@@ -678,18 +747,17 @@ module AltCoverTests =
lock Instance.I.visits (fun () ->
let key = " "
- Adapter.ModuleReset [| key |]
+ AltCoverCoreTests.ModuleReset [| key |]
try
- let payload =
- Adapter.time DateTime.UtcNow.Ticks
+ let payload = Time DateTime.UtcNow.Ticks
- Instance.I.VisitImpl(key, 23, Adapter.asNull ())
+ Instance.I.VisitImpl(key, 23, Null())
Instance.I.VisitImpl(key, 23, payload)
Assert.That(Instance.I.visits.[key].[23].Count, Is.EqualTo 1)
Assert.That(Instance.I.visits.[key].[23].Tracks, Is.EquivalentTo [ payload ])
finally
- Adapter.HardReset())
+ AltCoverCoreTests.HardReset())
getMyMethodName "<="
@@ -1187,7 +1255,7 @@ module AltCoverTests =
item.Add("7C-CD-66-29-A3-6C-6D-5F-A7-65-71-0E-22-7D-B2-61-B5-1F-65-9A", payload)
- Adapter.updateReport (item, ReportFormat.OpenCover, worker, worker)
+ updateReport0 (item, ReportFormat.OpenCover, worker, worker)
|> ignore
worker.Position <- 0L
@@ -1224,17 +1292,17 @@ module AltCoverTests =
let EmptyFlushLeavesNoTrace () =
getMyMethodName "=>"
- lock Adapter.Lock (fun () ->
+ lock Instance.I.visits (fun () ->
let saved = Console.Out
try
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
use stdout = new StringWriter()
Console.SetOut stdout
Instance.FlushFinish()
Assert.That(stdout.ToString(), Is.Empty)
finally
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
Console.SetOut saved)
getMyMethodName "<="
@@ -1274,11 +1342,21 @@ module AltCoverTests =
trywithrelease (fun () ->
InvalidOperationException() |> raise)
+ let internal makeStreamTrace s1 =
+ let mutable t = Tracer.Create(null)
+ // fsharplint:disable-next-line RedundantNewKeyword
+ t.Stream <- new System.IO.MemoryStream()
+ // fsharplint:disable-next-line RedundantNewKeyword
+ t.Formatter <- new System.IO.BinaryWriter(s1)
+ t.Runner <- true
+ t.Definitive <- false
+ t
+
[]
let PauseLeavesExpectedTraces () =
getMyMethodName "=>"
- lock Adapter.Lock (fun () ->
+ lock Instance.I.visits (fun () ->
trywithrelease (fun () ->
let saved = Console.Out
let here = Directory.GetCurrentDirectory()
@@ -1296,11 +1374,11 @@ module AltCoverTests =
let s1 =
new Compression.DeflateStream(s, CompressionMode.Compress)
- Instance.I.Trace <- Adapter.makeStreamTrace s1
+ Instance.I.Trace <- makeStreamTrace s1
try
Instance.I.isRunner <- true
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
use stdout = new StringWriter()
Console.SetOut stdout
@@ -1328,17 +1406,16 @@ module AltCoverTests =
[ 0..9 ]
|> Seq.iter (fun i ->
- Adapter.VisitsAdd(
+ AltCoverCoreTests.VisitsAdd(
"f6e3edb3-fb20-44b3-817d-f69d1a22fc2f",
i,
(int64 (i + 1))
))
let nullObj: obj = null
- Adapter.DoPause().Invoke(nullObj, null)
+ Instance.I.doPause.Invoke(nullObj, null)
- Adapter.VisitsSeq()
- |> Seq.cast>>
+ AltCoverCoreTests.VisitsSeq()
|> Seq.iter (fun v ->
Assert.That(v.Value, Is.Empty, sprintf "Unexpected write %A" v))
@@ -1370,7 +1447,7 @@ module AltCoverTests =
finally
Instance.I.Trace <- save
AltCoverCoreTests.maybeDeleteFile Instance.ReportFilePath
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
Instance.I.isRunner <- false
Console.SetOut saved
Directory.SetCurrentDirectory(here)
@@ -1382,7 +1459,7 @@ module AltCoverTests =
let ResumeLeavesExpectedTraces () =
getMyMethodName "=>"
- lock Adapter.Lock (fun () ->
+ lock Instance.I.visits (fun () ->
trywithrelease (fun () ->
let saved = Console.Out
let here = Directory.GetCurrentDirectory()
@@ -1405,7 +1482,7 @@ module AltCoverTests =
let key =
"f6e3edb3-fb20-44b3-817d-f69d1a22fc2f"
- Adapter.ModuleReset [| key |]
+ AltCoverCoreTests.ModuleReset [| key |]
Instance.I.Trace <- Tracer.Create(tag)
use stdout = new StringWriter()
@@ -1433,13 +1510,12 @@ module AltCoverTests =
()
[ 0..9 ]
- |> Seq.iter (fun i -> Adapter.VisitsAdd(key, i, (int64 (i + 1))))
+ |> Seq.iter (fun i -> AltCoverCoreTests.VisitsAdd(key, i, (int64 (i + 1))))
let nullObj: obj = null
- Adapter.DoResume().Invoke(nullObj, null)
+ Instance.I.doResume.Invoke(nullObj, null)
- Adapter.VisitsSeq()
- |> Seq.cast>>
+ AltCoverCoreTests.VisitsSeq()
|> Seq.iter (fun v ->
Assert.That(v.Value, Is.Empty, sprintf "Visits should be cleared %A" v))
@@ -1475,10 +1551,10 @@ module AltCoverTests =
"-1" ]
)
finally
- Adapter.HardReset()
+ AltCoverCoreTests.HardReset()
Instance.I.Trace <- save
AltCoverCoreTests.maybeDeleteFile Instance.ReportFilePath
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
Console.SetOut saved
Directory.SetCurrentDirectory(here)
File.Delete tag
@@ -1490,7 +1566,7 @@ module AltCoverTests =
let FlushLeavesExpectedTraces () =
getMyMethodName "=>"
- lock Adapter.Lock (fun () ->
+ lock Instance.I.visits (fun () ->
Instance.I.isRunner <- false
trywithrelease (fun () ->
@@ -1505,10 +1581,10 @@ module AltCoverTests =
Path.Combine(where, Guid.NewGuid().ToString())
let save = Instance.I.Trace
- Instance.I.Trace <- Adapter.makeNullTrace null
+ Instance.I.Trace <- Tracer.Create null
try
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
use stdout = new StringWriter()
Console.SetOut stdout
Directory.CreateDirectory(unique) |> ignore
@@ -1535,14 +1611,14 @@ module AltCoverTests =
[ 0..9 ]
|> Seq.iter (fun i ->
- Adapter.VisitsAdd(
+ AltCoverCoreTests.VisitsAdd(
"f6e3edb3-fb20-44b3-817d-f69d1a22fc2f",
i,
(int64 (i + 1))
))
let nullObj: obj = null
- Adapter.DoExit().Invoke(nullObj, null)
+ Instance.I.doExit.Invoke(nullObj, null)
let head =
"Coverage statistics flushing took "
@@ -1586,7 +1662,7 @@ module AltCoverTests =
finally
Instance.I.Trace <- save
AltCoverCoreTests.maybeDeleteFile Instance.ReportFilePath
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
Console.SetOut saved
Directory.SetCurrentDirectory(here)
AltCoverCoreTests.maybeIOException (fun () -> Directory.Delete(unique))))
@@ -1597,7 +1673,7 @@ module AltCoverTests =
let SupervisedFlushLeavesExpectedTraces () =
getMyMethodName "=>"
- lock Adapter.Lock (fun () ->
+ lock Instance.I.visits (fun () ->
trywithrelease (fun () ->
let saved = Console.Out
let here = Directory.GetCurrentDirectory()
@@ -1610,12 +1686,12 @@ module AltCoverTests =
Path.Combine(where, Guid.NewGuid().ToString())
let save = Instance.I.Trace
- Instance.I.Trace <- Adapter.makeNullTrace null
+ Instance.I.Trace <- Tracer.Create null
Instance.supervision <- true
try
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
use stdout = new StringWriter()
Console.SetOut stdout
Directory.CreateDirectory(unique) |> ignore
@@ -1642,14 +1718,14 @@ module AltCoverTests =
[ 0..9 ]
|> Seq.iter (fun i ->
- Adapter.VisitsAdd(
+ AltCoverCoreTests.VisitsAdd(
"f6e3edb3-fb20-44b3-817d-f69d1a22fc2f",
i,
(int64 (i + 1))
))
let nullObj: obj = null
- Adapter.DoUnload().Invoke(nullObj, null)
+ Instance.I.doUnload.Invoke(nullObj, null)
let head =
"Coverage statistics flushing took "
@@ -1687,13 +1763,22 @@ module AltCoverTests =
Instance.I.Trace <- save
Instance.supervision <- false
AltCoverCoreTests.maybeDeleteFile Instance.ReportFilePath
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
Console.SetOut saved
Directory.SetCurrentDirectory(here)
AltCoverCoreTests.maybeIOException (fun () -> Directory.Delete(unique))))
getMyMethodName "<="
+ let internal doFlush (visits, format, report, output) =
+ let output' =
+ if System.String.IsNullOrEmpty output then
+ null
+ else
+ output
+
+ Counter.DoFlushFile(ignore, (fun _ _ -> ()), true, visits, format, report, output')
+
[]
let FlushLeavesExpectedTracesWhenDiverted () =
let saved = Console.Out
@@ -1747,7 +1832,7 @@ module AltCoverTests =
visits.["f6e3edb3-fb20-44b3-817d-f69d1a22fc2f"] <- payload
- Adapter.doFlush (visits, ReportFormat.NCover, reportFile, outputFile)
+ doFlush (visits, ReportFormat.NCover, reportFile, outputFile)
|> ignore
use worker' =
@@ -1831,7 +1916,7 @@ module AltCoverTests =
visits.["f6e3edb3-fb20-44b3-817d-f69d1a22fc2f"] <- payload
- Adapter.doFlush (visits, ReportFormat.NCover, reportFile, outputFile)
+ doFlush (visits, ReportFormat.NCover, reportFile, outputFile)
|> ignore
use worker' =
@@ -1906,7 +1991,7 @@ module AltCoverTests =
visits.["f6e3edb3-fb20-44b3-817d-f69d1a22fc2f"] <- payload
- Adapter.doFlush (
+ doFlush (
visits,
ReportFormat.NCover ||| ReportFormat.Zipped,
reportFile,
@@ -1997,7 +2082,7 @@ module AltCoverTests =
visits.["f6e3edb3-fb20-44b3-817d-f69d1a22fc2f"] <- payload
- Adapter.doFlush (
+ doFlush (
visits,
ReportFormat.NCover ||| ReportFormat.Zipped,
reportFile,
@@ -2070,12 +2155,7 @@ module AltCoverTests =
visits.["f6e3edb3-fb20-44b3-817d-f69d1a22fc2f"] <- payload
- Adapter.doFlush (
- visits,
- ReportFormat.NCover ||| ReportFormat.Zipped,
- reportFile,
- null
- )
+ doFlush (visits, ReportFormat.NCover ||| ReportFormat.Zipped, reportFile, null)
|> ignore
Assert.That(reportFile |> File.Exists |> not)
@@ -2092,7 +2172,7 @@ module AltCoverTests =
let ZipFlushLeavesExpectedTraces () =
getMyMethodName "=>"
- lock Adapter.Lock (fun () ->
+ lock Instance.I.visits (fun () ->
Instance.I.isRunner <- false
Instance.CoverageFormat <- ReportFormat.NCover ||| ReportFormat.Zipped
@@ -2108,10 +2188,10 @@ module AltCoverTests =
Path.Combine(where, Guid.NewGuid().ToString())
let save = Instance.I.Trace
- Instance.I.Trace <- Adapter.makeNullTrace null
+ Instance.I.Trace <- Tracer.Create null
try
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
use stdout = new StringWriter()
Console.SetOut stdout
Directory.CreateDirectory(unique) |> ignore
@@ -2146,14 +2226,14 @@ module AltCoverTests =
[ 0..9 ]
|> Seq.iter (fun i ->
- Adapter.VisitsAdd(
+ AltCoverCoreTests.VisitsAdd(
"f6e3edb3-fb20-44b3-817d-f69d1a22fc2f",
i,
(int64 (i + 1))
))
let nullObj: obj = null
- Adapter.DoExit().Invoke(nullObj, null)
+ Instance.I.doExit.Invoke(nullObj, null)
let head =
"Coverage statistics flushing took "
@@ -2204,7 +2284,7 @@ module AltCoverTests =
Instance.I.Trace <- save
AltCoverCoreTests.maybeDeleteFile Instance.ReportFilePath
AltCoverCoreTests.maybeDeleteFile (Instance.ReportFilePath + ".zip")
- Adapter.VisitsClear()
+ AltCoverCoreTests.VisitsClear()
Console.SetOut saved
Directory.SetCurrentDirectory(here)
AltCoverCoreTests.maybeIOException (fun () -> Directory.Delete(unique))))
diff --git a/AltCover.Recorder.Tests/Tracer.Tests.cs b/AltCover.Recorder.Tests/Tracer.Tests.cs
deleted file mode 100644
index 8b79b76e4..000000000
--- a/AltCover.Recorder.Tests/Tracer.Tests.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-#if !NET472
-#if NET20
-namespace Tests.Recorder.Clr2
-#else
-
-namespace Tests.Recorder.Core
-#endif
-#else
-namespace Tests.Recorder.Clr4
-#endif
-
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.IO.Compression;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using AltCover.Recorder;
- using NUnit.Framework;
- using NUnit.Framework.Constraints;
- using static NUnit.Framework.Constraints.Tolerance;
-
- //[]
- public static class AltCoverCoreTests
- {
- private static void maybeIOException(Action f)
- {
- try { f(); }
- catch (IOException)
- { }
- }
-
- private static void maybeDeleteFile(string f)
- {
- if (File.Exists(f))
- {
- File.Delete(f);
- }
- }
-
- private static void maybeReraise(Action f, Action g)
- {
- try { f(); }
- catch (Exception)
- {
- g();
- throw;
- }
- }
-
- private static void ignore()
- { }
-
- [Test]
- public static void ExcerciseItAll()
- {
- var where =
- Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
-
- var unique =
- Path.Combine(Path.Combine(where, Guid.NewGuid().ToString()), "nonesuch.txt");
-
- maybeDeleteFile(unique);
- maybeIOException(() => { maybeReraise(() => { File.Delete(unique); }, ignore); });
- maybeIOException(() => { maybeReraise(() => { throw new IOException(); }, ignore); });
- }
-
- [Test]
- public static void WillNotConnectSpontaneously()
- {
- var where =
- Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
-
- var unique = Path.Combine(where, Guid.NewGuid().ToString());
-
- var client = Tracer.Create(unique);
- Action close = (() => client.Close());
-
- maybeReraise(
- () =>
- {
- client = client.OnStart();
- Assert.True(!client.IsConnected);
- close();
- }, close);
- }
-
- [Test]
- public static void ValidTokenWillConnect()
- {
- var where =
- Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
-
- var unique = Path.Combine(where, Guid.NewGuid().ToString());
-
- using (var stream = File.Create(unique))
- { }
-
- var client = Tracer.Create(unique);
-
- try
- {
- client = client.OnStart();
- Assert.True(client.IsConnected);
- }
- finally
- { client.Close(); }
- }
- }
-}
\ No newline at end of file
diff --git a/AltCover.Recorder.Tests/Tracer.Tests.fs b/AltCover.Recorder.Tests/Tracer.Tests.fs
index 3b0cd7ea2..97b572fa8 100644
--- a/AltCover.Recorder.Tests/Tracer.Tests.fs
+++ b/AltCover.Recorder.Tests/Tracer.Tests.fs
@@ -37,6 +37,89 @@ module AltCoverCoreTests =
g ()
reraise ()
+ let internal init (n, l) =
+ let tmp = PointVisit.Create()
+ tmp.Count <- n
+
+ tmp.Tracks.AddRange l
+ tmp
+
+ let internal newBoth (time, call) = Both(Pair.Create(time, call))
+
+ let VisitsClear () =
+ Instance.I.Clear()
+ Counter.branchVisits <- 0L
+ Counter.totalVisits <- 0L
+
+ let SamplesClear () =
+ Instance.I.samples <- Instance.I.MakeSamples()
+
+ let private reset () =
+ Instance.I.isRunner <- false
+ VisitsClear()
+ SamplesClear()
+
+ let ModuleReset (m: string array) =
+ Instance.Modules <- m
+ reset ()
+
+ let HardReset () =
+ Instance.Modules <- [| System.String.Empty |]
+ reset ()
+
+ let VisitsSeq () =
+ Instance.I.visits
+ |> Seq.cast>>
+
+ let VisitImplMethod (moduleId, hitPointId, mId) =
+ Instance.I.VisitImpl(moduleId, hitPointId, (Call mId))
+
+ let internal prepareName name =
+ if name |> Instance.I.visits.ContainsKey |> not then
+ let entry = Dictionary()
+ Instance.I.visits.Add(name, entry)
+
+ let VisitsAdd (name, line, number) =
+ prepareName name
+ let v = init (number, [])
+ Instance.I.visits.[name].Add(line, v)
+
+ let VisitsAddTrack (name, line, number) =
+ prepareName name
+ let v1 = init (number, [ Call 17; Call 42 ])
+ Instance.I.visits.[name].Add(line, v1)
+
+ let v2 =
+ init (
+ (number + 1L),
+ [ Time(17L)
+ Both(Pair.Create(42L, 23)) ]
+ )
+
+ Instance.I.visits.[name].Add(line + 1, v2)
+
+ type Untable =
+ | Name of string
+ | Place of int
+ | Token of Track
+
+ let internal untable t =
+ let r = List()
+ //let r = System.Collections.ArrayList()
+
+ let n, p, (t': Track) = t
+
+ match t' with
+ | :? Table as d ->
+ r.Add(Untable.Name n) |> ignore
+ r.Add(Untable.Place p) |> ignore
+ r.Add(Untable.Token d) |> ignore
+ | _ -> ()
+
+ r
+
+ //=======================================
+
[]
let ExcerciseItAll () =
let where =
@@ -106,9 +189,7 @@ module AltCoverCoreTests =
(id,
strike,
match enum tag with
- //| Tag.Time -> Adapter.Time <| formatter.ReadInt64()
- | Tag.Call -> (Adapter.asCall <| formatter.ReadInt32()) :> Track
- //| Tag.Both -> Adapter.NewBoth((formatter.ReadInt64()), (formatter.ReadInt32()))
+ | Tag.Call -> (Call <| formatter.ReadInt32()) :> Track
| Tag.Table ->
Assert.True((id = String.Empty))
Assert.True((strike = 0))
@@ -131,7 +212,7 @@ module AltCoverCoreTests =
if pts > 0 then
let p = formatter.ReadInt32()
let n = formatter.ReadInt64()
- let pv = Adapter.init (n, [])
+ let pv = init (n, [])
t.[m].Add(p, pv)
// []
@@ -140,17 +221,14 @@ module AltCoverCoreTests =
match enum track with
| Tag.Time ->
- pv.Tracks.Add(Adapter.time <| formatter.ReadInt64())
+ pv.Tracks.Add(Time <| formatter.ReadInt64())
tracking ()
| Tag.Call ->
- pv.Tracks.Add(Adapter.asCall <| formatter.ReadInt32())
+ pv.Tracks.Add(Call <| formatter.ReadInt32())
tracking ()
| Tag.Both ->
pv.Tracks.Add(
- Adapter.newBoth (
- (formatter.ReadInt64()),
- (formatter.ReadInt32())
- )
+ newBoth ((formatter.ReadInt64()), (formatter.ReadInt32()))
)
tracking ()
@@ -164,8 +242,8 @@ module AltCoverCoreTests =
sequencePoint points
``module`` ()
- Adapter.table t
- | _ -> Adapter.asNull ())
+ Table t
+ | _ -> Null())
|> hits.Add
sink ())
@@ -187,7 +265,7 @@ module AltCoverCoreTests =
let tag = unique + ".acv"
let expected =
- [ ("name", 23, Adapter.asNull ()) ]
+ [ ("name", 23, Null() :> Track) ]
do
use stream = File.Create tag
@@ -197,11 +275,11 @@ module AltCoverCoreTests =
let mutable client = Tracer.Create tag
try
- Adapter.HardReset()
+ HardReset()
Instance.I.Trace <- client.OnStart()
Assert.True(Instance.I.Trace.IsConnected, "connection failed")
Instance.I.isRunner <- true
- Adapter.VisitImplNone("name", 23)
+ Instance.I.VisitImpl("name", 23, Null())
finally
Instance.I.Trace.Close()
Instance.I.Trace.Close()
@@ -214,21 +292,19 @@ module AltCoverCoreTests =
let results =
readResults stream |> Seq.toList
- Adapter.VisitsSeq()
- |> Seq.cast>>
+ VisitsSeq()
|> Seq.iter (fun v ->
Assert.That(v.Value, Is.Empty, sprintf "Unexpected local write %A" v))
Assert.That(
- Adapter.VisitsSeq() |> Seq.length,
+ VisitsSeq() |> Seq.length,
Is.EqualTo 3,
- sprintf "unexpected local write %A"
- <| Adapter.VisitsSeq()
+ sprintf "unexpected local write %A" <| VisitsSeq()
)
Assert.True((results = expected), sprintf "unexpected result %A" results)
finally
- Adapter.HardReset()
+ HardReset()
[]
let VisitShouldSignalTrack () =
@@ -249,19 +325,18 @@ module AltCoverCoreTests =
t.["name"] <- Dictionary()
let expect23 =
- [ Adapter.asCall 17; Adapter.asCall 42 ]
- |> Seq.cast
- TRACE;DEBUG;ALTCOVER_TEST;$(ExtraDefines)
+ TRACE;DEBUG;ALTCOVER_TEST;RECORDER2;$(ExtraDefines)
TRACE;RELEASE;ALTCOVER_TEST;$(ExtraDefines)
@@ -25,11 +25,12 @@
AssemblyVersion.fs
-
-
+
+
+
diff --git a/AltCover.Visualizer.Tests/AltCover.Visualizer.Tests.fsproj b/AltCover.Visualizer.Tests/AltCover.Visualizer.Tests.fsproj
index 7e9837aab..f650d4061 100644
--- a/AltCover.Visualizer.Tests/AltCover.Visualizer.Tests.fsproj
+++ b/AltCover.Visualizer.Tests/AltCover.Visualizer.Tests.fsproj
@@ -14,7 +14,7 @@
TRACE;$(GlobalDefineConstants)
-
+
988
diff --git a/Build/Build.fsproj b/Build/Build.fsproj
index c06e48536..37e13afd8 100644
--- a/Build/Build.fsproj
+++ b/Build/Build.fsproj
@@ -1,4 +1,8 @@
+
+
+ NU1902,NU1903,NU1904
+
diff --git a/Build/DriveApi.fsproj b/Build/DriveApi.fsproj
index 1269bde15..f31ff1800 100644
--- a/Build/DriveApi.fsproj
+++ b/Build/DriveApi.fsproj
@@ -3,7 +3,7 @@
Exe
net8.0
- MSB3243
+ MSB3243;NU1902,NU1903,NU1904
diff --git a/Build/Setup.fsproj b/Build/Setup.fsproj
index 108a81cfb..38fc25bf9 100644
--- a/Build/Setup.fsproj
+++ b/Build/Setup.fsproj
@@ -1,5 +1,9 @@
+
+ NU1902,NU1903,NU1904
+
+
diff --git a/Samples/Sample18/Sample18.fsproj b/Samples/Sample18/Sample18.fsproj
index b2b15268b..9c6249cdc 100644
--- a/Samples/Sample18/Sample18.fsproj
+++ b/Samples/Sample18/Sample18.fsproj
@@ -7,7 +7,7 @@
portable
-
+
988
diff --git a/fullbuild.ps1 b/fullbuild.ps1
new file mode 100644
index 000000000..11b868926
--- /dev/null
+++ b/fullbuild.ps1
@@ -0,0 +1,3 @@
+dotnet tool restore
+dotnet run --project .\Build\setup.fsproj
+dotnet run --project .\Build\build.fsproj
\ No newline at end of file