Skip to content

Commit 160bd91

Browse files
committed
fix test
1 parent 2f67851 commit 160bd91

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

test/test_other.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,33 +3954,34 @@ def test_file_packager_standalone_modularize(self):
39543954
MESSAGE = 'Remember to build the main file with `-sFORCE_FILESYSTEM` so that it includes support for loading this file package'
39553955

39563956
create_file('data.txt', 'hello data')
3957-
err = self.run_process([FILE_PACKAGER, 'test.data', '--modularize', '--preload', 'data.txt', '--js-output=dataFileLoader.mjs'], stderr=PIPE).stderr
3957+
err = self.run_process([FILE_PACKAGER, 'test.data', '--modularize', '--preload', 'data.txt', '--js-output=dataFileLoader.js', '--no-node'], stderr=PIPE).stderr
39583958
self.assertContained(MESSAGE, err)
39593959

3960-
create_file('test.cpp', '''
3960+
create_file('test.c', '''
39613961
#include <stdio.h>
3962-
#include <emscripten/bind.h>
39633962

3964-
int EMSCRIPTEN_KEEPALIVE test_fun() {
3963+
int main() {
39653964
FILE* f = fopen("data.txt", "r");
3966-
char buf[64];
3965+
char buf[64] = {0};
39673966
int rtn = fread(buf, 1, 64, f);
39683967
buf[rtn] = '\\0';
39693968
fclose(f);
39703969
printf("%s\\n", buf);
39713970
return 0;
39723971
}
39733972
''')
3974-
self.run_process([EMCC, 'test.cpp', '-sFORCE_FILESYSTEM', '-sMODULARIZE', '-sEXPORT_ES6', '-o', 'moduleFile.mjs'])
3973+
self.run_process([EMCC, 'test.c', '-sFORCE_FILESYSTEM', '-sMODULARIZE', '-sEXPORT_ES6', '-o', 'moduleFile.js'])
39753974

39763975
create_file('run.js', '''
3977-
import loadDataFile from 'dataFileLoader.mjs'
3978-
import {default as loadModule} from 'moduleFile.mjs'
3976+
import loadDataFile from './dataFileLoader.js'
3977+
import {default as loadModule} from './moduleFile.js'
39793978

3979+
const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
39803980
var module = loadModule();
3981-
module.then((mod) => {
3982-
loadDataFile(mod);
3983-
mod._test_fun();
3981+
module.then(async (module) => {
3982+
loadDataFile(module);
3983+
await sleep(1000);
3984+
module._test_fun();
39843985
});
39853986
''')
39863987

0 commit comments

Comments
 (0)