Skip to content

Commit f253732

Browse files
dotnet-maestro[bot]EvangelinkCopilot
authored
[main] Update dependencies from microsoft/testfx (#12181)
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Amaury Levé <amauryleve@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 3444490 commit f253732

9 files changed

Lines changed: 143 additions & 31 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import json
5+
import pathlib
6+
import subprocess
7+
import unittest
8+
9+
import yaml
10+
11+
12+
ROOT = pathlib.Path(__file__).resolve().parents[2]
13+
WORKFLOWS = (
14+
ROOT / ".github/workflows/shared/test-reviewer-shared.md",
15+
ROOT / ".github/workflows/test-reviewer-on-pr.agent.md",
16+
ROOT / ".github/workflows/test-reviewer.agent.md",
17+
)
18+
WORKFLOW_NAME = "Test quality review"
19+
RUN_URL = "https://github.com/example/testfx/actions/runs/123"
20+
HISTORY_URL = "https://github.com/search?q=repo%3Aexample%2Ftestfx"
21+
EXPECTED_FOOTER = (
22+
f"> \U0001f916 **Automated content by GitHub Copilot.** Generated by the "
23+
f"[{WORKFLOW_NAME}]({RUN_URL}/agentic_workflow) workflow."
24+
)
25+
NODE_HARNESS = r"""
26+
const fs = require("fs");
27+
const path = require("path");
28+
const input = JSON.parse(fs.readFileSync(0, "utf8"));
29+
global.core = { info() {}, warning() {}, debug() {} };
30+
global.github = {};
31+
global.context = { repo: { owner: "example", repo: "testfx" }, payload: {} };
32+
for (const key of [
33+
"GH_AW_AIC", "GH_AW_AGENT_AIC", "GH_AW_EVALS_AIC",
34+
"GH_AW_THREAT_DETECTION_AIC", "GH_AW_AMBIENT_CONTEXT",
35+
"GH_AW_ENGINE_ID", "GH_AW_ENGINE_MODEL",
36+
]) {
37+
delete process.env[key];
38+
}
39+
process.env.GH_AW_SAFE_OUTPUT_MESSAGES = JSON.stringify({ footer: input.footer });
40+
const { getFooterMessage } = require(path.join(input.scriptsDirectory, "messages_footer.cjs"));
41+
const output = getFooterMessage({
42+
workflowName: input.workflowName,
43+
runUrl: input.runUrl,
44+
historyUrl: input.historyUrl,
45+
});
46+
console.log(JSON.stringify({ output }));
47+
"""
48+
49+
50+
class GhAwReviewFooterTests(unittest.TestCase):
51+
def check_footer(self, history_url: str | None) -> None:
52+
expected = EXPECTED_FOOTER
53+
if history_url:
54+
expected += f" \u00b7 [\u25f7]({history_url})"
55+
for workflow in WORKFLOWS:
56+
with self.subTest(workflow=workflow.name, history=bool(history_url)):
57+
frontmatter = yaml.safe_load(workflow.read_text(encoding="utf-8").split("---", 2)[1])
58+
footer = frontmatter["safe-outputs"]["messages"]["footer"]
59+
result = subprocess.run(
60+
["node", "-e", NODE_HARNESS],
61+
input=json.dumps(
62+
{
63+
"scriptsDirectory": str(SCRIPTS_DIRECTORY),
64+
"footer": footer,
65+
"workflowName": WORKFLOW_NAME,
66+
"runUrl": RUN_URL,
67+
"historyUrl": history_url,
68+
}
69+
),
70+
encoding="utf-8",
71+
capture_output=True,
72+
check=True,
73+
timeout=30,
74+
)
75+
self.assertEqual(expected, json.loads(result.stdout)["output"])
76+
77+
def test_absent_history_omits_the_entire_optional_fragment(self) -> None:
78+
self.check_footer(None)
79+
80+
def test_present_history_expands_one_complete_link(self) -> None:
81+
self.check_footer(HISTORY_URL)
82+
83+
84+
if __name__ == "__main__":
85+
parser = argparse.ArgumentParser()
86+
parser.add_argument("--scripts-directory", type=pathlib.Path, required=True)
87+
args, unittest_args = parser.parse_known_args()
88+
SCRIPTS_DIRECTORY = args.scripts_directory.resolve()
89+
unittest.main(argv=[__file__, *unittest_args])

‎.github/workflows/README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,16 @@ unnecessary requests instead of broadening the firewall.
252252

253253
#### Provisional CONNECT records and test-review footers
254254

255+
The `history_link` footer value is an optional, already-rendered fragment,
256+
including its separator and link. Append `{history_link}` directly; do not
257+
nest it inside another Markdown link's URL. That nesting produces empty or
258+
malformed links in the string renderer and fails with `Report nodes cannot
259+
appear in scalar fields` in the structured renderer. Both reviewer variants
260+
and their shared configuration use the same fragment contract.
261+
`test_gh_aw_review_footer.py` exercises all three templates with the pinned
262+
runtime, with and without a history URL; the action-pin workflow runs it
263+
alongside the existing firewall-footer checks.
264+
255265
The warning on [PR #11892](https://github.com/microsoft/testfx/pull/11892#pullrequestreview-5490606840)
256266
is a reporting defect, not missing GitHub access. In
257267
[run 38246632006](https://github.com/microsoft/testfx/actions/runs/38246632006),

‎.github/workflows/check-action-pins.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ on:
2222
- '.github/scripts/issue-labeler.mjs'
2323
- '.github/scripts/issue-labeler.test.mjs'
2424
- '.github/scripts/test_gh_aw_firewall_footer.py'
25+
- '.github/scripts/test_gh_aw_review_footer.py'
2526
- '.github/scripts/test_gh_aw_runtime_contracts.py'
2627
- '.github/scripts/test_build_failure_analysis_checkout.py'
2728
- '.github/scripts/test_agentic_workflow_warning_contracts.py'
@@ -45,6 +46,7 @@ on:
4546
- '.github/scripts/issue-labeler.mjs'
4647
- '.github/scripts/issue-labeler.test.mjs'
4748
- '.github/scripts/test_gh_aw_firewall_footer.py'
49+
- '.github/scripts/test_gh_aw_review_footer.py'
4850
- '.github/scripts/test_gh_aw_runtime_contracts.py'
4951
- '.github/scripts/test_build_failure_analysis_checkout.py'
5052
- '.github/scripts/test_agentic_workflow_warning_contracts.py'
@@ -97,5 +99,7 @@ jobs:
9799
destination: ${{ runner.temp }}/gh-aw/actions
98100
- name: Test firewall footer correction
99101
run: python .github/scripts/test_gh_aw_firewall_footer.py --module-path "$RUNNER_TEMP/gh-aw/actions/firewall_blocked_domains.cjs"
102+
- name: Test review footer fragments
103+
run: python .github/scripts/test_gh_aw_review_footer.py --scripts-directory "$RUNNER_TEMP/gh-aw/actions"
100104
- name: Test pinned gh-aw footer and review contracts
101105
run: python .github/scripts/test_gh_aw_runtime_contracts.py --actions-dir "$RUNNER_TEMP/gh-aw/actions"

‎eng/Version.Details.xml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
<Uri>https://dev.azure.com/devdiv/DevDiv/_git/vs-code-coverage</Uri>
2222
<Sha>eca1718b78e9adb640b700ede7b51ec97ed077fa</Sha>
2323
</Dependency>
24-
<Dependency Name="MSTest" Version="4.6.0-preview.26531.5">
24+
<Dependency Name="MSTest" Version="4.6.0-preview.26552.13">
2525
<Uri>https://github.com/microsoft/testfx</Uri>
26-
<Sha>2a8ebadb17a3b388b62bbb0cedd407999e3ce10a</Sha>
26+
<Sha>3a95626573dd6932505a860cbd059dae4f79a81d</Sha>
2727
</Dependency>
28-
<Dependency Name="Microsoft.Testing.Platform" Version="2.6.0-preview.26531.5">
28+
<Dependency Name="Microsoft.Testing.Platform" Version="2.6.0-preview.26552.13">
2929
<Uri>https://github.com/microsoft/testfx</Uri>
30-
<Sha>2a8ebadb17a3b388b62bbb0cedd407999e3ce10a</Sha>
30+
<Sha>3a95626573dd6932505a860cbd059dae4f79a81d</Sha>
3131
</Dependency>
3232
</ToolsetDependencies>
3333
</Dependencies>

‎eng/Versions.props‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<MicrosoftTestingExtensionsCodeCoverageVersion>18.13.0-preview.26553.3</MicrosoftTestingExtensionsCodeCoverageVersion>
1212
<MicrosoftTestingExtensionsAffectedTestsVersion>18.13.0-preview.26553.4</MicrosoftTestingExtensionsAffectedTestsVersion>
1313
<!-- empty line to avoid merge conflicts for darc PRs to update CC and MSTest+MTP -->
14-
<MSTestVersion>4.6.0-preview.26531.5</MSTestVersion>
15-
<MicrosoftTestingPlatformVersion>2.6.0-preview.26531.5</MicrosoftTestingPlatformVersion>
14+
<MSTestVersion>4.6.0-preview.26552.13</MSTestVersion>
15+
<MicrosoftTestingPlatformVersion>2.6.0-preview.26552.13</MicrosoftTestingPlatformVersion>
1616
</PropertyGroup>
1717
</Project>

‎test/UnitTests/Microsoft.Testing.Extensions.UnitTests/RetryArtifactRecoveryProtocolTests.cs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,14 @@ public async Task Orchestrate_ManifestIoFailuresWarnAndPreserveAvailableArtifact
435435
}
436436
}
437437

438+
// Stack-frame locations can change between logging and assertion.
438439
Assert.AreSequenceEqual(
439440
new[]
440441
{
441442
deleteFailure
442-
? $"Failed to delete recovered retry artifact manifest '{attempt.ManifestPath}': {original}"
443-
: $"Failed to read recovered retry artifact manifest '{attempt.ManifestPath}': {original}",
444-
}, fixture.Warnings);
443+
? $"Failed to delete recovered retry artifact manifest '{attempt.ManifestPath}': {original.GetType().FullName}: {original.Message}"
444+
: $"Failed to read recovered retry artifact manifest '{attempt.ManifestPath}': {original.GetType().FullName}: {original.Message}",
445+
}, fixture.Warnings.Select(static warning => warning.Split('\n')[0].TrimEnd('\r')));
445446
Assert.AreEqual(deleteFailure, fixture.Files.ContainsKey(attempt.ManifestPath));
446447
if (deleteFailure)
447448
{

‎test/UnitTests/Microsoft.Testing.Extensions.UnitTests/RetryTests.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ public async Task RunAttemptAsync_ProcessExitEventWinsBeforeConnection()
802802
It.IsAny<CancellationToken>()))
803803
.Returns(Task.CompletedTask);
804804
using var server = new RetryFailedTestsPipeServer(serviceProvider, [], Mock.Of<ILogger>());
805-
using var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(5));
806805
Mock<ILogger> logger = CreateRecordingLogger();
807806

