Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": ["styles.css"],
"styles": ["src/styles.css"],
"scripts": [],
"assets": ["src/assets"]
}
Expand Down
13 changes: 9 additions & 4 deletions src/ProjectTemplates/test/Helpers/ProcessEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ public static ProcessEx Run(ITestOutputHelper output, string workingDirectory, s
return new ProcessEx(output, proc);
}

public static async Task<ProcessEx> RunViaShellAsync(ITestOutputHelper output, string workingDirectory, string commandAndArgs)
public static ProcessEx RunViaShell(ITestOutputHelper output, string workingDirectory, string commandAndArgs)
{
var (shellExe, argsPrefix) = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? ("cmd", "/c")
: ("bash", "-c");

var result = Run(output, workingDirectory, shellExe, $"{argsPrefix} \"{commandAndArgs}\"");
await result.Exited;
result.WaitForExit(assertSuccess: false);
return result;
}

Expand Down Expand Up @@ -168,9 +168,14 @@ internal string GetFormattedOutput()
return $"Process exited with code {_process.ExitCode}\nStdErr: {Error}\nStdOut: {Output}";
}

public void WaitForExit(bool assertSuccess)
public void WaitForExit(bool assertSuccess, TimeSpan? timeSpan = null)
{
Exited.Wait();
if(!timeSpan.HasValue)
{
timeSpan = TimeSpan.FromSeconds(480);
}

Exited.Wait(timeSpan.Value);

if (assertSuccess && _process.ExitCode != 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ProjectTemplates/test/Helpers/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private async Task<ProcessEx> RestoreAsync(ITestOutputHelper output, string work
try
{
output.WriteLine($"Restoring NPM packages in '{workingDirectory}' using npm...");
var result = await ProcessEx.RunViaShellAsync(output, workingDirectory, "npm install");
var result = ProcessEx.RunViaShell(output, workingDirectory, "npm install");
return result;
}
finally
Expand Down
12 changes: 5 additions & 7 deletions src/ProjectTemplates/test/SpaTemplateTest/SpaTemplateTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ protected async Task SpaTemplateImplAsync(
using var npmRestoreResult = await Project.RestoreWithRetryAsync(Output, clientAppSubdirPath);
Assert.True(0 == npmRestoreResult.ExitCode, ErrorMessages.GetFailedProcessMessage("npm restore", Project, npmRestoreResult));

using var lintResult = await ProcessEx.RunViaShellAsync(Output, clientAppSubdirPath, "npm run lint");
using var lintResult = ProcessEx.RunViaShell(Output, clientAppSubdirPath, "npm run lint");
Assert.True(0 == lintResult.ExitCode, ErrorMessages.GetFailedProcessMessage("npm run lint", Project, lintResult));

if (template == "react" || template == "reactredux")
{
using var testResult = await ProcessEx.RunViaShellAsync(Output, clientAppSubdirPath, "npm run test");
Assert.True(0 == testResult.ExitCode, ErrorMessages.GetFailedProcessMessage("npm run test", Project, testResult));
}
var testcommand = "npm run test" + template == "angular" ? "-- --watch=false" : "";
using var testResult = ProcessEx.RunViaShell(Output, clientAppSubdirPath, testcommand);
Assert.True(0 == testResult.ExitCode, ErrorMessages.GetFailedProcessMessage("npm run test", Project, testResult));

using var publishResult = await Project.RunDotNetPublishAsync();
Assert.True(0 == publishResult.ExitCode, ErrorMessages.GetFailedProcessMessage("publish", Project, publishResult));
Expand Down Expand Up @@ -159,7 +157,7 @@ private async Task CleanupReactClientAppBuildFolder(string clientAppSubdirPath)
{
try
{
testResult = await ProcessEx.RunViaShellAsync(Output, clientAppSubdirPath, "npx rimraf ./build");
testResult = ProcessEx.RunViaShell(Output, clientAppSubdirPath, "npx rimraf ./build");
testResultExitCode = testResult.ExitCode;
if (testResultExitCode == 0)
{
Expand Down