Skip to content

Commit

Permalink
Merge pull request #9155 from yuehuang010/main_question3
Browse files Browse the repository at this point in the history
Question mode usage feedback updates.
  • Loading branch information
JanKrivanek committed Nov 18, 2023
2 parents 0a0959f + 2b4b76c commit 7595b3a
Show file tree
Hide file tree
Showing 22 changed files with 233 additions and 40 deletions.
7 changes: 7 additions & 0 deletions src/Build/BackEnd/Components/Logging/LoggingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ public int MaxCPUCount
set => _maxCPUCount = value;
}

/// <summary>
/// Gets or sets a value that will error when the build process fails an up-to-date check.
/// </summary>
public bool Question { get; set; }

/// <summary>
/// The list of descriptions which describe how to create forwarding loggers on a node.
/// This is used by the node provider to get a list of registered descriptions so that
Expand Down Expand Up @@ -797,6 +802,8 @@ public void InitializeComponent(IBuildComponentHost buildComponentHost)
// this information default to 1
_maxCPUCount = buildComponentHost.BuildParameters.MaxNodeCount;

Question = buildComponentHost.BuildParameters.Question;

// Ask the component host if onlyLogCriticalEvents is true or false. If the host does
// not have this information default to false.
_onlyLogCriticalEvents = buildComponentHost.BuildParameters.OnlyLogCriticalEvents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,14 @@ public void LogBuildFinished(bool success)
string message = String.Empty;
if (!OnlyLogCriticalEvents)
{
message = ResourceUtilities.GetResourceString(success ? "BuildFinishedSuccess" : "BuildFinishedFailure");
if (Question)
{
message = ResourceUtilities.GetResourceString(success ? "BuildFinishedQuestionSuccess" : "BuildFinishedQuestionFailure");
}
else
{
message = ResourceUtilities.GetResourceString(success ? "BuildFinishedSuccess" : "BuildFinishedFailure");
}
}

BuildFinishedEventArgs buildEvent = new BuildFinishedEventArgs(message, null /* no help keyword */, success);
Expand Down
6 changes: 6 additions & 0 deletions src/Build/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@
<data name="BuildFinishedFailure" xml:space="preserve">
<value>Build FAILED.</value>
</data>
<data name="BuildFinishedQuestionFailure" xml:space="preserve">
<value>Question build FAILED. The build exited early as it encountered a target or task that was not up-to-date.</value>
</data>
<data name="BuildFinishedQuestionSuccess" xml:space="preserve">
<value>Question build succeeded. Up-to-date checks passed.</value>
</data>
<data name="BuildFinishedSuccess" xml:space="preserve">
<value>Build succeeded.</value>
</data>
Expand Down
10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Build/Resources/xlf/Strings.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions src/Tasks.UnitTests/ResourceHandling/GenerateResource_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,59 @@ public void ForceOutOfDateLinked(bool usePreserialized)
}
}

[Fact]
public void QuestionOutOfDateByDeletion()
{
var folder = _env.CreateFolder();
string resxFileInput = Utilities.WriteTestResX(false, null, null, _env.CreateFile(folder, ".resx").Path);
TaskItem stateFile = new TaskItem(_env.GetTempFile(".cache").Path);
ITaskItem[] sources = new ITaskItem[] { new TaskItem(resxFileInput) };
ITaskItem[] output;

GenerateResource t1 = Utilities.CreateTask(_output);
t1.Sources = sources;
t1.StateFile = stateFile;
Utilities.ExecuteTask(t1);

Utilities.AssertLogContainsResource(t1, "GenerateResource.OutputDoesntExist", t1.OutputResources[0].ItemSpec);

output = t1.OutputResources;

// Run again to ensure all files are up to date.
GenerateResource t2 = Utilities.CreateTask(_output);
t2.Sources = sources;
t2.StateFile = stateFile;
t2.FailIfNotIncremental = true;
Utilities.ExecuteTask(t2);

// Delete the file and verify that FailIfNotIncremental will print the missing file
GenerateResource t3 = Utilities.CreateTask(_output);
t3.StateFile = stateFile;
t3.Sources = sources;
t3.FailIfNotIncremental = true;

// Delete the output
File.Delete(output[0].ItemSpec);

t3.Execute().ShouldBeFalse();

Utilities.AssertLogContainsResource(t3, "GenerateResource.ProcessingFile", sources[0].ItemSpec, output[0].ItemSpec);

GenerateResource t4 = Utilities.CreateTask(_output);
t4.Sources = sources;
t4.StateFile = stateFile;
Utilities.ExecuteTask(t4);

Utilities.AssertLogContainsResource(t4, "GenerateResource.OutputDoesntExist", t4.OutputResources[0].ItemSpec);

// Run again to ensure all files are up to date.
GenerateResource t5 = Utilities.CreateTask(_output);
t5.Sources = sources;
t5.StateFile = stateFile;
t5.FailIfNotIncremental = true;
Utilities.ExecuteTask(t5);
}

[Theory]
[InlineData(false, false)]
[InlineData(false, true)]
Expand Down
4 changes: 2 additions & 2 deletions src/Tasks.UnitTests/Touch_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public void QuestionTouchNonExistingAlwaysCreate()

bool success = Execute(t);

Assert.False(success);
Assert.True(success);

Assert.Contains(
String.Format(AssemblyResources.GetString("Touch.CreatingFile"), mynonexisting_txt, "AlwaysCreate"),
Expand All @@ -401,7 +401,7 @@ public void QuestionTouchExisting()

bool success = Execute(t);

Assert.False(success);
Assert.True(success);

Assert.Contains(
String.Format(AssemblyResources.GetString("Touch.Touching"), myexisting_txt),
Expand Down
Loading

0 comments on commit 7595b3a

Please sign in to comment.