Skip to content

Commit 5da43e9

Browse files
committed
Don't write AppVeyor AddMessage calls to trace, don't write empty
1 parent ff639d4 commit 5da43e9

File tree

1 file changed

+43
-39
lines changed

1 file changed

+43
-39
lines changed

src/app/FakeLib/AppVeyor.fs

+43-39
Original file line numberDiff line numberDiff line change
@@ -5,68 +5,68 @@ open System
55
open System.IO
66

77
/// AppVeyor environment variables as [described](http://www.appveyor.com/docs/environment-variables)
8-
type AppVeyorEnvironment =
9-
8+
type AppVeyorEnvironment =
9+
1010
/// AppVeyor Build Agent API URL
1111
static member ApiUrl = environVar "APPVEYOR_API_URL"
1212

1313
/// AppVeyor Account Name
1414
static member AccountName = environVar "APPVEYOR_ACCOUNT_NAME"
15-
15+
1616
/// AppVeyor unique project ID
1717
static member ProjectId = environVar "APPVEYOR_PROJECT_ID"
18-
18+
1919
/// Project name
2020
static member ProjectName = environVar "APPVEYOR_PROJECT_NAME"
21-
21+
2222
/// Project slug (as seen in project details URL)
2323
static member ProjectSlug = environVar "APPVEYOR_PROJECT_SLUG"
24-
24+
2525
/// Path to clone directory
2626
static member BuildFolder = environVar "APPVEYOR_BUILD_FOLDER"
27-
27+
2828
/// AppVeyor unique build ID
2929
static member BuildId = environVar "APPVEYOR_BUILD_ID"
30-
30+
3131
/// Build number
3232
static member BuildNumber = environVar "APPVEYOR_BUILD_NUMBER"
33-
33+
3434
/// Build version
3535
static member BuildVersion = environVar "APPVEYOR_BUILD_VERSION"
36-
36+
3737
/// GitHub Pull Request number
3838
static member PullRequestNumber = environVar "APPVEYOR_PULL_REQUEST_NUMBER"
39-
39+
4040
/// GitHub Pull Request title
4141
static member PullRequestTitle = environVar "APPVEYOR_PULL_REQUEST_TITLE"
42-
42+
4343
/// AppVeyor unique job ID
4444
static member JobId = environVar "APPVEYOR_JOB_ID"
45-
45+
4646
/// GitHub, BitBucket or Kiln
4747
static member RepoProvider = environVar "APPVEYOR_REPO_PROVIDER"
48-
48+
4949
/// git or mercurial
5050
static member RepoScm = environVar "APPVEYOR_REPO_SCM"
51-
51+
5252
/// Repository name in format owner-name/repo-name
5353
static member RepoName = environVar "APPVEYOR_REPO_NAME"
54-
54+
5555
/// Build branch
5656
static member RepoBranch = environVar "APPVEYOR_REPO_BRANCH"
57-
57+
5858
/// Commit ID (SHA)
5959
static member RepoCommit = environVar "APPVEYOR_REPO_COMMIT"
60-
60+
6161
/// Commit author's name
6262
static member RepoCommitAuthor = environVar "APPVEYOR_REPO_COMMIT_AUTHOR"
63-
63+
6464
/// Commit author's email address
6565
static member RepoCommitAuthorEmail = environVar "APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL"
66-
66+
6767
/// Commit date/time
6868
static member RepoCommitTimestamp = environVar "APPVEYOR_REPO_COMMIT_TIMESTAMP"
69-
69+
7070
/// Commit message
7171
static member RepoCommitMessage = environVar "APPVEYOR_REPO_COMMIT_MESSAGE"
7272

@@ -81,7 +81,7 @@ type AppVeyorEnvironment =
8181

8282
/// If the build has been started by the "Re-Build commit/PR" button or from the same API
8383
static member IsReBuild = environVar "APPVEYOR_RE_BUILD"
84-
84+
8585
/// true if build has started by pushed tag; otherwise false
8686
static member RepoTag =
8787
let rt = environVar "APPVEYOR_REPO_TAG"
@@ -93,31 +93,35 @@ type AppVeyorEnvironment =
9393
/// Platform name set on Build tab of project settings (or through platform parameter in appveyor.yml).
9494
static member Platform = environVar "PLATFORM"
9595

96-
/// Configuration name set on Build tab of project settings (or through configuration parameter in appveyor.yml).
96+
/// Configuration name set on Build tab of project settings (or through configuration parameter in appveyor.yml).
9797
static member Configuration = environVar "CONFIGURATION"
9898

