public void SomethingWentWrongReturnsTrueWhenErrorTaskAddedToTaskService() { FileName fileName = new FileName("test.cs"); Task task = new Task(fileName, String.Empty, 1, 2, TaskType.Error); taskService.Add(task); Assert.IsTrue(taskService.SomethingWentWrong); }
public void Init() { string className = "MyNamespace.MyTests"; TestProject testProject = TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod(className, "MyTestMethod"); TestResult testResult = new TestResult("MyNamespace.MyTests.MyTestMethod"); testResult.ResultType = TestResultType.Ignored; testResult.Message = "Test ignored"; task = TestResultTask.Create(testResult, testProject); }
public void Init() { TestResult testResult = new TestResult("MyNamespace.MyTests"); testResult.ResultType = TestResultType.Failure; testResult.Message = "Test failed"; testResult.StackTrace = "Test Error : MyTest.Test\r\n" + "at TestResultTask.Create() in c:\\projects\\SharpDevelop\\TestResultTask.cs:line 45\r\n" + "at MyTest.Test() in c:\\myprojects\\test\\..\\test\\mytest.cs:line 28\r\n" + ""; testResult.StackTraceFilePosition = new FilePosition("c:\\myprojects\\test\\..\\test\\mytest.cs", 28, 1); task = TestResultTask.Create(testResult, null); }
public void Init() { MockRegisteredTestFrameworks testFrameworks = new MockRegisteredTestFrameworks(); MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); TestClass testClass = new TestClass(c, testFrameworks); TestProject testProject = new TestProject(c.Project, c.ProjectContent, testFrameworks); testProject.TestClasses.Add(testClass); TestResult testResult = new TestResult("MyNamespace.MyTests.MyTestMethod"); testResult.ResultType = TestResultType.Ignored; testResult.Message = "Test ignored"; task = TestResultTask.Create(testResult, testProject); }
/// <summary> /// <para> /// Initializes a new instance of <see cref='TaskCollection'/> containing any array of <see cref='Task'/> objects. /// </para> /// </summary> /// <param name='val'> /// A array of <see cref='Task'/> objects with which to intialize the collection /// </param> public TaskCollection(Task[] val) { this.AddRange(val); }
/// <summary> /// Looks for errors of the form /// "BUILD FAILED" /// "[csc] C:/foo/foo.cs(5,5):" /// "Something bad happened." /// </summary> /// <param name="textLine">The line of text to parse.</param> /// <returns>A <see cref="Task"/> if an error was found; otherwise /// <see langword="null"/>.</returns> static Task ParseNAntBuildFailedError(string output) { Task task = null; Match match = Regex.Match(output, @"^BUILD FAILED.*?$\n^$\n^(\w+:[/\\].*?)\(([\d]*),([\d]*)\):$\n^(.*?)$\n^(.*?)$", RegexOptions.Multiline); if (match.Success) { try { int line = Convert.ToInt32(match.Groups[2].Value); int col = Convert.ToInt32(match.Groups[3].Value); string description = String.Concat(match.Groups[4], Environment.NewLine, match.Groups[5]); task = new Task(FileName.Create(match.Groups[1].Value), description, col, line, TaskType.Error); } catch(Exception) { }; } else { match = Regex.Match(output, @"^BUILD FAILED$\n^$\n^(.*?)$", RegexOptions.Multiline); if (match.Success) { task = new Task(null, match.Groups[1].Value, 0, 0, TaskType.Error); } } return task; }
/// <summary> /// Looks for errors of the form /// "vbc : error BC31019: Unable to write to output file." /// </summary> /// <param name="textLine">The line of text to parse.</param> /// <returns>A <see cref="Task"/> if an error was found; otherwise /// <see langword="null"/>.</returns> static Task ParseVBFatalError(string textLine) { Task task = null; Match match = Regex.Match(textLine, @"^.*?vbc : error (.*?): (.*?)$"); if (match.Success) { try { string description = String.Concat(match.Groups[2].Value, " (", match.Groups[1].Value, ")"); task = new Task(null, description, 0, 0, TaskType.Error); } catch (Exception) { // Ignore. } } return task; }
/// <summary> /// Looks for errors of the form /// "C:/MyProject/MyProject.build(40): error CS1000: An error occurred." /// </summary> /// <remarks> /// This should handle C++ errors too.</remarks> /// <param name="textLine">The line of text to parse.</param> /// <returns>A <see cref="Task"/> if an error was found; otherwise /// <see langword="null"/>.</returns> static Task ParseVBError(string textLine) { Task task = null; Match match = Regex.Match(textLine, @"^.*?(\w+:[/\\].*?)\(([\d]*)\) : (.*?) (.*?): (.*?)$"); if (match.Success) { try { int line = Convert.ToInt32(match.Groups[2].Value); string description = String.Concat(match.Groups[5].Value, " (", match.Groups[4], ")"); TaskType taskType = TaskType.Error; if (String.Compare(match.Groups[3].Value, "warning", true) == 0) { taskType = TaskType.Warning; } task = new Task(FileName.Create(match.Groups[1].Value), description, 0, line, taskType); } catch (Exception) { // Ignore. } } return task; }
public void CodeCoverageProcessExitsAndCodeCoverageFileDoesNotExistsAddsErrorTaskToTaskList() { command.ParsedStringToReturn = "No code coverage results file generated."; ActionArguments<Task> args = CreateTestRunnerAndFirePartCoverProcessExitEventWhenNoCoverageFileProduced(); Task task = args.Arg; string description = @"No code coverage results file generated. c:\projects\MyTests\PartCover\coverage.xml"; int column = 1; int line = 1; Task expectedTask = new Task(null, description, column, line, TaskType.Error); TaskComparison comparison = new TaskComparison(expectedTask, task); Assert.IsTrue(comparison.IsMatch, comparison.MismatchReason); }
/// <summary> /// Looks for errors of the form /// "BUILD FAILED" /// "[csc] C:/foo/foo.cs(5,5):" /// "Something bad happened." /// </summary> /// <param name="textLine">The line of text to parse.</param> /// <returns>A <see cref="Task"/> if an error was found; otherwise /// <see langword="null"/>.</returns> static Task ParseNAntBuildFailedError(string output) { Task task = null; Match match = Regex.Match(output, @"^BUILD FAILED.*?$\n^$\n^(\w+:[/\\].*?)\(([\d]*),([\d]*)\):$\n^(.*?)$\n^(.*?)$", RegexOptions.Multiline); if (match.Success) { try { // Take off 1 for line/col since SharpDevelop is zero index based. int line = Convert.ToInt32(match.Groups[2].Value) - 1; int col = Convert.ToInt32(match.Groups[3].Value) - 1; string description = String.Concat(match.Groups[4], Environment.NewLine, match.Groups[5]); task = new Task(match.Groups[1].Value, description, col, line, TaskType.Error); } catch(Exception) { }; } else { match = Regex.Match(output, @"^BUILD FAILED$\n^$\n^(.*?)$", RegexOptions.Multiline); if (match.Success) { task = new Task(String.Empty, match.Groups[1].Value, 0, 0, TaskType.Error); } } return task; }
void AddTask(Task task) { if (!isEnabled) return; if (!CheckTask(task)) return; if (task.Line >= 1 && task.Line <= textEditor.Document.TotalNumberOfLines) { LoggingService.Debug(task.ToString()); int offset = textEditor.Document.PositionToOffset(task.Line, task.Column); int endOffset = TextUtilities.GetNextCaretPosition(DocumentUtilitites.GetTextSource(textEditor.Document), offset, System.Windows.Documents.LogicalDirection.Forward, CaretPositioningMode.WordBorderOrSymbol); if (endOffset < 0) endOffset = textEditor.Document.TextLength; int length = endOffset - offset; if (length < 2) { // marker should be at least 2 characters long, but take care that we don't make // it longer than the document length = Math.Min(2, textEditor.Document.TextLength - offset); } ITextMarker marker = this.markerService.Create(offset, length); Color markerColor = Colors.Transparent; switch (task.TaskType) { case TaskType.Error: markerColor = Colors.Red; break; case TaskType.Message: markerColor = Colors.Blue; break; case TaskType.Warning: markerColor = Colors.Orange; break; } marker.MarkerColor = markerColor; marker.MarkerType = TextMarkerType.SquigglyUnderline; marker.ToolTip = task.Description; marker.Tag = task; } }
public void AddTask(Task task) { TaskService.Add(task); }
public TaskComparison(Task lhs, Task rhs) { this.lhs = lhs; this.rhs = rhs; Compare(); }
public void TasksAddedToTaskServiceAreSaved() { FileName fileName = new FileName("test.cs"); Task task = new Task(fileName, "description", 1, 1, TaskType.Error); taskService.Add(task); Task[] tasks = new Task[] { task }; Assert.AreEqual(tasks, taskService.Tasks.ToArray()); }
/// <summary> /// Looks for errors of the form /// "C:/MyProject/MyProject.build(40,3): ifnot is deprecated." /// </summary> /// <param name="textLine">The line of text to parse.</param> /// <returns>A <see cref="Task"/> if an error was found; otherwise /// <see langword="null"/>.</returns> static Task ParseNAntError(string textLine) { Task task = null; Match match = Regex.Match(textLine, @"^.*?(\w+:[/\\].*?)\(([\d]*),([\d]*)\): (.*?)$"); if (match.Success) { try { // Take off 1 for line/col since SharpDevelop is zero index based. int line = Convert.ToInt32(match.Groups[2].Value) - 1; int col = Convert.ToInt32(match.Groups[3].Value) - 1; task = new Task(match.Groups[1].Value, match.Groups[4].Value, col, line, TaskType.Warning); } catch (Exception) { // Ignore. } } return task; }
bool CheckTask(Task task) { if (textEditor.FileName == null) return false; if (task.FileName == null || task.Column <= 0) return false; if (task.TaskType != TaskType.Warning && task.TaskType != TaskType.Error) return false; return FileUtility.IsEqualFileName(task.FileName, textEditor.FileName); }
/// <summary> /// Looks for errors of the form /// "C:/MyProject/MyProject.build(40): error CS1000: An error occurred." /// </summary> /// <remarks> /// This should handle C++ errors too.</remarks> /// <param name="textLine">The line of text to parse.</param> /// <returns>A <see cref="Task"/> if an error was found; otherwise /// <see langword="null"/>.</returns> static Task ParseVBError(string textLine) { Task task = null; Match match = Regex.Match(textLine, @"^.*?(\w+:[/\\].*?)\(([\d]*)\) : (.*?) (.*?): (.*?)$"); if (match.Success) { try { // Take off 1 for line/col since SharpDevelop is zero index based. int line = Convert.ToInt32(match.Groups[2].Value) - 1; string description = String.Concat(match.Groups[5].Value, " (", match.Groups[4], ")"); TaskType taskType = TaskType.Error; if (String.Compare(match.Groups[3].Value, "warning", true) == 0) { taskType = TaskType.Warning; } task = new Task(match.Groups[1].Value, description, 0, line, taskType); } catch (Exception) { // Ignore. } } return task; }
void AddTask(Task task) { if (!isEnabled) return; if (!CheckTask(task)) return; if (task.Line >= 1 && task.Line <= textEditor.Document.TotalNumberOfLines) { LoggingService.Debug(task.ToString()); int offset = textEditor.Document.PositionToOffset(task.Line, task.Column); int length = textEditor.Document.GetWordAt(offset).Length; if (length < 2) { // marker should be at least 2 characters long, but take care that we don't make // it longer than the document length = Math.Min(2, textEditor.Document.TextLength - offset); } ITextMarker marker = this.markerService.Create(offset, length); Color markerColor = Colors.Transparent; switch (task.TaskType) { case TaskType.Error: markerColor = Colors.Red; break; case TaskType.Message: markerColor = Colors.Blue; break; case TaskType.Warning: markerColor = Colors.Orange; break; } marker.MarkerColor = markerColor; marker.MarkerType = TextMarkerType.SquigglyUnderline; marker.ToolTip = task.Description; marker.Tag = task; } }
/// <summary> /// Parses errors of the form. /// "[delete] C:\foo\foo.build(94,5):" /// "[delete] Cannot delete directory 'C:\foo\bin'. The directory does not exist." /// </summary> /// <param name="textLine">The line of text to parse.</param> /// <returns>A <see cref="Task"/> if an error was found; otherwise /// <see langword="null"/>.</returns> static Task ParseMultilineBuildError(string output) { Task task = null; Match match = Regex.Match(output, @"^.*?\[delete\] (\w+:[/\\].*?)\(([\d]*),([\d]*)\):$\n^.*?\[delete\] (.*?)$", RegexOptions.Multiline); if (match.Success) { try { // Take off 1 for line/col since SharpDevelop is zero index based. int line = Convert.ToInt32(match.Groups[2].Value) - 1; int col = Convert.ToInt32(match.Groups[3].Value) - 1; string description = String.Concat(match.Groups[4]); task = new Task(match.Groups[1].Value, description, col, line, TaskType.Error); } catch(Exception) { }; } return task; }
public void AddTask(Task task) { TasksAdded.Add(task); }
/// <summary> /// Looks for errors of the form /// "C:/MyProject/MyProject.build(40,3): ifnot is deprecated." /// </summary> /// <param name="textLine">The line of text to parse.</param> /// <returns>A <see cref="Task"/> if an error was found; otherwise /// <see langword="null"/>.</returns> static Task ParseNAntError(string textLine) { Task task = null; Match match = Regex.Match(textLine, @"^.*?(\w+:[/\\].*?)\(([\d]*),([\d]*)\): (.*?)$"); if (match.Success) { try { int line = Convert.ToInt32(match.Groups[2].Value); int col = Convert.ToInt32(match.Groups[3].Value); task = new Task(FileName.Create(match.Groups[1].Value), match.Groups[4].Value, col, line, TaskType.Warning); } catch (Exception) { // Ignore. } } return task; }
void DisplayCoverageResults(string fileName) { if (!File.Exists(fileName)) { Task task = new Task(String.Empty, String.Concat(StringParser.Parse("${res:ICSharpCode.CodeCoverage.NoCodeCoverageResultsGenerated}"), " ", fileName), 0, 0, TaskType.Error); WorkbenchSingleton.SafeThreadAsyncCall(TaskService.Add, task); return; } CodeCoverageResults results = new CodeCoverageResults(fileName); WorkbenchSingleton.SafeThreadAsyncCall(CodeCoverageService.ShowResults, results); }
/// <summary> /// Looks for errors of the form /// "fatal error CS00042: An error occurred." /// </summary> /// <param name="textLine">The line of text to parse.</param> /// <returns>A <see cref="Task"/> if an error was found; otherwise /// <see langword="null"/>.</returns> static Task ParseFatalError(string textLine) { Task task = null; Match match = Regex.Match(textLine, @"^.*?(fatal error .*?: .*?)$"); if (match.Success) { try { task = new Task(null, match.Groups[1].Value, 0, 0, TaskType.Error); } catch (Exception) { // Ignore. } } return task; }
public static void Add(Task task) { tasks.Add(task); if (!taskCount.ContainsKey(task.TaskType)) { taskCount[task.TaskType] = 1; } else { taskCount[task.TaskType]++; } OnAdded(new TaskEventArgs(task)); }
/// <summary> /// Looks for errors of the form /// "fatal error CS00042: An error occurred." /// </summary> /// <param name="textLine">The line of text to parse.</param> /// <returns>A <see cref="Task"/> if a warning was found; otherwise /// <see langword="null"/>.</returns> static Task ParseNAntWarning(string textLine) { Task task = null; Match match = Regex.Match(textLine, @"^.*?(Read-only property .*? cannot be overwritten.)$"); if (match.Success) { try { task = new Task(null, match.Groups[1].Value, 0, 0, TaskType.Warning); } catch (Exception) { // Ignore. } } return task; }
public static void Remove(Task task) { if (tasks.Contains(task)) { tasks.Remove(task); taskCount[task.TaskType]--; OnRemoved(new TaskEventArgs(task)); } }
/// <summary> /// Parses errors of the form. /// "[delete] C:\foo\foo.build(94,5):" /// "[delete] Cannot delete directory 'C:\foo\bin'. The directory does not exist." /// </summary> /// <param name="textLine">The line of text to parse.</param> /// <returns>A <see cref="Task"/> if an error was found; otherwise /// <see langword="null"/>.</returns> static Task ParseMultilineBuildError(string output) { Task task = null; Match match = Regex.Match(output, @"^.*?\[delete\] (\w+:[/\\].*?)\(([\d]*),([\d]*)\):$\n^.*?\[delete\] (.*?)$", RegexOptions.Multiline); if (match.Success) { try { int line = Convert.ToInt32(match.Groups[2].Value); int col = Convert.ToInt32(match.Groups[3].Value); string description = String.Concat(match.Groups[4]); task = new Task(FileName.Create(match.Groups[1].Value), description, col, line, TaskType.Error); } catch(Exception) { }; } return task; }
public TaskEventArgs(Task task) { this.task = task; }
public void Init() { TestResult testResult = new TestResult("MyNamespace.MyTests"); testResult.ResultType = TestResultType.Ignored; task = TestResultTask.Create(testResult, null); }
/// <summary> /// <para> Removes a specific <see cref='Task'/> from the /// <see cref='TaskCollection'/> .</para> /// </summary> /// <param name='val'>The <see cref='Task'/> to remove from the <see cref='TaskCollection'/> .</param> /// <returns><para>None.</para></returns> /// <exception cref='System.ArgumentException'><paramref name='val'/> is not found in the Collection. </exception> public void Remove(Task val) { List.Remove(val); }