Skip to content

Commit

Permalink
Test explorer stability: Use test results as main truth source for ex…
Browse files Browse the repository at this point in the history
…plorer (#1874)

Co-authored-by: Chet Husk <[email protected]>
  • Loading branch information
farlee2121 and baronfel committed Aug 19, 2023
1 parent 6e4ae40 commit cd3cd53
Show file tree
Hide file tree
Showing 4 changed files with 1,567 additions and 369 deletions.
8 changes: 7 additions & 1 deletion release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,12 @@
}
]
},
"viewsWelcome": [
{
"view": "testing",
"contents": "Build your projects then refresh this explorer to discover F# and .NET tests"
}
],
"viewsContainers": {
"activitybar": [
{
Expand Down Expand Up @@ -1748,4 +1754,4 @@
"url": "https://github.com/ionide/ionide-vscode-fsharp.git"
},
"version": "7.8.5"
}
}
73 changes: 73 additions & 0 deletions src/Components/MSBuild.fs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,79 @@ module MSBuild =
| Ok msbuild -> Promise.lift msbuild
| Error msg -> Promise.reject (exn msg))

let invokeMSBuildWithCancel project target (cancellationToken: CancellationToken) =

if cancellationToken.isCancellationRequested then
promise { return { Code = None; Signal = Some "SIGINT" } }
else
let autoshow =
let cfg = workspace.getConfiguration ()
cfg.get ("FSharp.msbuildAutoshow", false)

let command = [ project; $"/t:%s{target}" ]

let executeWithHost () =
promise {
let! msbuildPath = dotnetBinary ()
let cmd = ResizeArray("msbuild" :: command)
logger.Info("invoking msbuild from %s on %s for target %s", msbuildPath, project, target)

if autoshow then
outputChannel.show (?preserveFocus = None)

let childProcess = Process.spawnWithNotification msbuildPath cmd outputChannel

cancellationToken.onCancellationRequested.Invoke(fun _ ->
if (childProcess.connected) then
childProcess.kill ("SIGINT")

None)
|> ignore

return! childProcess |> Process.toPromise
}

let progressOpts = createEmpty<ProgressOptions>
progressOpts.location <- U2.Case1 ProgressLocation.Window

window.withProgress (
progressOpts,
(fun p ctok ->
promise {
let pm =
{| message = Some $"Running MSBuild '{target}' target on '{project}'"
increment = None |}

p.report pm
let! response = executeWithHost ()

match response.Code with
| Some 0 ->
p.report (
{| message = Some "MSBuild completed successfully"
increment = None |}
)

return response
| Some code ->
p.report (
{| message = Some $"MSBuild failed with code %d{code}"
increment = None |}
)

return response
| None ->
p.report (
{| message = Some "MSBuild failed with an unknown error"
increment = None |}
)

return response
}
|> Promise.toThenable)
)
|> Promise.ofThenable

let invokeMSBuild project target =
let autoshow =
let cfg = workspace.getConfiguration ()
Expand Down
Loading

0 comments on commit cd3cd53

Please sign in to comment.