AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: true, targetFramework: DefaultTargetFramework);
- (int exitCode, string output) = RunProcess(s_buildEnv.DotNet, _testOutput, args: $"run --no-build -c {config}", workingDir: _projectDir);
- Assert.Equal(0, exitCode);
- Assert.Contains("Hello, Console!", output);
+ CommandResult res = new RunCommand(s_buildEnv, _testOutput)
+ .WithWorkingDirectory(_projectDir!)
+ .ExecuteWithCapturedOutput($"run --no-silent --no-build -c {config}")
+ .EnsureSuccessful();
+ Assert.Contains("Hello, Console!", res.Output);
if (!_buildContext.TryGetBuildFor(buildArgs, out BuildProduct? product))
throw new XunitException($"Test bug: could not get the build product in the cache");
AssertDotNetJsSymbols(Path.Combine(GetBinDir(config, expectedTFM), "AppBundle"), fromRuntimePack: !relinking, targetFramework: expectedTFM);
- (int exitCode, string output) = RunProcess(s_buildEnv.DotNet, _testOutput, args: $"run --no-build -c {config} x y z", workingDir: _projectDir);
- Assert.Equal(42, exitCode);
+ CommandResult res = new RunCommand(s_buildEnv, _testOutput)
+ .WithWorkingDirectory(_projectDir!)
+ .ExecuteWithCapturedOutput($"run --no-silent --no-build -c {config} x y z")
+ .EnsureExitCode(42);
- Assert.Contains("args[0] = x", output);
- Assert.Contains("args[1] = y", output);
- Assert.Contains("args[2] = z", output);
+ Assert.Contains("args[0] = x", res.Output);
+ Assert.Contains("args[1] = y", res.Output);
+ Assert.Contains("args[2] = z", res.Output);
}
public static TheoryData<bool, bool, string> TestDataForAppBundleDir()
.WithWorkingDirectory(workingDir);
await using var runner = new BrowserRunner(_testOutput);
- var page = await runner.RunAsync(runCommand, $"run -c {config} --project {projectFile} --forward-console");
+ var page = await runner.RunAsync(runCommand, $"run --no-silent -c {config} --project {projectFile} --forward-console");
await runner.WaitForExitMessageAsync(TimeSpan.FromMinutes(2));
Assert.Contains("Hello, Browser!", string.Join(Environment.NewLine, runner.OutputLines));
}
.WithWorkingDirectory(workingDir);
await using var runner = new BrowserRunner(_testOutput);
- var page = await runner.RunAsync(runCommand, $"run -c {config} --no-build --project {projectFile} --forward-console");
+ var page = await runner.RunAsync(runCommand, $"run --no-silent -c {config} --no-build --project {projectFile} --forward-console");
await runner.WaitForExitMessageAsync(TimeSpan.FromMinutes(2));
Assert.Contains("Hello, Browser!", string.Join(Environment.NewLine, runner.OutputLines));
}
string workingDir = runOutsideProjectDirectory ? BuildEnvironment.TmpPath : _projectDir!;
{
- string runArgs = $"run -c {config} --project {projectFile}";
+ string runArgs = $"run --no-silent -c {config} --project {projectFile}";
runArgs += " x y z";
using var cmd = new RunCommand(s_buildEnv, _testOutput, label: id)
.WithWorkingDirectory(workingDir)
{
// Run with --no-build
- string runArgs = $"run -c {config} --project {projectFile} --no-build";
+ string runArgs = $"run --no-silent -c {config} --project {projectFile} --no-build";
runArgs += " x y z";
using var cmd = new RunCommand(s_buildEnv, _testOutput, label: id)
.WithWorkingDirectory(workingDir);
AssertFilesDontExist(Path.Combine(GetBinDir(config), "AppBundle"), new[] { "dotnet.native.js.symbols" });
}
- string runArgs = $"run --no-build -c {config}";
+ string runArgs = $"run --no-silent --no-build -c {config}";
runArgs += " x y z";
var res = new RunCommand(s_buildEnv, _testOutput, label: id)
.WithWorkingDirectory(_projectDir!)
.WithWorkingDirectory(_projectDir!);
await using var runner = new BrowserRunner(_testOutput);
- var page = await runner.RunAsync(runCommand, $"run -c {config} --no-build -r browser-wasm --forward-console");
+ var page = await runner.RunAsync(runCommand, $"run --no-silent -c {config} --no-build -r browser-wasm --forward-console");
await runner.WaitForExitMessageAsync(TimeSpan.FromMinutes(2));
Assert.Contains("Hello, Browser!", string.Join(Environment.NewLine, runner.OutputLines));
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#nullable enable
-
using Mono.Options;
using System.Linq;
using System;
public HostConfig HostConfig { get; init; }
public WasmHostProperties HostProperties { get; init; }
public IEnumerable<string> HostArguments { get; init; }
+ public bool Silent { get; private set; } = true;
private string? hostArg;
private string? _runtimeConfigPath;
{ "host|h=", "Host config name", v => hostArg = v },
{ "runtime-config|r=", "runtimeconfig.json path for the app", v => _runtimeConfigPath = v },
{ "extra-host-arg=", "Extra argument to be passed to the host", hostArgsList.Add },
+ { "no-silent", "Verbose output from WasmAppHost", _ => Silent = false }
};
RemainingArgs = options.Parse(args);
_logger = logger;
}
- public static async Task<int> InvokeAsync(CommonConfiguration commonArgs,
+ public static Task<int> InvokeAsync(CommonConfiguration commonArgs,
ILoggerFactory _,
ILogger logger,
CancellationToken _1)
{
var args = new JSEngineArguments(commonArgs);
args.Validate();
- return await new JSEngineHost(args, logger).RunAsync();
+ return new JSEngineHost(args, logger).RunAsync();
}
private async Task<int> RunAsync()
int exitCode = await Utils.TryRunProcess(psi,
_logger,
msg => { if (msg != null) _logger.LogInformation(msg); },
- msg => { if (msg != null) _logger.LogInformation(msg); });
+ msg => { if (msg != null) _logger.LogInformation(msg); },
+ silent: _args.CommonConfig.Silent);
+ if (!_args.CommonConfig.Silent)
+ Console.WriteLine($"{_args.Host} exited with {exitCode}");
return exitCode;
}
}
ILogger logger,
Action<string?>? logStdOut = null,
Action<string?>? logStdErr = null,
+ bool silent = false,
string? label = null)
{
string msgPrefix = label == null ? string.Empty : $"[{label}] ";
- logger.LogInformation($"{msgPrefix}Running: {psi.FileName} {string.Join(" ", psi.ArgumentList)}");
+ if (!silent)
+ logger.LogInformation($"{msgPrefix}Running: {psi.FileName} {string.Join(" ", psi.ArgumentList)}");
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
if (logStdErr != null)
psi.RedirectStandardError = true;
- logger.LogDebug($"{msgPrefix}Using working directory: {psi.WorkingDirectory ?? Environment.CurrentDirectory}", msgPrefix);
+ if (!silent)
+ logger.LogDebug($"{msgPrefix}Using working directory: {psi.WorkingDirectory ?? Environment.CurrentDirectory}", msgPrefix);
// if (psi.EnvironmentVariables.Count > 0)
// logger.LogDebug($"{msgPrefix}Setting environment variables for execution:", msgPrefix);