9999
/// The job name
100100
static member JobName = environVar "APPVEYOR_JOB_NAME"
101-
102-
let private sendToAppVeyor args =
103-
ExecProcess (fun info ->
101+
102+
let private sendToAppVeyor args =
103+
ExecProcess (fun info ->
104104
info.FileName <- "appveyor"
105105
info.Arguments <- args) (System.TimeSpan.MaxValue)
106106
|> ignore
107107

108-
let private add msg category =
109-
sprintf "AddMessage %s -Category %s" (quoteIfNeeded msg) (quoteIfNeeded category) |> sendToAppVeyor
108+
let private add msg category =
109+
let enableProcessTracingPreviousValue = enableProcessTracing
110+
enableProcessTracing <- false
111+
if not <| isNullOrEmpty msg then
112+
sprintf "AddMessage %s -Category %s" (quoteIfNeeded msg) (quoteIfNeeded category) |> sendToAppVeyor
113+
enableProcessTracing <- enableProcessTracingPreviousValue
110114
let private addNoCategory msg = sprintf "AddMessage %s" (quoteIfNeeded msg) |> sendToAppVeyor
111115

112116
// Add trace listener to track messages
113-
if buildServer = BuildServer.AppVeyor then
117+
if buildServer = BuildServer.AppVeyor then
114118
{ new ITraceListener with
115-
member this.Write msg =
119+
member this.Write msg =
116120
match msg with
117121
| ErrorMessage x -> add x "Error"
118122
| ImportantMessage x -> add x "Warning"
119123
| LogMessage(x, _) -> add x "Information"
120-
| TraceMessage(x, _) ->
124+
| TraceMessage(x, _) ->
121125
if not enableProcessTracing then addNoCategory x
122126
| StartMessage | FinishedMessage | OpenTag(_, _) | CloseTag _ -> () }
123127
|> listeners.Add
@@ -129,23 +133,23 @@ let FinishTestSuite testSuiteName = () // Nothing in API yet
129133
let StartTestSuite testSuiteName = () // Nothing in API yet
130134

131135
/// Starts the test case.
132-
let StartTestCase testSuiteName testCaseName =
136+
let StartTestCase testSuiteName testCaseName =
133137
sendToAppVeyor <| sprintf "AddTest \"%s\" -Outcome Running" (testSuiteName + " - " + testCaseName)
134138

135139
/// Reports a failed test.
136-
let TestFailed testSuiteName testCaseName message details =
140+
let TestFailed testSuiteName testCaseName message details =
137141
sendToAppVeyor <| sprintf "UpdateTest \"%s\" -Outcome Failed -ErrorMessage %s -ErrorStackTrace %s" (testSuiteName + " - " + testCaseName)
138142
(EncapsulateSpecialChars message) (EncapsulateSpecialChars details)
139143

140-
/// Ignores the test case.
144+
/// Ignores the test case.
141145
let IgnoreTestCase testSuiteName testCaseName message = sendToAppVeyor <| sprintf "UpdateTest \"%s\" -Outcome Ignored" (testSuiteName + " - " + testCaseName)
142146

143147
/// Reports a succeeded test.
144148
let TestSucceeded testSuiteName testCaseName = sendToAppVeyor <| sprintf "UpdateTest \"%s\" -Outcome Passed" (testSuiteName + " - " + testCaseName)
145149

146150
/// Finishes the test case.
147-
let FinishTestCase testSuiteName testCaseName (duration : System.TimeSpan) =
148-
let duration =
151+
let FinishTestCase testSuiteName testCaseName (duration : System.TimeSpan) =
152+
let duration =
149153
duration.TotalMilliseconds
150154
|> round
151155
|> string
@@ -238,7 +242,7 @@ let PushArtifacts paths =
238242

239243
/// AppVeyor parameters for update build as [described](https://www.appveyor.com/docs/build-worker-api/#update-build-details)
240244
[<CLIMutable>]
241-
type UpdateBuildParams =
245+
type UpdateBuildParams =
242246
{ /// Build version; must be unique for the current project
243247
Version : string
244248
/// Commit message
@@ -271,7 +275,7 @@ let UpdateBuild (setParams : UpdateBuildParams -> UpdateBuildParams) =
271275
if buildServer = BuildServer.AppVeyor then
272276
let parameters = setParams defaultUpdateBuildParams
273277

274-
let committedStr =
278+
let committedStr =
275279
match parameters.Committed with
276280
| Some x -> x.ToString("o")
277281
| None -> ""
@@ -290,5 +294,5 @@ let UpdateBuild (setParams : UpdateBuildParams -> UpdateBuildParams) =
290294
|> sendToAppVeyor
291295

292296
/// Update build version. This must be unique for the current project.
293-
let UpdateBuildVersion version =
297+
let UpdateBuildVersion version =
294298
UpdateBuild (fun p -> { p with Version = version })

0 commit comments

Comments
 (0)