public void TestLaunchWithErrorsDontRun() { var app = new PythonVisualStudioApp(); var originalValue = GetOptions().PromptBeforeRunningWithBuildErrorSetting; GetOptions().PromptBeforeRunningWithBuildErrorSetting = true; try { var project = app.OpenProject(@"TestData\ErrorProject.sln"); var debug3 = (Debugger3)app.Dte.Debugger; ThreadPool.QueueUserWorkItem(x => debug3.Go(true)); var dialog = new PythonLaunchWithErrorsDialog(app.WaitForDialog()); dialog.No(); // make sure we don't go into debug mode for (int i = 0; i < 10; i++) { Assert.AreEqual(dbgDebugMode.dbgDesignMode, app.Dte.Debugger.CurrentMode); System.Threading.Thread.Sleep(100); } WaitForMode(app, dbgDebugMode.dbgDesignMode); } finally { GetOptions().PromptBeforeRunningWithBuildErrorSetting = originalValue; app.Dispose(); } }
public static ReplWindowProxy Prepare( PythonVisualStudioApp app, ReplWindowProxySettings settings, string projectName, string workspaceName, bool useIPython = false ) { settings.AssertValid(); ReplWindowProxy result = null; try { result = OpenInteractive(app, settings, projectName, workspaceName, useIPython ? IPythonBackend : StandardBackend); app = null; for (int retries = 10; retries > 0; --retries) { result.Reset(); result.ClearScreen(); result.ClearInput(); try { var task = result.ExecuteText("print('READY')"); Assert.IsTrue(task.Wait(useIPython ? 30000 : 15000), "ReplWindow did not initialize in time"); if (!task.Result.IsSuccessful) { continue; } } catch (TaskCanceledException) { continue; } if (useIPython) { // The longer we wait, the better are the chances of detecting this error // This seems long enough to detect it when running locally Thread.Sleep(500); if (result.TextView.TextBuffer.CurrentSnapshot.Lines .Any(l => l.GetText().Contains("Error using selected REPL back-end")) ) { Assert.Inconclusive("IPython is not available"); } // In IPython mode, a help header appears at startup, // but the output order is inconsistent, so we can't WaitForTextEnd // (sometimes READY appears before help, sometimes after) result.WaitForAnyLineContainsTextInternal("READY"); result.WaitForReadyForInput(TimeSpan.FromSeconds(5)); } else { result.WaitForTextEnd("READY", ">"); } result.ClearScreen(); return(result); } Assert.Fail("ReplWindow did not initialize"); return(null); } finally { if (app != null) { app.Dispose(); } } }
private PythonVisualStudioApp OpenProfileTestProject( out EnvDTE.Project project, out IPythonProfiling profiling, string projectFile = @"TestData\ProfileTest.sln" ) { var app = new PythonVisualStudioApp(); try { profiling = (IPythonProfiling)app.Dte.GetObject("PythonProfiling"); // no sessions yet Assert.IsNull(profiling.GetSession(1)); if (string.IsNullOrEmpty(projectFile)) { project = null; } else { project = app.OpenProject(projectFile); } var res = app; app = null; return res; } finally { if (app != null) { app.Dispose(); } } }