@@ -3788,33 +3788,20 @@ def check(text):
3788
3788
stderr = self.expect_fail([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../data1.txt'])
3789
3789
self.assertContained('which is not contained within the current directory', stderr)
3790
3790
3791
- stderr = self.expect_fail([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../data1.txt', '--modularize'])
3792
- self.assertContained('which is not contained within the current directory', stderr)
3793
-
3794
3791
# relative path that ends up under us is cool
3795
3792
proc = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../subdir/data2.txt'], stderr=PIPE, stdout=PIPE)
3796
3793
self.assertEqual(proc.stderr, '')
3797
3794
check(proc.stdout)
3798
3795
3799
- proc = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../subdir/data2.txt', '--modularize'], stderr=PIPE, stdout=PIPE)
3800
- self.assertEqual(proc.stderr, '')
3801
- check(proc.stdout)
3802
-
3803
- def clean(txt):
3804
- lines = txt.splitlines()
3805
- lines = [l for l in lines if 'PACKAGE_UUID' not in l and 'loadPackage({' not in l]
3806
- return ''.join(lines)
3807
-
3808
3796
# direct path leads to the same code being generated - relative path does not make us do anything different
3809
3797
proc2 = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', 'data2.txt'], stderr=PIPE, stdout=PIPE)
3810
3798
check(proc2.stdout)
3811
3799
self.assertEqual(proc2.stderr, '')
3812
3800
3813
- self.assertTextDataIdentical(clean(proc.stdout), clean(proc2.stdout))
3814
-
3815
- proc2 = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', 'data2.txt', '--modularize'], stderr=PIPE, stdout=PIPE)
3816
- check(proc2.stdout)
3817
- self.assertEqual(proc2.stderr, '')
3801
+ def clean(txt):
3802
+ lines = txt.splitlines()
3803
+ lines = [l for l in lines if 'PACKAGE_UUID' not in l and 'loadPackage({' not in l]
3804
+ return ''.join(lines)
3818
3805
3819
3806
self.assertTextDataIdentical(clean(proc.stdout), clean(proc2.stdout))
3820
3807
@@ -3919,7 +3906,7 @@ def test_file_packager_returns_error_if_target_equal_to_jsoutput(self):
3919
3906
def test_file_packager_returns_error_if_emcc_and_modularize(self):
3920
3907
MESSAGE = 'error: Can\'t use modularize option together with --from-emcc since the code should be embedded within emcc\'s code'
3921
3908
err = self.expect_fail([FILE_PACKAGER, 'test.data', '--modularize', '--from-emcc'])
3922
- self.assertEqual (MESSAGE, err)
3909
+ self.assertContained (MESSAGE, err)
3923
3910
3924
3911
def test_file_packager_embed(self):
3925
3912
create_file('data.txt', 'hello data')
@@ -3952,13 +3939,13 @@ def test_file_packager_standalone_modularize(self):
3952
3939
3953
3940
create_file('data.txt', 'hello data')
3954
3941
err = self.run_process([FILE_PACKAGER, 'test.data', '--modularize', '--preload', 'data.txt', '--js-output=dataFileLoader.mjs'], stderr=PIPE).stderr
3955
- self.assertEqual (MESSAGE, err)
3942
+ self.assertContained (MESSAGE, err)
3956
3943
3957
3944
create_file('test.cpp', '''
3958
3945
#include <stdio.h>
3959
3946
#include <emscripten/bind.h>
3960
3947
3961
- int test_fun() {
3948
+ int EMSCRIPTEN_KEEPALIVE test_fun() {
3962
3949
FILE* f = fopen("data.txt", "r");
3963
3950
char buf[64];
3964
3951
int rtn = fread(buf, 1, 64, f);
@@ -3967,12 +3954,8 @@ def test_file_packager_standalone_modularize(self):
3967
3954
printf("%s\\n", buf);
3968
3955
return 0;
3969
3956
}
3970
-
3971
- EMSCRIPTEN_BINDINGS(my_module) {
3972
- emscripten::function("TestFun", &test_fun);
3973
- }
3974
3957
''')
3975
- self.run_process([EMCC, 'test.cpp', '-sFORCE_FILESYSTEM', '-sMODULARIZE', '-sEXPORT_ES6', '-o', 'moduleFile.mjs', '-lembind' ])
3958
+ self.run_process([EMCC, 'test.cpp', '-sFORCE_FILESYSTEM', '-sMODULARIZE', '-sEXPORT_ES6', '-o', 'moduleFile.mjs'])
3976
3959
3977
3960
create_file('run.js', '''
3978
3961
import loadDataFile from 'dataFileLoader.mjs'
@@ -3981,7 +3964,7 @@ def test_file_packager_standalone_modularize(self):
3981
3964
var module = loadModule();
3982
3965
module.then((mod) => {
3983
3966
loadDataFile(mod);
3984
- mod.TestFun ();
3967
+ mod._test_fun ();
3985
3968
});
3986
3969
''')
3987
3970
0 commit comments