/// <summary> /// Make sure deleting a project clears the error list when there are errors in multiple files /// /// Take 2 of https://pytools.codeplex.com/workitem/1523 /// </summary> public void ErrorListAndTaskListAreClearedWhenProjectWithMultipleFilesIsUnloaded(VisualStudioApp app) { var project = app.OpenProject(app.CopyProjectForTest(@"TestData\ErrorProjectMultipleFiles.sln")); var projectNode = project.GetPythonProject(); app.OpenDocument(Path.Combine(projectNode.ProjectHome, "Program.py")); app.OpenDocument(Path.Combine(projectNode.ProjectHome, "Program2.py")); app.OpenErrorList(); //app.OpenTaskList(); app.WaitForTaskListItems(typeof(SVsErrorList), 14); //app.WaitForTaskListItems(typeof(SVsTaskList), 4); var solutionService = app.GetService <IVsSolution>(typeof(SVsSolution)); Assert.IsNotNull(solutionService); IVsHierarchy selectedHierarchy; ErrorHandler.ThrowOnFailure(solutionService.GetProjectOfUniqueName(project.UniqueName, out selectedHierarchy)); Assert.IsNotNull(selectedHierarchy); Console.WriteLine("Unloading project"); ErrorHandler.ThrowOnFailure(solutionService.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, selectedHierarchy, 0)); app.WaitForTaskListItems(typeof(SVsErrorList), 0); //app.WaitForTaskListItems(typeof(SVsTaskList), 0); }
/// <summary> /// Make sure *.pyi files ignore the active Python version /// </summary> public void ErrorListEmptyForValidTypingFile(VisualStudioApp app) { var project = app.OpenProject(app.CopyProjectForTest(@"TestData\Typings.sln")); var projectNode = project.GetPythonProject(); app.OpenDocument(Path.Combine(projectNode.ProjectHome, "mymod.pyi")); app.OpenDocument(Path.Combine(projectNode.ProjectHome, "usermod.py")); app.OpenErrorList(); var actual = app.WaitForTaskListItems(typeof(SVsErrorList), 1); Assert.AreEqual(1, actual.Count); ErrorHandler.ThrowOnFailure(actual[0].Document(out var doc)); Assert.AreEqual("usermod.py", Path.GetFileName(doc)); }
/// <summary> /// Make sure task comments in a file show up in the task list window. /// </summary> public void CommentTaskList(VisualStudioApp app) { var project = app.OpenProject(app.CopyProjectForTest(@"TestData\ErrorProject.sln")); var projectNode = project.GetPythonProject(); var expectedDocument = Path.Combine(projectNode.ProjectHome, "Program.py"); var expectedCategory = VSTASKCATEGORY.CAT_COMMENTS; var expectedItems = new[] { new TaskItemInfo(expectedDocument, 4, 5, VSTASKPRIORITY.TP_NORMAL, expectedCategory, null, "TODO 123"), new TaskItemInfo(expectedDocument, 5, 0, VSTASKPRIORITY.TP_HIGH, expectedCategory, null, "456 UnresolvedMergeConflict"), }; app.OpenDocument(expectedDocument); app.OpenTaskList(); TaskListTest(app, typeof(SVsTaskList), expectedItems, navigateTo: new[] { 0, 1 }); }
/// <summary> /// Make sure deleting a file w/ errors clears the error list /// </summary> public void ErrorListAndTaskListAreClearedWhenFileIsDeleted(VisualStudioApp app) { var project = app.OpenProject(app.CopyProjectForTest(@"TestData\ErrorProjectDeleteFile.sln")); var projectNode = project.GetPythonProject(); app.OpenDocument(Path.Combine(projectNode.ProjectHome, "Program.py")); app.OpenErrorList(); //app.OpenTaskList(); app.WaitForTaskListItems(typeof(SVsErrorList), 7); //app.WaitForTaskListItems(typeof(SVsTaskList), 2); Console.WriteLine("Deleting file"); project.ProjectItems.Item("Program.py").Delete(); app.WaitForTaskListItems(typeof(SVsErrorList), 0); //app.WaitForTaskListItems(typeof(SVsTaskList), 0); }
/// <summary> /// Make sure errors in a file show up in the error list window. /// </summary> public void ErrorList(VisualStudioApp app) { var project = app.OpenProject(app.CopyProjectForTest(@"TestData\ErrorProject.sln")); var projectNode = project.GetPythonProject(); var expectedDocument = Path.Combine(projectNode.ProjectHome, "Program.py"); var expectedCategory = VSTASKCATEGORY.CAT_CODESENSE; var expectedItems = new[] { new TaskItemInfo(expectedDocument, 2, 8, VSTASKPRIORITY.TP_HIGH, expectedCategory, null, "unexpected indent"), new TaskItemInfo(expectedDocument, 2, 13, VSTASKPRIORITY.TP_HIGH, expectedCategory, null, "unexpected token '('"), new TaskItemInfo(expectedDocument, 2, 30, VSTASKPRIORITY.TP_HIGH, expectedCategory, null, "unexpected token ')'"), new TaskItemInfo(expectedDocument, 2, 31, VSTASKPRIORITY.TP_HIGH, expectedCategory, null, "unexpected token '<newline>'"), new TaskItemInfo(expectedDocument, 3, 0, VSTASKPRIORITY.TP_HIGH, expectedCategory, null, "unexpected token '<NL>'"), new TaskItemInfo(expectedDocument, 3, 0, VSTASKPRIORITY.TP_HIGH, expectedCategory, null, "unexpected token '<dedent>'"), new TaskItemInfo(expectedDocument, 4, 0, VSTASKPRIORITY.TP_HIGH, expectedCategory, null, "unexpected token 'pass'"), }; app.OpenDocument(expectedDocument); app.OpenErrorList(); TaskListTest(app, typeof(SVsErrorList), expectedItems, navigateTo: new[] { 0, 1, 2, 3, 4, 5, 6 }); }