Skip to content

Commit c03a89f

Browse files
authored
[wasm] workaround test results corruption (#61841)
* xharness bump * more logging in unit test
1 parent 721e9fc commit c03a89f

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
]
1616
},
1717
"microsoft.dotnet.xharness.cli": {
18-
"version": "1.0.0-prerelease.21561.1",
18+
"version": "1.0.0-prerelease.21572.4",
1919
"commands": [
2020
"xharness"
2121
]

eng/Version.Details.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@
202202
<Uri>https://github.com/dotnet/linker</Uri>
203203
<Sha>f2dd65f51f6096f25e00e0d1e4c6af0e85d41865</Sha>
204204
</Dependency>
205-
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.21561.1">
205+
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="1.0.0-prerelease.21572.4">
206206
<Uri>https://github.com/dotnet/xharness</Uri>
207-
<Sha>42da0d206c22393c081abc4b6a48a181e17bb372</Sha>
207+
<Sha>7aa4d338b58a2b21974933802bd731a64c36c1d8</Sha>
208208
</Dependency>
209-
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="1.0.0-prerelease.21561.1">
209+
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="1.0.0-prerelease.21572.4">
210210
<Uri>https://github.com/dotnet/xharness</Uri>
211-
<Sha>42da0d206c22393c081abc4b6a48a181e17bb372</Sha>
211+
<Sha>7aa4d338b58a2b21974933802bd731a64c36c1d8</Sha>
212212
</Dependency>
213213
<Dependency Name="Microsoft.DotNet.PackageTesting" Version="7.0.0-beta.21559.3">
214214
<Uri>https://github.com/dotnet/arcade</Uri>

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@
154154
<!-- Testing -->
155155
<MicrosoftNETCoreCoreDisToolsVersion>1.0.1-prerelease-00006</MicrosoftNETCoreCoreDisToolsVersion>
156156
<MicrosoftNETTestSdkVersion>16.9.0-preview-20201201-01</MicrosoftNETTestSdkVersion>
157-
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>1.0.0-prerelease.21561.1</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
158-
<MicrosoftDotNetXHarnessCLIVersion>1.0.0-prerelease.21561.1</MicrosoftDotNetXHarnessCLIVersion>
157+
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>1.0.0-prerelease.21572.4</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
158+
<MicrosoftDotNetXHarnessCLIVersion>1.0.0-prerelease.21572.4</MicrosoftDotNetXHarnessCLIVersion>
159159
<MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>1.0.2-alpha.0.21558.2</MicrosoftDotNetHotReloadUtilsGeneratorBuildToolVersion>
160160
<XUnitVersion>2.4.2-pre.9</XUnitVersion>
161161
<XUnitRunnerVisualStudioVersion>2.4.2</XUnitRunnerVisualStudioVersion>

src/mono/wasm/test-main.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const originalConsole = {
2323
};
2424

2525
let isXUnitDoneCheck = false;
26+
let isXmlDoneCheck = false;
2627

2728
function proxyMethod(prefix, func, asJson) {
2829
return function () {
@@ -42,7 +43,12 @@ function proxyMethod(prefix, func, asJson) {
4243
isXUnitDoneCheck = true;
4344
}
4445

45-
if (asJson) {
46+
if (payload.startsWith("STARTRESULTXML")) {
47+
originalConsole.log('Sending RESULTXML')
48+
isXmlDoneCheck = true;
49+
func(payload);
50+
}
51+
else if (asJson) {
4652
func(JSON.stringify({
4753
method: prefix,
4854
payload: payload,
@@ -66,10 +72,12 @@ function proxyJson(func) {
6672
console[m] = proxyMethod(`console.${m}`, func, true);
6773
}
6874

75+
let consoleWebSocket;
76+
6977
if (is_browser) {
7078
const consoleUrl = `${window.location.origin}/console`.replace('http://', 'ws://');
7179

72-
let consoleWebSocket = new WebSocket(consoleUrl);
80+
consoleWebSocket = new WebSocket(consoleUrl);
7381
// redirect output so that when emscripten starts it's already redirected
7482
proxyJson(function (msg) {
7583
if (consoleWebSocket.readyState === WebSocket.OPEN) {
@@ -238,7 +246,7 @@ function set_exit_code(exit_code, reason) {
238246
}
239247
if (is_browser) {
240248
const stack = (new Error()).stack.replace(/\n/g, "").replace(/[ ]*at/g, " at").replace(/https?:\/\/[0-9.:]*/g, "").replace("Error", "");
241-
const messsage = `Exit called with ${exit_code} when isXUnitDoneCheck=${isXUnitDoneCheck} ${stack}.`;
249+
const messsage = `Exit called with ${exit_code} when isXUnitDoneCheck=${isXUnitDoneCheck} isXmlDoneCheck=${isXmlDoneCheck} WS.bufferedAmount=${consoleWebSocket.bufferedAmount} ${stack}.`;
242250

243251
// Notify the selenium script
244252
Module.exit_code = exit_code;
@@ -249,20 +257,20 @@ function set_exit_code(exit_code, reason) {
249257
tests_done_elem.innerHTML = exit_code.toString();
250258
document.body.appendChild(tests_done_elem);
251259

252-
// need to flush streams (stdout/stderr)
253-
for (const stream of Module.FS.streams) {
254-
if (stream && stream.stream_ops && stream.stream_ops.flush) {
255-
stream.stream_ops.flush(stream);
260+
console.log('WS: ' + messsage);
261+
originalConsole.log('CDP: ' + messsage);
262+
const stop_when_ws_buffer_empty = () => {
263+
if (consoleWebSocket.bufferedAmount == 0) {
264+
// tell xharness WasmTestMessagesProcessor we are done.
265+
// note this sends last few bytes into the same WS
266+
console.log("WASM EXIT " + exit_code);
256267
}
257-
}
258-
console.log("Flushed stdout!");
259-
260-
console.log('1 ' + messsage);
261-
setTimeout(() => {
262-
originalConsole.log('2 ' + messsage);
263-
// tell xharness WasmTestMessagesProcessor we are done.
264-
console.log("WASM EXIT " + exit_code);
265-
}, 100);
268+
else {
269+
setTimeout(stop_when_ws_buffer_empty, 100);
270+
}
271+
};
272+
stop_when_ws_buffer_empty();
273+
266274
} else if (INTERNAL) {
267275
INTERNAL.mono_wasm_exit(exit_code);
268276
}

0 commit comments

Comments
 (0)