@@ -932,16 +932,20 @@ public void BlazorAddRazorButton(string buttonText, string customCode, string me
932
932
File . WriteAllText ( counterRazorPath , oldContent + additionalCode ) ;
933
933
}
934
934
935
+ // Keeping these methods with explicit Build/Publish in the name
936
+ // so in the test code it is evident which is being run!
935
937
public Task BlazorRunForBuildWithDotnetRun ( string config , Func < IPage , Task > ? test = null , string extraArgs = "--no-build" )
936
938
=> BlazorRunTest ( $ "run -c { config } { extraArgs } ", _projectDir ! , test ) ;
937
939
938
-
939
940
public Task BlazorRunForPublishWithWebServer ( string config , Func < IPage , Task > ? test = null , string extraArgs = "" )
940
941
=> BlazorRunTest ( $ "{ s_xharnessRunnerCommand } wasm webserver --app=. --web-server-use-default-files { extraArgs } ",
941
942
Path . GetFullPath ( Path . Combine ( FindBlazorBinFrameworkDir ( config , forPublish : true ) , ".." ) ) ,
942
943
test ) ;
943
944
944
- public async Task BlazorRunTest ( string runArgs , string workingDirectory , Func < IPage , Task > ? test = null )
945
+ public async Task BlazorRunTest ( string runArgs ,
946
+ string workingDirectory ,
947
+ Func < IPage , Task > ? test = null ,
948
+ bool detectRuntimeFailures = true )
945
949
{
946
950
using var runCommand = new RunCommand ( s_buildEnv , _testOutput )
947
951
. WithWorkingDirectory ( workingDirectory ) ;
@@ -965,6 +969,12 @@ void OnConsoleMessage(IConsoleMessage msg)
965
969
if ( EnvironmentVariables . ShowBuildOutput )
966
970
Console . WriteLine ( $ "[{ msg . Type } ] { msg . Text } ") ;
967
971
_testOutput . WriteLine ( $ "[{ msg . Type } ] { msg . Text } ") ;
972
+
973
+ if ( detectRuntimeFailures )
974
+ {
975
+ if ( msg . Text . Contains ( "[MONO] * Assertion" ) || msg . Text . Contains ( "Error: [MONO] " ) )
976
+ throw new XunitException ( $ "Detected a runtime failure at line: { msg . Text } ") ;
977
+ }
968
978
}
969
979
}
970
980
0 commit comments