Skip to content

Commit d5c419f

Browse files
authored
[test] Remove (broken) EMTEST_BROWSER_PORT test setting (#23113)
The `browser_reporting.js` file (which does most of the reporting these days) was not honoring it anyway. I've never found the need to configure this in all the years I've been working on emscripten so hopefully we don't need to bring it back.
1 parent d87c1ac commit d5c419f

File tree

5 files changed

+30
-42
lines changed

5 files changed

+30
-42
lines changed

site/source/docs/porting/files/Synchronous-Virtual-XHR-Backed-File-System-Usage.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ Instructions
6363

6464
.. include:: ../../../../../test/test_browser.py
6565
:literal:
66-
:start-after: create_file('main.html',
67-
:end-before: """ % (worker_filename, self.port))
66+
:start-after: create_file('main.html', '''
67+
:end-before: ''' % self.PORT)
6868
:code: html

test/browser_reporting.js

+13-17
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
var hasModule = typeof Module === 'object' && Module;
22

3-
/**
4-
* @param {number=} port
5-
*/
6-
function reportResultToServer(result, port) {
7-
port = port || 8888;
3+
var reportingURL = 'http://localhost:8888/';
4+
5+
function reportResultToServer(result) {
86
if (reportResultToServer.reported) {
97
// Only report one result per test, even if the test misbehaves and tries to report more.
108
reportErrorToServer(`excessive reported results, sending ${result}, test will fail`);
@@ -14,7 +12,7 @@ function reportResultToServer(result, port) {
1412
out(`RESULT: ${result}`);
1513
} else {
1614
let doFetch = typeof origFetch != 'undefined' ? origFetch : fetch;
17-
doFetch(`http://localhost:${port}/report_result?${encodeURIComponent(result)}`).then(() => {
15+
doFetch(`${reportingURL}/report_result?${encodeURIComponent(result)}`).then(() => {
1816
if (typeof window === 'object' && window && hasModule && !Module['pageThrewException']) {
1917
/* for easy debugging, don't close window on failure */
2018
window.close();
@@ -24,26 +22,24 @@ function reportResultToServer(result, port) {
2422
}
2523

2624
function sendFileToServer(filename, contents) {
27-
fetch(`http://localhost:8888/?file=${encodeURIComponent(filename)}`, {method: "POST", body: contents});
25+
fetch(`${reportingURL}/?file=${encodeURIComponent(filename)}`, {method: "POST", body: contents});
2826
}
2927

30-
/**
31-
* @param {number=} port
32-
*/
33-
function maybeReportResultToServer(result, port) {
34-
if (reportResultToServer.reported) return;
35-
reportResultToServer(result, port);
28+
function maybeReportResultToServer(result) {
29+
if (!reportResultToServer.reported) {
30+
reportResultToServer(result);
31+
}
3632
}
3733

3834
function reportErrorToServer(message) {
3935
if (typeof ENVIRONMENT_IS_NODE !== 'undefined' && ENVIRONMENT_IS_NODE) {
4036
err(message);
4137
} else {
42-
fetch(`http://localhost:8888?stderr=${encodeURIComponent(message)}`);
38+
fetch(`${reportingURL}?stderr=${encodeURIComponent(message)}`);
4339
}
4440
}
4541

46-
function report_error(e) {
42+
function reportTopLevelError(e) {
4743
// MINIMAL_RUNTIME doesn't handle exit or call the below onExit handler
4844
// so we detect the exit by parsing the uncaught exception message.
4945
var message = e.message || e;
@@ -68,9 +64,9 @@ function report_error(e) {
6864

6965
if (typeof window === 'object' && window) {
7066
window.addEventListener('error', event => {
71-
report_error(event.error || event)
67+
reportTopLevelError(event.error || event)
7268
});
73-
window.addEventListener('unhandledrejection', event => report_error(event.reason));
69+
window.addEventListener('unhandledrejection', event => reportTopLevelError(event.reason));
7470
}
7571

7672
if (hasModule) {

test/common.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -2072,6 +2072,9 @@ class BrowserCore(RunnerCore):
20722072
# suite early, as otherwise we will wait for the timeout on every
20732073
# single test (hundreds of minutes)
20742074
MAX_UNRESPONSIVE_TESTS = 10
2075+
PORT = 8888
2076+
HARNESS_URL = 'http://localhost:%s/run_harness' % PORT
2077+
BROWSER_TIMEOUT = 60
20752078

20762079
unresponsive_tests = 0
20772080

@@ -2091,7 +2094,7 @@ def browser_restart(cls):
20912094
logger.info('Browser did not respond to `terminate`. Using `kill`')
20922095
cls.browser_proc.kill()
20932096
cls.browser_proc.wait()
2094-
cls.browser_open(cls.harness_url)
2097+
cls.browser_open(cls.HARNESS_URL)
20952098

20962099
@classmethod
20972100
def browser_open(cls, url):
@@ -2106,17 +2109,14 @@ def browser_open(cls, url):
21062109
@classmethod
21072110
def setUpClass(cls):
21082111
super().setUpClass()
2109-
cls.port = int(os.getenv('EMTEST_BROWSER_PORT', '8888'))
21102112
if not has_browser() or EMTEST_BROWSER == 'node':
21112113
return
2112-
cls.browser_timeout = 60
21132114
cls.harness_in_queue = multiprocessing.Queue()
21142115
cls.harness_out_queue = multiprocessing.Queue()
2115-
cls.harness_server = multiprocessing.Process(target=harness_server_func, args=(cls.harness_in_queue, cls.harness_out_queue, cls.port))
2116+
cls.harness_server = multiprocessing.Process(target=harness_server_func, args=(cls.harness_in_queue, cls.harness_out_queue, cls.PORT))
21162117
cls.harness_server.start()
21172118
print('[Browser harness server on process %d]' % cls.harness_server.pid)
2118-
cls.harness_url = 'http://localhost:%s/run_harness' % cls.port
2119-
cls.browser_open(cls.harness_url)
2119+
cls.browser_open(cls.HARNESS_URL)
21202120

21212121
@classmethod
21222122
def tearDownClass(cls):
@@ -2158,11 +2158,11 @@ def run_browser(self, html_file, expected=None, message=None, timeout=None, extr
21582158
if expected is not None:
21592159
try:
21602160
self.harness_in_queue.put((
2161-
'http://localhost:%s/%s' % (self.port, html_file),
2161+
'http://localhost:%s/%s' % (self.PORT, html_file),
21622162
self.get_dir()
21632163
))
21642164
if timeout is None:
2165-
timeout = self.browser_timeout
2165+
timeout = self.BROWSER_TIMEOUT
21662166
try:
21672167
output = self.harness_out_queue.get(block=True, timeout=timeout)
21682168
except queue.Empty:
@@ -2213,7 +2213,6 @@ def compile_btest(self, filename, args, reporting=Reporting.FULL):
22132213
# If C reporting (i.e. the REPORT_RESULT macro) is required we
22142214
# also include report_result.c and force-include report_result.h
22152215
self.run_process([EMCC, '-c', '-I' + TEST_ROOT,
2216-
'-DEMTEST_PORT_NUMBER=%d' % self.port,
22172216
test_file('report_result.c')] + self.get_emcc_args(compile_only=True) + (['-fPIC'] if '-fPIC' in args else []))
22182217
args += ['report_result.o', '-include', test_file('report_result.h')]
22192218
if EMTEST_BROWSER == 'node':

test/report_result.c

+2-9
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,13 @@ extern "C" {
2020
#endif
2121

2222
#if defined __EMSCRIPTEN__ && !defined EMTEST_NODE
23-
#ifndef EMTEST_PORT_NUMBER
24-
#error "EMTEST_PORT_NUMBER not defined"
25-
#endif
2623

2724
void EMSCRIPTEN_KEEPALIVE _ReportResult(int result) {
28-
EM_ASM({
29-
reportResultToServer($0, $1);
30-
}, result, EMTEST_PORT_NUMBER);
25+
EM_ASM(reportResultToServer($0), result);
3126
}
3227

3328
void EMSCRIPTEN_KEEPALIVE _MaybeReportResult(int result) {
34-
EM_ASM({
35-
maybeReportResultToServer($0, $1);
36-
}, result, EMTEST_PORT_NUMBER);
29+
EM_ASM(maybeReportResultToServer($0), result);
3730
}
3831

3932
#else

test/test_browser.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ def test_hello_world_worker(self, file_data):
16081608
</script>
16091609
</body>
16101610
</html>
1611-
''' % self.port)
1611+
''' % self.PORT)
16121612

16131613
cmd = [EMCC, test_file('hello_world_worker.c'), '-o', 'worker.js'] + self.get_emcc_args()
16141614
if file_data:
@@ -1671,7 +1671,7 @@ def test_chunked_synchronous_xhr(self):
16711671
</script>
16721672
</body>
16731673
</html>
1674-
""" % (worker_filename, self.port))
1674+
""" % (worker_filename, self.PORT))
16751675

16761676
create_file('worker_prejs.js', r"""
16771677
Module.arguments = ["/bigfile"];
@@ -1688,7 +1688,7 @@ def test_chunked_synchronous_xhr(self):
16881688
data = os.urandom(10 * chunkSize + 1) # 10 full chunks and one 1 byte chunk
16891689
checksum = zlib.adler32(data) & 0xffffffff # Python 2 compatibility: force bigint
16901690

1691-
server = multiprocessing.Process(target=test_chunked_synchronous_xhr_server, args=(True, chunkSize, data, checksum, self.port))
1691+
server = multiprocessing.Process(target=test_chunked_synchronous_xhr_server, args=(True, chunkSize, data, checksum, self.PORT))
16921692
server.start()
16931693

16941694
# block until the server is actually ready
@@ -2422,7 +2422,7 @@ def test_runtime_misuse(self):
24222422
doCwrapCall(200);
24232423
doDirectCall(300);
24242424
}
2425-
''' % self.port
2425+
''' % self.PORT
24262426

24272427
create_file('pre_runtime.js', r'''
24282428
Module.onRuntimeInitialized = myJSCallback;
@@ -2569,7 +2569,7 @@ def test_html5_core(self, opts):
25692569
window.disableErrorReporting = true;
25702570
window.addEventListener('error', (event) => {
25712571
if (!event.message.includes('exception:fullscreen error')) {
2572-
report_error(event);
2572+
reportTopLevelError(event);
25732573
}
25742574
});
25752575
''')

0 commit comments

Comments
 (0)