@@ -56,6 +56,7 @@ public async Task Seed()
56
56
57
57
using var process = Process . Start ( "dotnet" , $ "build \" { s_samplesDir } /seed/dotnet/assembly/BuildFromAssembly.csproj\" ") ;
58
58
await process . WaitForExitAsync ( ) ;
59
+ VerifyExitCode ( process ) ;
59
60
60
61
if ( Debugger . IsAttached || IsWslRemoteTest ( ) )
61
62
{
@@ -121,7 +122,8 @@ public async Task SeedMarkdown()
121
122
var outputPath = nameof ( SeedMarkdown ) ;
122
123
Clean ( samplePath ) ;
123
124
124
- Program . Main ( [ "metadata" , $ "{ samplePath } /docfx.json", "--outputFormat" , "markdown" , "--output" , outputPath ] ) ;
125
+ var exitCode = Program . Main ( [ "metadata" , $ "{ samplePath } /docfx.json", "--outputFormat" , "markdown" , "--output" , outputPath ] ) ;
126
+ Assert . Equal ( 0 , exitCode ) ;
125
127
126
128
await VerifyDirectory ( outputPath ) . AutoVerify ( includeBuildServer : false ) ;
127
129
}
@@ -156,10 +158,12 @@ public Task Extensions()
156
158
#if DEBUG
157
159
using var process = Process . Start ( "dotnet" , $ "build \" { samplePath } /build\" ") ;
158
160
process . WaitForExit ( ) ;
161
+ VerifyExitCode ( process ) ;
159
162
Assert . Equal ( 0 , Exec ( "dotnet" , "run --no-build --project build" , workingDirectory : samplePath ) ) ;
160
163
#else
161
164
using var process = Process . Start ( "dotnet" , $ "build -c Release \" { samplePath } /build\" ") ;
162
165
process . WaitForExit ( ) ;
166
+ VerifyExitCode ( process ) ;
163
167
Assert . Equal ( 0 , Exec ( "dotnet" , "run --no-build -c Release --project build" , workingDirectory : samplePath ) ) ;
164
168
#endif
165
169
@@ -239,4 +243,19 @@ private static bool IsWslRemoteTest([CallerFilePath] string callerFilePath = "")
239
243
return Environment . GetEnvironmentVariable ( "WSLENV" ) != null
240
244
&& callerFilePath . Contains ( '\\ ' , StringComparison . Ordinal ) ; // Contains `\` when build on windows environment.
241
245
}
246
+
247
+ private static void VerifyExitCode ( Process process )
248
+ {
249
+ if ( ! process . HasExited )
250
+ throw new InvalidOperationException ( "Process is not exited yet." ) ;
251
+
252
+ // Gets exit code before closing process.
253
+ var exitCode = process . ExitCode ;
254
+
255
+ // Close process to flush stdout/stderr logs.
256
+ process . Close ( ) ;
257
+
258
+ // Assert exit code
259
+ Assert . Equal ( 0 , exitCode ) ;
260
+ }
242
261
}
0 commit comments