Skip to content

Commit

Permalink
Fixing tests for #357
Browse files Browse the repository at this point in the history
  • Loading branch information
haf committed Jul 1, 2018
1 parent 1f979b0 commit efa3e1c
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 22 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#### 5.0.0-beta.21
* Fix #357 — for simple exns
* Fix #357 — for AggregateException
* Rename `StacktraceParse.InnerDelim` -> `StacktraceParse.StacktraceDelim`, since it's being used for non-inner stacktrace delimitations.

#### 5.0.0-beta.20
* Enable access to Suave.HttpContext for HTTP ingestion
Expand Down
2 changes: 1 addition & 1 deletion src/Logary.Facade.Tests/Logary.Facade.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Logary.Facade.Tests</AssemblyName>
<Version>5.0.0-beta.20</Version>
<Version>5.0.0-beta.21</Version>
<Version>5.0.0-beta.12</Version>
<OutputType>Exe</OutputType>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
Expand Down
2 changes: 1 addition & 1 deletion src/Logary.Facade/Logary.Facade.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Logary.Facade</AssemblyName>
<Version>5.0.0-beta.20</Version>
<Version>5.0.0-beta.21</Version>
<Version>5.0.0-beta.12</Version>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Logary.PerfTests/Logary.PerfTests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
<Version>5.0.0-beta.20</Version>
<Version>5.0.0-beta.21</Version>
<OutputType>Exe</OutputType>
<ServerGarbageCollection>true</ServerGarbageCollection>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Expand Down
13 changes: 8 additions & 5 deletions src/Logary.Tests/Literate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ let tokenisation =
let expected =
[ "-", MessageTemplates.Formatting.Literate.Subtext // newline
"System.Exception: Top level exn", MessageTemplates.Formatting.Literate.Text
"Logary.Tests.LiterateConsole.throwAnotherExn@65(Exception inner)", MessageTemplates.Formatting.Literate.Subtext
"--- End of inner exception stack trace ---", MessageTemplates.Formatting.Literate.Punctuation
"Logary.Tests.LiterateConsole.throwAnotherExn@19(Exception inner)", MessageTemplates.Formatting.Literate.Subtext
"--- End of exception stack trace ---", MessageTemplates.Formatting.Literate.Punctuation
"System.Exception: Bad things going on", MessageTemplates.Formatting.Literate.Text
"Logary.Tests.Utils.innermost[a]()", MessageTemplates.Formatting.Literate.Subtext
]
Expand All @@ -46,14 +46,17 @@ let tokenisation =
let expected =
[ "-", MessageTemplates.Formatting.Literate.Subtext // newline
"System.AggregateException: Outer aggregate exception (Bad things going on) (Bad things going on)", MessageTemplates.Formatting.Literate.Text
"Logary.Tests.LiterateConsole.throwAggrExn@69(Exception inner)", MessageTemplates.Formatting.Literate.Subtext
"--- End of inner exception stack trace ---", MessageTemplates.Formatting.Literate.Punctuation
"Logary.Tests.LiterateConsole.throwAggrExn@23(Exception inner1, Exception inner2)", MessageTemplates.Formatting.Literate.Subtext
"--- End of exception stack trace ---", MessageTemplates.Formatting.Literate.Punctuation
"System.Exception: Bad things going on", MessageTemplates.Formatting.Literate.Text
"Logary.Tests.Utils.innermost[a]()", MessageTemplates.Formatting.Literate.Subtext
"--- End of exception stack trace ---", MessageTemplates.Formatting.Literate.Punctuation
"System.Exception: Bad things going on", MessageTemplates.Formatting.Literate.Text
"Logary.Tests.Utils.innermost[a]()", MessageTemplates.Formatting.Literate.Subtext
]
Message.event Warn "My error" |> Message.addExn exnOuter
|> Literate.tokeniseExceptions Culture.invariant "-"
|> Expect.sequenceEqual "Has correct output" expected
|> Expect.sequenceContainsOrder "Has correct output" expected
]

