Skip to content

Commit

Permalink
Changes for lefthandedgoat#154 TC Escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Jul 2, 2014
1 parent 162d373 commit ceded0c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
5 changes: 4 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,7 @@

#### 0.9.11 - May 28 2014
* Upgraded to Selenium 2.42 [Issue #152](https://github.com/lefthandedgoat/canopy/issues/152)
* Chrome is now launched with --test-type flag to hide warning message of deprecated flags [Issue #153](https://github.com/lefthandedgoat/canopy/issues/153)
* Chrome is now launched with --test-type flag to hide warning message of deprecated flags [Issue #153](https://github.com/lefthandedgoat/canopy/issues/153)

#### 0.9.12 - July 2 2014
* Accepted TeamCity Report fix by mattsonlyattack and incorporated other fixes to TC Reporter. Thanks! [Issue #154](https://github.com/lefthandedgoat/canopy/issues/154)
6 changes: 3 additions & 3 deletions src/canopy/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("canopy")>]
[<assembly: AssemblyProductAttribute("canopy")>]
[<assembly: AssemblyDescriptionAttribute("F# web testing framework")>]
[<assembly: AssemblyVersionAttribute("0.9.11")>]
[<assembly: AssemblyFileVersionAttribute("0.9.11")>]
[<assembly: AssemblyVersionAttribute("0.9.12")>]
[<assembly: AssemblyFileVersionAttribute("0.9.12")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "0.9.11"
let [<Literal>] Version = "0.9.12"
36 changes: 27 additions & 9 deletions src/canopy/reporters.fs
Original file line number Diff line number Diff line change
Expand Up @@ -98,35 +98,53 @@ type ConsoleReporter() =

type TeamCityReporter() =
let consoleReporter : IReporter = new ConsoleReporter() :> IReporter

let tcFriendlyMessage (message : string) =
let message = message.Replace("|", "||")
let message = message.Replace("'", "|'")
let message = message.Replace(@"\n", "|n")
let message = message.Replace(@"\r", "|r")
let message = message.Replace(System.Environment.NewLine, "|r|n")
let message = message.Replace(@"\u", "|u")
let message = message.Replace("[", "|[")
let message = message.Replace("]", "|]")
message

interface IReporter with
member this.pass () = consoleReporter.pass ()

member this.fail ex id ss =
consoleReporter.describe (String.Format("##teamcity[testFailed name='{0}' message='{1}']", id, ex.Message.Replace("'", "|'")))
member this.fail ex id ss =
let mutable image = ""
if not (Array.isEmpty ss) then
image <- String.Format("canopy-image({0})", Convert.ToBase64String(ss))

consoleReporter.describe (String.Format("##teamcity[testFailed name='{0}' message='{1}' details='{3}']",
(tcFriendlyMessage id),
(tcFriendlyMessage ex.Message),
(tcFriendlyMessage ex.StackTrace),
(tcFriendlyMessage image)))
consoleReporter.fail ex id ss

member this.describe d =
consoleReporter.describe (String.Format("##teamcity[message text='{0}' status='NORMAL']", d))
consoleReporter.describe (String.Format("##teamcity[message text='{0}' status='NORMAL']", (tcFriendlyMessage d)))
consoleReporter.describe d

member this.contextStart c =
consoleReporter.describe (String.Format("##teamcity[testSuiteStarted name='{0}']", c))
consoleReporter.describe (String.Format("##teamcity[testSuiteStarted name='{0}']", (tcFriendlyMessage c)))
consoleReporter.contextStart c

member this.contextEnd c =
consoleReporter.describe (String.Format("##teamcity[testSuiteFinished name='{0}']", c))
consoleReporter.describe (String.Format("##teamcity[testSuiteFinished name='{0}']", (tcFriendlyMessage c)))
consoleReporter.contextEnd c

member this.summary minutes seconds passed failed =consoleReporter.summary minutes seconds passed failed
member this.summary minutes seconds passed failed = consoleReporter.summary minutes seconds passed failed

member this.write w = consoleReporter.write w

member this.suggestSelectors selector suggestions = consoleReporter.suggestSelectors selector suggestions

member this.testStart id = consoleReporter.describe (String.Format("##teamcity[testStarted name='{0}']", id))
member this.testStart id = consoleReporter.describe (String.Format("##teamcity[testStarted name='{0}']", (tcFriendlyMessage id)))

member this.testEnd id = consoleReporter.describe (String.Format("##teamcity[testFinished name='{0}']", id))
member this.testEnd id = consoleReporter.describe (String.Format("##teamcity[testFinished name='{0}']", (tcFriendlyMessage id)))

member this.quit () = ()

Expand Down
6 changes: 3 additions & 3 deletions tests/basictests/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -552,17 +552,17 @@ context "User Agents tests"
"ChromeWithUserAgent userAgents.iPad should show as iPad" &&& fun _ ->
start <| ChromeWithUserAgent userAgents.iPad
url "http://whatsmyuseragent.com/"
"#body_lbUserAgent" =~ "iPad"
".info" *~ "iPad"

"FirefoxDeviceWithUserAgent userAgents.iPhone should show as iPhone" &&& fun _ ->
start <| FirefoxWithUserAgent userAgents.iPhone
url "http://whatsmyuseragent.com/"
"#body_lbUserAgent" =~ "iPhone"
".info" *~ "iPhone"

"FirefoxDeviceWithUserAgent myagent should show as myagent" &&& fun _ ->
start <| FirefoxWithUserAgent "myagent"
url "http://whatsmyuseragent.com/"
"#body_lbUserAgent" == "myagent"
".info" *~ "myagent"

context "Resize tests"

Expand Down

0 comments on commit ceded0c

Please sign in to comment.