Skip to content

Commit

Permalink
Changes for #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")

This comment has been minimized.

Copy link
@Buthrakaur

Buthrakaur Aug 12, 2014

Why is this escaped string meaning \n instead of real LF character used? Is there any special meaning behind this? The thing is I just didn't get strings with aaaa\n\nbbbb escaped for TC well, because of this function.

The same comment applies to following row with @"\r" instead of "\r".

This comment has been minimized.

Copy link
@lefthandedgoat

lefthandedgoat Aug 14, 2014

Author Owner

Sorry didn't see this earlier. I was just looking at TC documentation and making sure I covered all of the bases. I should probably fixed it like I did on 106? If its not working let me know.

This comment has been minimized.

Copy link
@Buthrakaur

Buthrakaur Aug 14, 2014

I guess you should just omit the at-sign, which escapes the backslash :)

let message = message.Replace("\n", "|n")
let message = message.Replace("\r", "|r")

This comment has been minimized.

Copy link
@lefthandedgoat

lefthandedgoat Aug 14, 2014

Author Owner

Doh! yes. Same on 107 too, thanks.

This comment has been minimized.

Copy link
@lefthandedgoat

lefthandedgoat Aug 14, 2014

Author Owner

2600b0b
Is this causing you a problem now? If so I can do a new nuget build tonight. If not I will just wait til I have other stuff to bundle with it.

This comment has been minimized.

Copy link
@Buthrakaur

Buthrakaur Aug 14, 2014

It's not such a big issue, but new nuget version in one week or so would be great, thanks ;)

This comment has been minimized.

Copy link
@lefthandedgoat

lefthandedgoat Sep 8, 2014

Author Owner

@Buthrakaur this is now in canopy 0.9.14 available on nuget. Sorry for the delay. Had another issue come in that I spent a lot of time getting just right before doing a build.

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.