File tree 3 files changed +14
-1
lines changed
TestFixtures/EnvironmentExitCode
3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -493,6 +493,13 @@ public void ShouldThrowExceptionWhenSdkIsNotSupported()
493
493
Assert . StartsWith ( "The sdk 'Unsupported' is not supported" , processResult . StandardError ) ;
494
494
}
495
495
496
+ [ Fact ]
497
+ public void ShouldRespectEnvironmentExitCodeOfTheScript ( )
498
+ {
499
+ var processResult = ScriptTestRunner . Default . ExecuteFixture ( "EnvironmentExitCode" , "--no-cache" ) ;
500
+ Assert . Equal ( 0xA0 , processResult . ExitCode ) ;
501
+ }
502
+
496
503
private static string CreateTestScript ( string scriptFolder )
497
504
{
498
505
string script = @"
Original file line number Diff line number Diff line change
1
+ Environment . ExitCode = 0xA0 ;
2
+ Console . WriteLine ( "Hello World" ) ;
Original file line number Diff line number Diff line change @@ -258,7 +258,11 @@ private static int Wain(string[] args)
258
258
} ;
259
259
260
260
var fileCommand = new ExecuteScriptCommand ( ScriptConsole . Default , logFactory ) ;
261
- return await fileCommand . Run < int , CommandLineScriptGlobals > ( fileCommandOptions ) ;
261
+ var result = await fileCommand . Run < int , CommandLineScriptGlobals > ( fileCommandOptions ) ;
262
+ if ( Environment . ExitCode != 0 ) return Environment . ExitCode ;
263
+
264
+ return result ;
265
+
262
266
}
263
267
else
264
268
{
You can’t perform that action at this time.
0 commit comments