protected string RunAndTestWasmApp(BuildArgs buildArgs, RunHost host, string id, Action <string>?test = null, string?buildDir = null, int expectedExitCode = 0, string?args = null, Dictionary <string, string>?envVars = null) { buildDir ??= _projectDir; envVars ??= new(); envVars["XHARNESS_DISABLE_COLORED_OUTPUT"] = "true"; if (buildArgs.AOT) { envVars["EMSDK_PATH"] = s_emsdkPath; envVars["MONO_LOG_LEVEL"] = "debug"; envVars["MONO_LOG_MASK"] = "aot"; } string bundleDir = Path.Combine(GetBinDir(baseDir: buildDir, config: buildArgs.Config), "AppBundle"); (string testCommand, string extraXHarnessArgs) = host switch { RunHost.V8 => ("wasm test", "--js-file=runtime.js --engine=V8 -v trace"), _ => ("wasm test-browser", $"-v trace -b {host}") }; string testLogPath = Path.Combine(_logPath, host.ToString()); string output = RunWithXHarness( testCommand, testLogPath, buildArgs.ProjectName, bundleDir, _testOutput, envVars: envVars, expectedAppExitCode: expectedExitCode, extraXHarnessArgs: extraXHarnessArgs, appArgs: args); if (buildArgs.AOT) { Assert.Contains("AOT: image 'System.Private.CoreLib' found.", output); Assert.Contains($"AOT: image '{buildArgs.ProjectName}' found.", output); } else { Assert.DoesNotContain("AOT: image 'System.Private.CoreLib' found.", output); Assert.DoesNotContain($"AOT: image '{buildArgs.ProjectName}' found.", output); } if (test != null) { test(output); } return(output); }
protected string RunAndTestWasmApp(BuildArgs buildArgs, RunHost host, string id, Action <string>?test = null, string?buildDir = null, int expectedExitCode = 0, string?args = null, Dictionary <string, string>?envVars = null, string targetFramework = DefaultTargetFramework, string?extraXHarnessMonoArgs = null) { buildDir ??= _projectDir; envVars ??= new(); envVars["XHARNESS_DISABLE_COLORED_OUTPUT"] = "true"; if (buildArgs.AOT) { envVars["MONO_LOG_LEVEL"] = "debug"; envVars["MONO_LOG_MASK"] = "aot"; } if (s_buildEnv.EnvVars != null) { foreach (var kvp in s_buildEnv.EnvVars) { envVars[kvp.Key] = kvp.Value; } } string bundleDir = Path.Combine(GetBinDir(baseDir: buildDir, config: buildArgs.Config, targetFramework: targetFramework), "AppBundle"); (string testCommand, string extraXHarnessArgs) = host switch { RunHost.V8 => ("wasm test", "--js-file=test-main.js --engine=V8 -v trace"), RunHost.NodeJS => ("wasm test", "--js-file=test-main.js --engine=NodeJS -v trace"), _ => ("wasm test-browser", $"-v trace -b {host} --web-server-use-cop") }; string testLogPath = Path.Combine(_logPath, host.ToString()); string output = RunWithXHarness( testCommand, testLogPath, buildArgs.ProjectName, bundleDir, _testOutput, envVars: envVars, expectedAppExitCode: expectedExitCode, extraXHarnessArgs: extraXHarnessArgs, appArgs: args, extraXHarnessMonoArgs: extraXHarnessMonoArgs ); if (buildArgs.AOT) { Assert.Contains("AOT: image 'System.Private.CoreLib' found.", output); Assert.Contains($"AOT: image '{buildArgs.ProjectName}' found.", output); } else { Assert.DoesNotContain("AOT: image 'System.Private.CoreLib' found.", output); Assert.DoesNotContain($"AOT: image '{buildArgs.ProjectName}' found.", output); } if (test != null) { test(output); } return(output); }
protected string RunAndTestWasmApp(BuildArgs buildArgs, RunHost host, string id, Action <string>?test = null, string?buildDir = null, string?bundleDir = null, int expectedExitCode = 0, string?args = null, Dictionary <string, string>?envVars = null, string targetFramework = DefaultTargetFramework, string?extraXHarnessMonoArgs = null, string jsRelativePath = "test-main.js") { buildDir ??= _projectDir; envVars ??= new(); envVars["XHARNESS_DISABLE_COLORED_OUTPUT"] = "true"; if (buildArgs.AOT) { envVars["MONO_LOG_LEVEL"] = "debug"; envVars["MONO_LOG_MASK"] = "aot"; } if (s_buildEnv.EnvVars != null) { foreach (var kvp in s_buildEnv.EnvVars) { envVars[kvp.Key] = kvp.Value; } } bundleDir ??= Path.Combine(GetBinDir(baseDir: buildDir, config: buildArgs.Config, targetFramework: targetFramework), "AppBundle"); if (host is RunHost.V8 && OperatingSystem.IsWindows()) { throw new InvalidOperationException("Running tests with V8 on windows isn't supported"); } // Use wasm-console.log to get the xharness output for non-browser cases (string testCommand, string extraXHarnessArgs, bool useWasmConsoleOutput) = host switch { RunHost.V8 => ("wasm test", $"--js-file={jsRelativePath} --engine=V8 -v trace", true), RunHost.NodeJS => ("wasm test", $"--js-file={jsRelativePath} --engine=NodeJS -v trace", true), _ => ("wasm test-browser", $"-v trace -b {host} --web-server-use-cop", false) }; string testLogPath = Path.Combine(_logPath, host.ToString()); string output = RunWithXHarness( testCommand, testLogPath, buildArgs.ProjectName, bundleDir, _testOutput, envVars: envVars, expectedAppExitCode: expectedExitCode, extraXHarnessArgs: extraXHarnessArgs, appArgs: args, extraXHarnessMonoArgs: extraXHarnessMonoArgs, useWasmConsoleOutput: useWasmConsoleOutput ); if (buildArgs.AOT) { Assert.Contains("AOT: image 'System.Private.CoreLib' found.", output); Assert.Contains($"AOT: image '{buildArgs.ProjectName}' found.", output); } else { Assert.DoesNotContain("AOT: image 'System.Private.CoreLib' found.", output); Assert.DoesNotContain($"AOT: image '{buildArgs.ProjectName}' found.", output); } if (test != null) { test(output); } return(output); }