module LiterateTesting =
Expand Down
2 changes: 1 addition & 1 deletion src/Logary.Tests/Logary.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Version>5.0.0-beta.20</Version>
<Version>5.0.0-beta.21</Version>
<Version>5.0.0-beta.12</Version>
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
<NoWarn>44</NoWarn>
Expand Down
22 changes: 15 additions & 7 deletions src/Logary.Tests/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ module Expect =

open System.Text

let printSeq (xs: #seq<_>): string =
xs |> Seq.mapi (fun i x -> sprintf " [%i] %A" i x) |> String.concat Environment.NewLine

/// This will pass:
///
/// [ 1; 2; 3; 4; 5; 6 ]
Expand All @@ -249,17 +252,22 @@ module Expect =
let el = System.Collections.Generic.Queue<'t> expectedSub
use ae = actual.GetEnumerator()
let al = ResizeArray<'t>()
let nl = Environment.NewLine

let rec iter i =
if el.Count = 0 then (* success *) () else
if not (ae.MoveNext()) then failwithf "Remainder %A of expected enumerable, after going through actual enumerable." el else
al.Add ae.Current
let expected = el.Peek()
if expected = ae.Current then
ignore (el.Dequeue())
iter (i + 1)
if not (ae.MoveNext()) then
failtestf
"Remainder of expected enumerable:%s%s%sWent through actual enumerable (%i items):%s%s"
nl (printSeq el) nl i nl (printSeq al)
else
iter (i + 1)
al.Add ae.Current
let expected = el.Peek()
if expected = ae.Current then
ignore (el.Dequeue())
iter (i + 1)
else
iter (i + 1)

iter 0

Expand Down
4 changes: 2 additions & 2 deletions src/Logary/Formatting/DotNetStacktrace.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type StacktraceLine =
/// " at ServiceStack.ServiceClient.Web.ServiceClientBase.Send[TResponse](String httpMethod, String relativeOrAbsoluteUrl, Object request)"
| Line of line:StacktraceLineData
/// "--- End of inner exception stack trace ---"
| InnerDelim
| StacktraceDelim
/// WRN: Assembly binding logging is turned OFF.
| LineOutput of data:string

Expand All @@ -35,7 +35,7 @@ module DotNetStacktrace =
let lineNo = let ln = mline.Groups.["lineNo"] in if String.IsNullOrWhiteSpace ln.Value then None else Some (int ln.Value)
Match (Line { site = site; file = file; lineNo = lineNo })
elif mdelim.Success then
Match InnerDelim
Match StacktraceDelim
else
let mexnt = mexnt.Match line
if mexnt.Success then
Expand Down
7 changes: 4 additions & 3 deletions src/Logary/Formatting/Literate.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ module Literate =
yield "line ", Subtext
yield Option.get line.lineNo |> string, NumericSymbol
]
| StacktraceLine.InnerDelim ->
[ "--- End of inner exception stack trace ---", Punctuation ]
| StacktraceLine.StacktraceDelim ->
[ "--- End of exception stack trace ---", Punctuation ]

/// Iterates through an exception hierarchy and uses `DotNetStacktrace.parse` on the stacktraces, yielding a
/// the lines (outer list), each consisting of a string and a literate token specifying how that string is to be
Expand All @@ -44,6 +44,7 @@ module Literate =
for e in ae.InnerExceptions do
i <- i + 1
let firstLine, remainder = tokeniseException e |> Seq.headTail
yield printLine StacktraceDelim
yield [
yield sprintf "Inner exn#", Subtext
yield string i, NumericSymbol
Expand All @@ -53,7 +54,7 @@ module Literate =
yield! remainder

| _ when not (isNull e.InnerException) ->
yield printLine InnerDelim
yield printLine StacktraceDelim
yield! tokeniseException e.InnerException
| _ ->
()
Expand Down
2 changes: 1 addition & 1 deletion src/Logary/Logary.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Logary</AssemblyName>
<Version>5.0.0-beta.20</Version>
<Version>5.0.0-beta.21</Version>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<NoWarn>44;2003</NoWarn>
<DefineConstants>TYPESHAPE_EXPOSE</DefineConstants>
Expand Down

0 comments on commit efa3e1c

Please sign in to comment.