Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tasks Log.HasLoggedError now respects MSBuildWarningsAsErrors #6174

Merged
merged 32 commits into from Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8ca466d
Add IBuildEngine8 with a hashset of all warnings to be logged as errors
benvillalobos Feb 8, 2021
ff95db2
Add GetWarningsAsErrors method to ILoggingService. TaskLoggingHelper …
benvillalobos Feb 9, 2021
16cd7f0
Try adding warningsaserrors into taskhostconfiguration so OOP taskhos…
benvillalobos Feb 16, 2021
2b61f12
TaskHostConfiguration now translates warningsaserrors
benvillalobos Feb 16, 2021
07fbbb7
Update src/Utilities/Task.cs
benvillalobos Feb 19, 2021
8da9849
run build.cmd and update ref files
benvillalobos Feb 19, 2021
8f58790
WarningsAsErrors can be null if not specified
benvillalobos Feb 19, 2021
cf90ca0
Null check on warningsaserrors instead of buildengine
benvillalobos Feb 19, 2021
fda18f5
Unit Test: Add check for tasks logging warnings that are turned into …
benvillalobos Feb 19, 2021
4a93c5a
Ensure build stops when task logs a warning->error
benvillalobos Feb 19, 2021
cdb831e
Add test for translation of taskhostconfiguration and warningsaserrors
benvillalobos Feb 20, 2021
6cd3074
Add test that shows even if a task logs an error but returns true the…
benvillalobos Feb 23, 2021
53c5b0e
BuildEngine may not be an IBE8
benvillalobos Feb 23, 2021
4af8ce6
Exclude warnings->messages from warnings->errors because the former t…
benvillalobos Feb 23, 2021
b396ed5
Consider when WarningsAsErrors is an empty set that means we treat AL…
benvillalobos Feb 24, 2021
764df59
Properly remove all warningsasmessages from warningsaserrors. handle …
benvillalobos Feb 25, 2021
fdd2419
Add customization to what CustomLogAndReturn task returns
benvillalobos Mar 1, 2021
5d7b16a
Finalize tests. Remove test that _should not work but does_.
benvillalobos Mar 1, 2021
83f1b66
Code review suggestion
benvillalobos Mar 1, 2021
63be126
Minor code cleanup
benvillalobos Mar 2, 2021
28f55cb
Explicitly call last overload of LogError
benvillalobos Mar 2, 2021
787982a
Add null check for taskloggingcontext for test compatibility
benvillalobos Mar 3, 2021
d2c230c
Add tests for task-batches
benvillalobos Mar 5, 2021
7aa9763
Minor PR feedback
benvillalobos Mar 8, 2021
febb509
Add arg names to taskhostconfig tests
benvillalobos Mar 8, 2021
0ccb51c
Reword 'thrown' to 'logged' to avoid confusion
benvillalobos Mar 8, 2021
7670dea
IBE8 now has ShouldTreatWarningAsError method
benvillalobos Mar 8, 2021
9a485da
WarningsAsErrors set turned into ICollection (taskhost side)
benvillalobos Mar 8, 2021
924423b
Binary translator converts an ICollection of strings. OOPTHN now tran…
benvillalobos Mar 8, 2021
a969d83
Rename arg to collection
benvillalobos Mar 8, 2021
b65e272
Make ICollection translate method more generic
benvillalobos Mar 8, 2021
9856364
PR changes. Adding comments.
benvillalobos Mar 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -211,6 +211,10 @@ public partial interface IBuildEngine7 : Microsoft.Build.Framework.IBuildEngine,
{
bool AllowFailureWithoutError { get; set; }
}
public partial interface IBuildEngine8 : Microsoft.Build.Framework.IBuildEngine, Microsoft.Build.Framework.IBuildEngine2, Microsoft.Build.Framework.IBuildEngine3, Microsoft.Build.Framework.IBuildEngine4, Microsoft.Build.Framework.IBuildEngine5, Microsoft.Build.Framework.IBuildEngine6, Microsoft.Build.Framework.IBuildEngine7
{
bool ShouldTreatWarningAsError(string warningCode);
}
public partial interface ICancelableTask : Microsoft.Build.Framework.ITask
{
void Cancel();
Expand Down
Expand Up @@ -211,6 +211,10 @@ public partial interface IBuildEngine7 : Microsoft.Build.Framework.IBuildEngine,
{
bool AllowFailureWithoutError { get; set; }
}
public partial interface IBuildEngine8 : Microsoft.Build.Framework.IBuildEngine, Microsoft.Build.Framework.IBuildEngine2, Microsoft.Build.Framework.IBuildEngine3, Microsoft.Build.Framework.IBuildEngine4, Microsoft.Build.Framework.IBuildEngine5, Microsoft.Build.Framework.IBuildEngine6, Microsoft.Build.Framework.IBuildEngine7
{
bool ShouldTreatWarningAsError(string warningCode);
}
public partial interface ICancelableTask : Microsoft.Build.Framework.ITask
{
void Cancel();
Expand Down
Expand Up @@ -353,6 +353,7 @@ public abstract partial class Task : Microsoft.Build.Framework.ITask
public Microsoft.Build.Framework.IBuildEngine5 BuildEngine5 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine6 BuildEngine6 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine7 BuildEngine7 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine8 BuildEngine8 { get { throw null; } }
protected string HelpKeywordPrefix { get { throw null; } set { } }
public Microsoft.Build.Framework.ITaskHost HostObject { get { throw null; } set { } }
public Microsoft.Build.Utilities.TaskLoggingHelper Log { get { throw null; } }
Expand Down
Expand Up @@ -198,6 +198,7 @@ public abstract partial class Task : Microsoft.Build.Framework.ITask
public Microsoft.Build.Framework.IBuildEngine5 BuildEngine5 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine6 BuildEngine6 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine7 BuildEngine7 { get { throw null; } }
public Microsoft.Build.Framework.IBuildEngine8 BuildEngine8 { get { throw null; } }
protected string HelpKeywordPrefix { get { throw null; } set { } }
public Microsoft.Build.Framework.ITaskHost HostObject { get { throw null; } set { } }
public Microsoft.Build.Utilities.TaskLoggingHelper Log { get { throw null; } }
Expand Down
39 changes: 39 additions & 0 deletions src/Build.UnitTests/BackEnd/CustomLogAndReturnTask.cs
@@ -0,0 +1,39 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
namespace Microsoft.Build.UnitTests
{
public class CustomLogAndReturnTask : Task
{
public string WarningCode { get; set; }

public string ErrorCode { get; set; }

public bool ReturnHasLoggedErrors { get; set; }

[Required]
public bool Return { get; set; }
Comment on lines +14 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like these are always true?


// Unused for now, created for task batching.
public ITaskItem[] Sources { get; set; }

/// <summary>
/// This task returns and logs what you want based on the running test.
/// </summary>
public override bool Execute()
{
if(!string.IsNullOrEmpty(WarningCode))
{
Log.LogWarning(null, WarningCode, null, null, 0, 0, 0, 0, "Warning Logged!", null);
}

if(!string.IsNullOrEmpty(ErrorCode))
{
Log.LogError(null, ErrorCode, null, null, 0, 0, 0, 0, "Error Logged!", null);
}
return ReturnHasLoggedErrors ? !Log.HasLoggedErrors : Return;
}
}
}
5 changes: 5 additions & 0 deletions src/Build.UnitTests/BackEnd/MockLoggingService.cs
Expand Up @@ -557,6 +557,11 @@ public bool HasBuildSubmissionLoggedErrors(int submissionId)
return false;
}

public HashSet<string> GetWarningsToBeLoggedAsErrorsByProject(BuildEventContext context)
{
throw new NotImplementedException();
}

#endregion
}
}