Skip to content

Commit bb9fd50

Browse files
CopilotViktorHofer
andcommitted
Add nodereuse flag validation to E2E tests
Updated tests to validate the nodereuse flag value in task command-line arguments: - Scenarios 1 & 3 (explicit TaskHostFactory): Validates /nodereuse:False for short-lived hosts - Scenario 4 (no explicit factory, non-matching runtime): Validates /nodereuse:True for long-lived sidecar - Scenario 2 (in-proc): No nodereuse validation needed as task runs in-process Tests now properly verify the core behavior through the task's perspective by checking the command-line arguments it receives. Co-authored-by: ViktorHofer <7412651+ViktorHofer@users.noreply.github.com>
1 parent 2fddfdf commit bb9fd50

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

src/Build.UnitTests/TaskHostFactoryLifecycle_E2E_Tests.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,22 @@ public TaskHostFactoryLifecycle_E2E_Tests(ITestOutputHelper output)
4040
/// 3. Runtime doesn't match + TaskHostFactory requested → short-lived out of proc (nodereuse:False)
4141
/// 4. Runtime doesn't match + TaskHostFactory NOT requested → long-lived sidecar out of proc (nodereuse:True)
4242
/// </summary>
43+
/// <param name="runtimeToUse">The runtime to use for the task (CurrentRuntime or NET)</param>
44+
/// <param name="taskFactoryToUse">The task factory to use (TaskHostFactory or AssemblyTaskFactory)</param>
45+
/// <param name="expectedNodeReuse">Expected node reuse value (true for long-lived, false for short-lived, null for in-proc)</param>
4346
[Theory]
44-
[InlineData("CurrentRuntime", "TaskHostFactory")] // Match + Explicit → short-lived out-of-proc
45-
[InlineData("CurrentRuntime", "AssemblyTaskFactory")] // Match + No Explicit → in-proc
47+
[InlineData("CurrentRuntime", "TaskHostFactory", false)] // Match + Explicit → short-lived out-of-proc
48+
[InlineData("CurrentRuntime", "AssemblyTaskFactory", null)] // Match + No Explicit → in-proc
4649

4750
// Not test-able on .NET msbuild as it can't run a CLR2/CLR4 task host (out-of-proc)
4851
#if !NET
49-
[InlineData("NET", "TaskHostFactory")] // No Match + Explicit → short-lived out-of-proc
50-
[InlineData("NET", "AssemblyTaskFactory")] // No Match + No Explicit → long-lived sidecar out-of-proc
52+
[InlineData("NET", "TaskHostFactory", false)] // No Match + Explicit → short-lived out-of-proc
53+
[InlineData("NET", "AssemblyTaskFactory", true)] // No Match + No Explicit → long-lived sidecar out-of-proc
5154
#endif
5255
public void TaskHostLifecycle_ValidatesAllScenarios(
5356
string runtimeToUse,
54-
string taskFactoryToUse)
57+
string taskFactoryToUse,
58+
bool? expectedNodeReuse)
5559
{
5660
using TestEnvironment env = TestEnvironment.Create(_output);
5761
string testProjectPath = Path.Combine(TestAssetsRootPath, "TaskHostLifecycleTestApp.csproj");
@@ -64,6 +68,16 @@ public void TaskHostLifecycle_ValidatesAllScenarios(
6468
}
6569

6670
successTestTask.ShouldBeTrue();
71+
72+
// Verify node reuse behavior based on expected value
73+
if (expectedNodeReuse.HasValue)
74+
{
75+
// For out-of-proc scenarios, validate the nodereuse flag in the task's command-line arguments
76+
string expectedFlag = expectedNodeReuse.Value ? "/nodereuse:True" : "/nodereuse:False";
77+
testTaskOutput.ShouldContain(expectedFlag,
78+
customMessage: $"Task should have {expectedFlag} in its command-line arguments");
79+
}
80+
// For in-proc scenarios (expectedNodeReuse == null), no nodereuse flag validation needed
6781
}
6882
}
6983
}

0 commit comments

Comments
 (0)