Skip to content

Commit 60f254f

Browse files
committed
Implemented test execution output redirect to Fake output
1 parent c5743ba commit 60f254f

1 file changed

Lines changed: 39 additions & 7 deletions

File tree

build/Program.fs

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Target.create BuildTarget <| fun _ ->
7777
"FSharp.Data.GraphQL.slnx"
7878
|> DotNet.build (fun options -> {
7979
options with
80-
Common = DotNetCli.setVersion options.Common
80+
Common = options.Common.WithRedirectOutput true |> DotNetCli.setVersion
8181
Configuration = configuration
8282
MSBuildParams = {
8383
options.MSBuildParams with
@@ -93,6 +93,8 @@ Target.create BuildTarget <| fun _ ->
9393
let startGraphQLServer (project : string) port (streamRef : DataRef<Stream>) =
9494
CreateProcess.fromRawCommandLine "dotnet" $"run --project {project} --no-build --configuration {configurationString} --urls=http://localhost:%i{port}/"
9595
|> CreateProcess.withStandardInput (CreatePipe streamRef)
96+
|> CreateProcess.redirectOutput
97+
|> CreateProcess.withOutputEventsNotNull Trace.trace Trace.traceError
9698
|> Proc.start
9799
|> ignore
98100

@@ -117,8 +119,8 @@ let runTests (project : string) (args : string) =
117119
]
118120
}
119121
}
120-
.WithCommon
121-
DotNetCli.setVersion)
122+
|> _.WithRedirectOutput(true)
123+
|> _.WithCommon(DotNetCli.setVersion))
122124
project
123125

124126
let starWarsServerStream = StreamRef.Empty
@@ -198,13 +200,36 @@ Target.create UpdateIntrospectionFileTarget <| fun _ ->
198200
.Wait ()
199201
client.Dispose ()
200202

203+
let unitTestsProjectPath =
204+
"tests"
205+
</> "FSharp.Data.GraphQL.Tests"
206+
</> "FSharp.Data.GraphQL.Tests.fsproj"
207+
208+
let integrationTestsProjectPath =
209+
"tests"
210+
</> "FSharp.Data.GraphQL.IntegrationTests"
211+
</> "FSharp.Data.GraphQL.IntegrationTests.fsproj"
212+
213+
let [<Literal>] BuildIntegrationTestsTarget = "BuildIntegrationTests"
214+
Target.create BuildIntegrationTestsTarget <| fun _ ->
215+
integrationTestsProjectPath
216+
|> DotNet.build (fun options -> {
217+
options with
218+
Configuration = configuration
219+
MSBuildParams = {
220+
options.MSBuildParams with
221+
DisableInternalBinLog = true
222+
}
223+
Common = DotNetCli.setVersion options.Common
224+
})
225+
201226
let [<Literal>] RunUnitTestsTarget = "RunUnitTests"
202227
Target.create RunUnitTestsTarget <| fun _ ->
203-
runTests "tests/FSharp.Data.GraphQL.Tests/FSharp.Data.GraphQL.Tests.fsproj" ""
228+
runTests unitTestsProjectPath ""
204229

205230
let [<Literal>] RunIntegrationTestsTarget = "RunIntegrationTests"
206231
Target.create RunIntegrationTestsTarget <| fun _ ->
207-
runTests "tests/FSharp.Data.GraphQL.IntegrationTests/FSharp.Data.GraphQL.IntegrationTests.fsproj" "" //"--filter Execution=Sync"
232+
runTests integrationTestsProjectPath "" //"--filter Execution=Sync"
208233

209234
let prepareDocGen () =
210235
Shell.rm "docs/release-notes.md"
@@ -220,12 +245,18 @@ let prepareDocGen () =
220245
let [<Literal>] GenerateDocsTarget = "GenerateDocs"
221246
Target.create GenerateDocsTarget <| fun _ ->
222247
prepareDocGen ()
223-
DotNet.exec DotNetCli.setVersion "fsdocs" "build --clean" |> ignore
248+
let result = DotNet.exec DotNetCli.setVersion "fsdocs" "build --clean"
249+
if not result.OK then
250+
result.Errors |> Seq.iter (Trace.traceError)
251+
failwithf "fsdocs build failed with exit code %d" result.ExitCode
224252

225253
let [<Literal>] GenerateDocsWatchTarget = "GenerateDocsWatch"
226254
Target.create GenerateDocsWatchTarget <| fun _ ->
227255
prepareDocGen ()
228-
DotNet.exec DotNetCli.setVersion "fsdocs" "watch --clean" |> ignore
256+
let result = DotNet.exec DotNetCli.setVersion "fsdocs" "watch --clean"
257+
if not result.OK then
258+
result.Errors |> Seq.iter (Trace.traceError)
259+
failwithf "fsdocs watch failed with exit code %d" result.ExitCode
229260
System.Console.ReadKey () |> ignore
230261

231262
let [<Literal>] ReleaseDocsTarget = "ReleaseDocs"
@@ -379,6 +410,7 @@ Target.create "PackAndPush" ignore
379410
==> BuildIntegrationTestServerTarget
380411
==> StartIntegrationServerTarget
381412
==> UpdateIntrospectionFileTarget
413+
==> BuildIntegrationTestsTarget
382414
==> RunIntegrationTestsTarget
383415
==> "All"
384416
=?> (GenerateDocsTarget, Environment.environVar "GITHUB_ACTIONS" = "True")

0 commit comments

Comments
 (0)