808807
RetryTestHostRunner.AttemptResult result = await RetryTestHostRunner.RunAttemptAsync(
@@ -815,7 +814,7 @@ public async Task RunAttemptAsync_ProcessExitEventWinsBeforeConnection()
815814
[],
816815
attemptCount: 1,
817816
userMaxRetryCount: 1,
818-
cancellation.Token);
817+
TestContext.CancellationToken);
819818

820819
Assert.AreEqual(9, result.ExitCode);
821820
Assert.IsTrue(result.ExitedBeforeConnect);

‎test/UnitTests/Microsoft.Testing.Platform.ServerMode.Client.Sources.UnitTests/MtpServerClientInProcessTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,8 +1773,8 @@ public async Task<int> RunAsync(string[] serverArguments, CancellationToken canc
17731773
ServerToken = cancellationToken;
17741774
FakeMtpServer server = ConnectBack(serverArguments);
17751775
_server = server;
1776-
_connected.TrySetResult(server);
17771776
_ = Interlocked.Increment(ref _connectionCount);
1777+
_connected.TrySetResult(server);
17781778

17791779
try
17801780
{

‎test/UnitTests/Microsoft.Testing.Platform.ServerMode.Client.Sources.UnitTests/MtpServerClientTests.cs‎

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,8 +1485,7 @@ [new RequestMessage(1, ClientAttachDebuggerMethod, null), TestContext.Cancellati
14851485
out QueueingSynchronizationContext context);
14861486

14871487
handlerCompletion.TrySetResult(new Dictionary<string, object?> { ["success"] = true });
1488-
bool completedWithoutPumping = await CompletesQuicklyAsync(invocation).ConfigureAwait(false);
1489-
DrainContextUntilCompleted(context, invocation);
1488+
bool completedWithoutPumping = await CompletesWithoutPumpingAsync(invocation, context).ConfigureAwait(false);
14901489
_ = await invocation.ConfigureAwait(false);
14911490

14921491
Assert.IsTrue(completedWithoutPumping, "Awaiting the public server-request handler must not capture the calling synchronization context.");
@@ -1708,8 +1707,7 @@ public async Task JsonRpcConnection_RequestAwaits_DoNotCaptureTheCallingSynchron
17081707
writeCompletion.TrySetResult(true);
17091708
readCompletion.TrySetResult(new ResponseMessage(1, new Dictionary<string, object?>()));
17101709

1711-
bool completedWithoutPumping = await CompletesQuicklyAsync(request).ConfigureAwait(false);
1712-
DrainContextUntilCompleted(context, request);
1710+
bool completedWithoutPumping = await CompletesWithoutPumpingAsync(request, context).ConfigureAwait(false);
17131711
_ = await request.ConfigureAwait(false);
17141712

17151713
Assert.IsTrue(completedWithoutPumping, "Request continuations must not be posted to the caller's synchronization context.");
@@ -1736,8 +1734,7 @@ public async Task JsonRpcConnection_WriteLockAwait_DoesNotCaptureTheCallingSynch
17361734
out QueueingSynchronizationContext context);
17371735
firstWriteCompletion.TrySetResult(true);
17381736

1739-
bool completedWithoutPumping = await CompletesQuicklyAsync(second).ConfigureAwait(false);
1740-
DrainContextUntilCompleted(context, second);
1737+
bool completedWithoutPumping = await CompletesWithoutPumpingAsync(second, context).ConfigureAwait(false);
17411738
await Task.WhenAll(first, second).ConfigureAwait(false);
17421739

17431740
Assert.IsTrue(completedWithoutPumping, "Waiting for the write lock must not post to the caller's synchronization context.");
@@ -1764,7 +1761,7 @@ public async Task JsonRpcConnection_ReadLoop_DoesNotCaptureAHandlerSynchronizati
17641761

17651762
readCompletion.TrySetResult(new NotificationMessage("notification", null));
17661763

1767-
bool completedWithoutPumping = await CompletesQuicklyAsync(notificationReceived.Task).ConfigureAwait(false);
1764+
bool completedWithoutPumping = await CompletesWithoutPumpingAsync(notificationReceived.Task, context).ConfigureAwait(false);
17681765
DrainContextUntilCompleted(context, readLoop);
17691766
await WithTimeoutAsync(readLoop).ConfigureAwait(false);
17701767
Assert.IsTrue(completedWithoutPumping, "The read loop must not post message dispatch to a handler-provided synchronization context.");
@@ -1791,8 +1788,7 @@ public async Task JsonRpcConnection_ServerRequestHandlerAwait_DoesNotCaptureTheC
17911788
out QueueingSynchronizationContext context);
17921789

