public static void IntegrationTests() => Describe(nameof(IntegrationTests), () => { var(configuration, targetFramework, testDirectory, isWatchMode) = GetAssemblyAttributes(); var testsDirectory = Combine(testDirectory, "integration"); var integrationTests = Directory.EnumerateDirectories(testsDirectory); foreach (var integrationTest in integrationTests) { It($"should run {integrationTest} with {targetFramework}/{configuration}", () => { var workingDirectory = Combine(testsDirectory, integrationTest); var connectionString = NamedPipesConnectionStringBuilder.CreateNewConnection(); return(TasteProcess( connectionString, "dotnet", $"run --no-build --no-restore --framework {targetFramework} -c {configuration}", workingDirectory, configureCommander: commander => commander.UseNamedPipesTransport() )); }); } });
public static async Task <int> Interactive(string project, CancellationToken cancellationToken) { try { var path = Path.GetFullPath(project); if (!string.IsNullOrEmpty(path) && Directory.Exists(path)) { var directoryName = new DirectoryInfo(path).Name; var csProjFileName = Path.Combine(path, $"{directoryName}.csproj"); if (File.Exists(csProjFileName)) { var connectionString = NamedPipesConnectionStringBuilder.CreateNewConnection(); Console.WriteLine(csProjFileName); var progress = new Progress <(string line, bool isError, int?exitCode)>(p => { Console.WriteLine(p.line); }); var commander = new TastyProcessCommander(connectionString, new Func <ProcessStartInfo>(() => ProcessStartInfoHelper.Create("dotnet", $"run --no-build --no-restore -c Debug -f netcoreapp3.1 --project {csProjFileName}", configureEnvironment: env => { env[EnvironmentVariables.InteractiveMode] = "true"; })), progress); commander.UseNamedPipesTransport() .RegisterReporter(ConsoleReporter.Report) .RegisterReporter(ConsoleReporter.ReportSummary); Console.WriteLine("Connecting to remote"); var remoteTask = await commander.ConnectAsync(cancellationToken).ConfigureAwait(true); Console.WriteLine("Connected to remote"); try { var uiTask = Task.Run(async() => { var commands = await commander.ListCommands(cancellationToken).ConfigureAwait(false); await Task.Run(async() => await WaitForInput(commands, commander).ConfigureAwait(false), cancellationToken).ConfigureAwait(false); Console.WriteLine("UI-Task ended"); }, cancellationToken); await Task.WhenAll(remoteTask, uiTask).ConfigureAwait(false); } catch (TaskCanceledException) { return(0); } catch (SimpleExec.NonZeroExitCodeException e) { return(e.ExitCode); } finally { commander.Dispose(); } } } return(0); } catch (TaskCanceledException) { return(1); } }