public async Task <ExecutionResult> LoadCommandAsync(string path) { try { var result = await _interactiveHost.ExecuteFileAsync(path).ConfigureAwait(false); if (result.Success) { // We are executing a command, which means the current content type has been switched to "Command" // and the source document removed. Debug.Assert(!_workspace.CurrentSolution.GetProject(_currentSubmissionProjectId).HasDocuments); Debug.Assert(result.ResolvedPath != null); var documentId = DocumentId.CreateNewId(_currentSubmissionProjectId, result.ResolvedPath); var newSolution = _workspace.CurrentSolution.AddDocument(documentId, Path.GetFileName(result.ResolvedPath), new FileTextLoader(result.ResolvedPath, defaultEncoding: null)); _workspace.SetCurrentSolution(newSolution); SubmissionSuccessfullyExecuted(result); } return(new ExecutionResult(result.Success)); } catch (Exception e) when(FatalError.Report(e)) { throw ExceptionUtilities.Unreachable; } }
public void AsyncExecuteFile_InfiniteLoop() { var file = Temp.CreateFile().WriteAllText(MethodWithInfiniteLoop + "\r\nfoo();").Path; var mayTerminate = new ManualResetEvent(false); _host.ErrorOutputReceived += (_, __) => mayTerminate.Set(); var executeTask = _host.ExecuteFileAsync(file); mayTerminate.WaitOne(); RestartHost(); executeTask.Wait(); Assert.True(Execute(@"1+1")); Assert.Equal("2\r\n", ReadOutputToEnd()); }