17931790
handlerCompletion.TrySetResult(new Dictionary<string, object?> { ["success"] = true });
1794-
bool completedWithoutPumping = await CompletesQuicklyAsync(request).ConfigureAwait(false);
1795-
DrainContextUntilCompleted(context, request);
1791+
bool completedWithoutPumping = await CompletesWithoutPumpingAsync(request, context).ConfigureAwait(false);
17961792
await request.ConfigureAwait(false);
17971793

17981794
Assert.IsTrue(completedWithoutPumping, "Awaiting the server-request handler must not capture the calling synchronization context.");
@@ -1820,8 +1816,7 @@ public async Task JsonRpcConnection_ServerResponseWriteAwait_DoesNotCaptureTheCa
18201816
await WithTimeoutAsync(handler.WriteStarted).ConfigureAwait(false);
18211817

18221818
writeCompletion.TrySetResult(true);
1823-
bool completedWithoutPumping = await CompletesQuicklyAsync(request).ConfigureAwait(false);
1824-
DrainContextUntilCompleted(context, request);
1819+
bool completedWithoutPumping = await CompletesWithoutPumpingAsync(request, context).ConfigureAwait(false);
18251820
await request.ConfigureAwait(false);
18261821

18271822
Assert.IsTrue(completedWithoutPumping, "Awaiting the server response write must not capture the calling synchronization context.");
@@ -1842,8 +1837,7 @@ public async Task JsonRpcConnection_CancelNotificationAwait_DoesNotCaptureTheHan
18421837
await WithTimeoutAsync(handler.WriteStarted).ConfigureAwait(false);
18431838

