Skip to content

Commit 65b809d

Browse files
committed
Cleanup test_hello_world_worker. NFC
1 parent 29e98f8 commit 65b809d

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

test/hello_world_worker.cpp renamed to test/hello_world_worker.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
#include <emscripten.h>
99

1010
int main() {
11-
printf("you should not see this text when in a worker!\n"); // this should not crash, but also should not show up anywhere if you are in a worker
11+
// this should not crash, but also should not show up anywhere if you are in a worker
12+
printf("you should not see this text when in a worker!\n");
1213
FILE *f = fopen("file.dat", "r");
1314
char buffer[100];
14-
memset(buffer, 0, 100);
1515
buffer[0] = 0;
1616
if (f) fread(buffer, 10, 1, f);
1717
char buffer2[100];

test/test_browser.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,11 @@ def test_egl_width_height(self, args):
15841584
def test_egl_createcontext_error(self):
15851585
self.btest_exit('test_egl_createcontext_error.c', args=['-lEGL', '-lGL'])
15861586

1587-
def test_worker(self):
1587+
@parameterized({
1588+
'': ([False],),
1589+
'preload': ([True],),
1590+
})
1591+
def test_hello_world_worker(self, file_data):
15881592
# Test running in a web worker
15891593
create_file('file.dat', 'data for worker')
15901594
create_file('main.html', '''
@@ -1602,13 +1606,12 @@ def test_worker(self):
16021606
</html>
16031607
''' % self.port)
16041608

1605-
for file_data in (1, 0):
1606-
cmd = [EMCC, test_file('hello_world_worker.cpp'), '-o', 'worker.js'] + self.get_emcc_args()
1607-
if file_data:
1608-
cmd += ['--preload-file', 'file.dat']
1609-
self.run_process(cmd)
1610-
self.assertExists('worker.js')
1611-
self.run_browser('main.html', '/report_result?hello from worker, and :' + ('data for w' if file_data else '') + ':')
1609+
cmd = [EMCC, test_file('hello_world_worker.c'), '-o', 'worker.js'] + self.get_emcc_args()
1610+
if file_data:
1611+
cmd += ['--preload-file', 'file.dat']
1612+
self.run_process(cmd)
1613+
self.assertExists('worker.js')
1614+
self.run_browser('main.html', '/report_result?hello from worker, and :' + ('data for w' if file_data else '') + ':')
16121615

16131616
# code should run standalone too
16141617
# To great memories >4gb we need the canary version of node

0 commit comments

Comments
 (0)