Skip to content

Commit 1d262cc

Browse files
authored
[test] Allow enabling stdio logging using EMTEST_CAPTURE_STDIO. NFC (#24204)
1 parent d80c7c7 commit 1d262cc

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3936
1+
4241

test/browser_reporting.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Set this to true to have stdout and stderr sent back to the server
2-
var captureStdoutStderr = false;
2+
var captureStdio = false;
33

44
var hasModule = typeof Module === 'object' && Module;
55

@@ -76,6 +76,12 @@ function reportTopLevelError(e) {
7676
}
7777

7878
if (typeof window === 'object' && window) {
79+
const urlString = window.location.search;
80+
const searchParams = new URLSearchParams(urlString);
81+
if (searchParams.has('capture_stdio')) {
82+
captureStdio = true;
83+
}
84+
7985
window.addEventListener('error', event => {
8086
reportTopLevelError(event.error || event)
8187
});
@@ -105,7 +111,8 @@ if (hasModule) {
105111
Module['onAbort'].proxy = true;
106112
}
107113

108-
if (captureStdoutStderr) {
114+
if (captureStdio) {
115+
console.log("enabling remote stdio logging");
109116
const origPrint = Module['print'];
110117
const origPrintErr = Module['printErr'];
111118

test/common.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
# 2: Log stdout and stderr configure/make. Print out subprocess commands that were executed.
7272
# 3: Log stdout and stderr, and pass VERBOSE=1 to CMake/configure/make steps.
7373
EMTEST_BUILD_VERBOSE = int(os.getenv('EMTEST_BUILD_VERBOSE', '0'))
74+
EMTEST_CAPTURE_STDIO = int(os.getenv('EMTEST_CAPTURE_STDIO', '0'))
7475
if 'EM_BUILD_VERBOSE' in os.environ:
7576
exit_with_error('EM_BUILD_VERBOSE has been renamed to EMTEST_BUILD_VERBOSE')
7677

@@ -2247,6 +2248,7 @@ class BrowserCore(RunnerCore):
22472248
unresponsive_tests = 0
22482249

22492250
def __init__(self, *args, **kwargs):
2251+
self.capture_stdio = EMTEST_CAPTURE_STDIO
22502252
super().__init__(*args, **kwargs)
22512253

22522254
@classmethod
@@ -2405,7 +2407,8 @@ def btest_exit(self, filename, assert_returncode=0, *args, **kwargs):
24052407

24062408
def btest(self, filename, expected=None,
24072409
post_build=None,
2408-
emcc_args=None, url_suffix='', timeout=None,
2410+
emcc_args=None,
2411+
timeout=None,
24092412
extra_tries=1,
24102413
reporting=Reporting.FULL,
24112414
output_basename='test'):
@@ -2430,7 +2433,10 @@ def btest(self, filename, expected=None,
24302433
output = self.run_js('test.js')
24312434
self.assertContained('RESULT: ' + expected[0], output)
24322435
else:
2433-
self.run_browser(outfile + url_suffix, expected=['/report_result?' + e for e in expected], timeout=timeout, extra_tries=extra_tries)
2436+
url = outfile
2437+
if self.capture_stdio:
2438+
url += "?capture_stdio"
2439+
self.run_browser(url, expected=['/report_result?' + e for e in expected], timeout=timeout, extra_tries=extra_tries)
24342440

24352441

24362442
###################################################################################################

0 commit comments

Comments
 (0)