18441839
cancelWriteCompletion.TrySetResult(true);
1845-
bool completedWithoutPumping = await CompletesQuicklyAsync(cancel).ConfigureAwait(false);
1846-
DrainContextUntilCompleted(context, cancel);
1840+
bool completedWithoutPumping = await CompletesWithoutPumpingAsync(cancel, context).ConfigureAwait(false);
18471841
await cancel.ConfigureAwait(false);
18481842

18491843
Assert.IsTrue(completedWithoutPumping, "Awaiting the cancel notification write must not capture the calling synchronization context.");
@@ -2165,8 +2159,7 @@ private static async Task<TException> AssertThrowsAsync<TException>(Func<Task> a
21652159
private static async Task<T> AssertCompletesWithoutPumpingAsync<T>(Func<Task<T>> action)
21662160
{
21672161
Task<T> task = InvokeWithSynchronizationContext(action, out QueueingSynchronizationContext context);
2168-
bool completedWithoutPumping = await CompletesQuicklyAsync(task).ConfigureAwait(false);
2169-
DrainContextUntilCompleted(context, task);
2162+
bool completedWithoutPumping = await CompletesWithoutPumpingAsync(task, context).ConfigureAwait(false);
21702163
T result = await task.ConfigureAwait(false);
21712164

21722165
Assert.IsTrue(
@@ -2178,8 +2171,7 @@ private static async Task<T> AssertCompletesWithoutPumpingAsync<T>(Func<Task<T>>
21782171
private static async Task AssertCompletesWithoutPumpingAsync(Func<Task> action)
21792172
{
21802173
Task task = InvokeWithSynchronizationContext(action, out QueueingSynchronizationContext context);
2181-
bool completedWithoutPumping = await CompletesQuicklyAsync(task).ConfigureAwait(false);
2182-
DrainContextUntilCompleted(context, task);
2174+
bool completedWithoutPumping = await CompletesWithoutPumpingAsync(task, context).ConfigureAwait(false);
21832175
await task.ConfigureAwait(false);
21842176

21852177
Assert.IsTrue(
@@ -2221,8 +2213,20 @@ private static Task InvokeWithSynchronizationContext(
22212213
}
22222214
}
22232215

2224-
private static async Task<bool> CompletesQuicklyAsync(Task task)
2225-
=> await Task.WhenAny(task, Task.Delay(TimeSpan.FromSeconds(1))).ConfigureAwait(false) == task;
2216+
private static async Task<bool> CompletesWithoutPumpingAsync(Task task, QueueingSynchronizationContext context)
2217+
{
2218+
try
2219+
{
2220+
Task completed = await WithTimeoutAsync(Task.WhenAny(task, context.ContinuationPosted)).ConfigureAwait(false);
2221+
return completed == task && context.PostCount == 0;
2222+
}
2223+
finally
2224+
{
2225+
DrainContextUntilCompleted(context, task);
2226+
// Join completion without rethrowing faults that the caller asserts separately.
2227+
_ = await WithTimeoutAsync(Task.WhenAny(task)).ConfigureAwait(false);
2228+
}
2229+
}
22262230

22272231
private static void DrainContextUntilCompleted(QueueingSynchronizationContext context, Task task)
22282232
{
@@ -2293,17 +2297,22 @@ private sealed class QueueingSynchronizationContext : SynchronizationContext
22932297
#else
22942298
private readonly object _lock = new();
22952299
#endif
2300+
private readonly TaskCompletionSource<bool> _continuationPosted = new(TaskCreationOptions.RunContinuationsAsynchronously);
22962301
private int _postCount;
22972302

22982303
public int PostCount => Volatile.Read(ref _postCount);
22992304

2305+
public Task ContinuationPosted => _continuationPosted.Task;
2306+
23002307
public override void Post(SendOrPostCallback d, object? state)
23012308
{
23022309
_ = Interlocked.Increment(ref _postCount);
23032310
lock (_lock)
23042311
{
23052312
_callbacks.Enqueue((d, state));
23062313
}
2314+
2315+
_continuationPosted.TrySetResult(true);
23072316
}
23082317

23092318
public bool TryRunOne()

0 commit comments

Comments
 (0)