From ded7d61282b331e2c87b708698d4d51131c428b8 Mon Sep 17 00:00:00 2001 From: Chris Holt Date: Thu, 22 Oct 2015 12:41:44 -0600 Subject: [PATCH] Fix #218 --- RELEASE_NOTES.md | 3 +++ src/canopy/AssemblyInfo.fs | 6 +++--- src/canopy/reporters.fs | 10 ++++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index c3796d1e..a7457c00 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -184,3 +184,6 @@ Improve reporting skip for console and TeamCity reporter [Issue #215](https://gi #### 0.9.37 - October 18 2015 Great PR from @LimoWanKenobi that fixed a performance problem with add a lot of tests, thanks! [Issue #217](https://github.com/lefthandedgoat/canopy/issues/217) + +#### 0.9.38 - October 22 2015 +Fix a bug in html reporter trying to describe json, it would fail to because the data was not encoded properly [Issue #218](https://github.com/lefthandedgoat/canopy/issues/218) diff --git a/src/canopy/AssemblyInfo.fs b/src/canopy/AssemblyInfo.fs index fa3dc920..84d5ec61 100644 --- a/src/canopy/AssemblyInfo.fs +++ b/src/canopy/AssemblyInfo.fs @@ -4,9 +4,9 @@ open System.Reflection [] [] [] -[] -[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "0.9.37" + let [] Version = "0.9.38" diff --git a/src/canopy/reporters.fs b/src/canopy/reporters.fs index 95181f9b..27ac4dc4 100644 --- a/src/canopy/reporters.fs +++ b/src/canopy/reporters.fs @@ -217,6 +217,7 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) = let mutable environment = System.String.Empty let testStopWatch = System.Diagnostics.Stopwatch() let contextStopWatch = System.Diagnostics.Stopwatch() + let jsEncode value = System.Web.HttpUtility.JavaScriptStringEncode(value) new() = LiveHtmlReporter(Firefox, String.Empty) new(browser : BrowserStartMode) = LiveHtmlReporter(browser, String.Empty) @@ -234,7 +235,6 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) = then System.IO.Directory.CreateDirectory(directory) |> ignore IO.File.WriteAllText(System.IO.Path.Combine(directory,filename + ".html"), this.reportHtml()) - interface IReporter with member this.pass () = this.swallowedJS (sprintf "updateTestInContext('%s', 'Pass', '%s');" context "") @@ -243,12 +243,13 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) = member this.fail ex id ss url = this.swallowedJS (sprintf "updateTestInContext('%s', 'Fail', '%s');" context (Convert.ToBase64String(ss))) let stack = sprintf "%s%s%s" ex.Message System.Environment.NewLine ex.StackTrace - let stack = System.Web.HttpUtility.JavaScriptStringEncode(stack) + let stack = jsEncode stack this.swallowedJS (sprintf "addStackToTest ('%s', '%s');" context stack) this.swallowedJS (sprintf "addUrlToTest ('%s', '%s');" context url) consoleReporter.fail ex id ss url member this.describe d = + let d = jsEncode d this.swallowedJS (sprintf "addMessageToTest ('%s', '%s');" context d) consoleReporter.describe d @@ -256,7 +257,7 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) = contextStopWatch.Reset() contextStopWatch.Start() contexts <- c :: contexts - context <- System.Web.HttpUtility.JavaScriptStringEncode(c) + context <- jsEncode c this.swallowedJS (sprintf "addContext('%s');" context) this.swallowedJS (sprintf "collapseContextsExcept('%s');" context) consoleReporter.contextStart c @@ -272,6 +273,7 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) = consoleReporter.summary minutes seconds passed failed skipped member this.write w = + let w = jsEncode w this.swallowedJS (sprintf "addMessageToTest ('%s', '%s');" context w) consoleReporter.write w @@ -281,7 +283,7 @@ type LiveHtmlReporter(browser : BrowserStartMode, driverPath : string) = member this.testStart id = testStopWatch.Reset() testStopWatch.Start() - test <- System.Web.HttpUtility.JavaScriptStringEncode(id) + test <- jsEncode id this.swallowedJS (sprintf "addToContext ('%s', '%s');" context test) consoleReporter.testStart id