-
Notifications
You must be signed in to change notification settings - Fork 585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes To Target Traces #2016
Fixes To Target Traces #2016
Changes from 2 commits
5ffa1cb
74e60c9
4482bbb
e993402
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,10 @@ and [<NoComparison>] [<NoEquality>] TargetContext = | |
member x.HasError = | ||
x.PreviousTargets | ||
|> List.exists (fun t -> t.Error.IsSome) | ||
member x.LastTargetError = | ||
x.PreviousTargets | ||
|> List.last | ||
|> fun x -> x.Error.IsSome | ||
member x.TryFindPrevious name = | ||
x.PreviousTargets |> List.tryFind (fun t -> t.Target.Name = name) | ||
member x.TryFindTarget name = | ||
|
@@ -318,9 +322,9 @@ module Target = | |
|> Seq.map (fun kv -> kv.Key) | ||
|> Seq.fold (fun context name -> | ||
let target = get name | ||
use t = Trace.traceFinalTarget target.Name (match target.Description with Some d -> d | _ -> null) (dependencyString target) | ||
use t = Trace.traceFinalTarget target.Name target.Description (dependencyString target) | ||
let res = runSimpleContextInternal target context | ||
if res.HasError | ||
if res.LastTargetError | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another way would be to let runSimpleContextInternal return the state of the target it executed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ooooh even nicer! |
||
then t.MarkFailed() | ||
else t.MarkSuccess() | ||
res | ||
|
@@ -334,9 +338,9 @@ module Target = | |
|> Seq.map (fun kv -> kv.Key) | ||
|> Seq.fold (fun context name -> | ||
let target = get name | ||
use t = Trace.traceFailureTarget target.Name (match target.Description with Some d -> d | _ -> null) (dependencyString target) | ||
use t = Trace.traceFailureTarget target.Name target.Description (dependencyString target) | ||
let res = runSimpleContextInternal target context | ||
if res.HasError | ||
if res.LastTargetError | ||
then t.MarkFailed() | ||
else t.MarkSuccess() | ||
res | ||
|
@@ -506,9 +510,9 @@ module Target = | |
/// Runs a single target without its dependencies... only when no error has been detected yet. | ||
let internal runSingleTarget (target : Target) (context:TargetContext) = | ||
if not context.HasError then | ||
use t = Trace.traceTarget target.Name (match target.Description with Some d -> d | _ -> null) (dependencyString target) | ||
use t = Trace.traceTarget target.Name target.Description (dependencyString target) | ||
let res = runSimpleContextInternal target context | ||
if res.HasError | ||
if res.LastTargetError | ||
then t.MarkFailed() | ||
else t.MarkSuccess() | ||
res | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,10 +124,11 @@ let traceHeader name = | |
traceLine() | ||
|
||
/// Puts an opening tag on the internal tag stack | ||
let openTagUnsafe tag (description:string) = | ||
let openTagUnsafe tag description = | ||
let sw = System.Diagnostics.Stopwatch.StartNew() | ||
openTags.Value <- (sw, tag) :: openTags.Value | ||
TraceData.OpenTag(tag, if System.String.IsNullOrEmpty description then None else Some description) |> CoreTracing.postMessage | ||
let descriptionOption = if System.String.IsNullOrEmpty description then None else Some description | ||
TraceData.OpenTag(tag, descriptionOption) |> CoreTracing.postMessage | ||
|
||
type ISafeDisposable = | ||
inherit System.IDisposable | ||
|
@@ -225,20 +226,25 @@ let traceEndTargetUnsafe name = | |
[<System.Obsolete("Consider using traceTarget instead and 'use' to properly call traceEndTask in case of exceptions. To remove this warning use 'traceEndTargetUnsafe'.")>] | ||
let traceEndTarget name = traceEndTargetUnsafe name | ||
|
||
let private optionDescriptionToNullable description = | ||
match description with | ||
| Some d -> d | ||
| _ -> null | ||
|
||
let traceTarget name description dependencyString = | ||
traceStartTargetUnsafe name description dependencyString | ||
traceStartTargetUnsafe name (optionDescriptionToNullable description) dependencyString | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But this changes the public API of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could maybe add an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was my argument 😆 I was also tempted to put the internal modifier, but then because of modules we can't since targets are not internal to trace. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok i'll revert this then and have the narly logic in targets :( |
||
asSafeDisposable (fun state -> traceEndTargetUnsafeEx state name) | ||
|
||
let traceFinalTarget name description dependencyString = | ||
traceStartFinalTargetUnsafe name description dependencyString | ||
traceStartFinalTargetUnsafe name (optionDescriptionToNullable description) dependencyString | ||
asSafeDisposable (fun state -> traceEndFinalTargetUnsafeEx state name) | ||
|
||
let traceFailureTarget name description dependencyString = | ||
traceStartFailureTargetUnsafe name description dependencyString | ||
traceStartFailureTargetUnsafe name (optionDescriptionToNullable description) dependencyString | ||
asSafeDisposable (fun state -> traceEndFailureTargetUnsafeEx state name) | ||
|
||
/// Traces the begin of a task | ||
let traceStartTaskUnsafe task (description:string) = | ||
let traceStartTaskUnsafe task description = | ||
openTagUnsafe (KnownTags.Task task) description | ||
|
||
/// Traces the begin of a task | ||
|
@@ -257,7 +263,7 @@ let traceEndTaskUnsafe task = traceEndTaskUnsafeEx TagStatus.Success task | |
let traceEndTask task = traceEndTaskUnsafe task | ||
|
||
/// Wrap functions in a 'use' of this function | ||
let traceTask name (description:string) = | ||
let traceTask name description = | ||
traceStartTaskUnsafe name description | ||
asSafeDisposable (fun state -> traceEndTaskUnsafeEx state name) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strictly speaking LastTargetError needs to be a
bool option
as thePreviousTargets
list might be empty...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh your so right...fixing now