@@ -3804,33 +3804,20 @@ def check(text):
3804
3804
stderr = self.expect_fail([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../data1.txt'])
3805
3805
self.assertContained('which is not contained within the current directory', stderr)
3806
3806
3807
- stderr = self.expect_fail([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../data1.txt', '--modularize'])
3808
- self.assertContained('which is not contained within the current directory', stderr)
3809
-
3810
3807
# relative path that ends up under us is cool
3811
3808
proc = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../subdir/data2.txt'], stderr=PIPE, stdout=PIPE)
3812
3809
self.assertEqual(proc.stderr, '')
3813
3810
check(proc.stdout)
3814
3811
3815
- proc = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../subdir/data2.txt', '--modularize'], stderr=PIPE, stdout=PIPE)
3816
- self.assertEqual(proc.stderr, '')
3817
- check(proc.stdout)
3818
-
3819
- def clean(txt):
3820
- lines = txt.splitlines()
3821
- lines = [l for l in lines if 'PACKAGE_UUID' not in l and 'loadPackage({' not in l]
3822
- return ''.join(lines)
3823
-
3824
3812
# direct path leads to the same code being generated - relative path does not make us do anything different
3825
3813
proc2 = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', 'data2.txt'], stderr=PIPE, stdout=PIPE)
3826
3814
check(proc2.stdout)
3827
3815
self.assertEqual(proc2.stderr, '')
3828
3816
3829
- self.assertTextDataIdentical(clean(proc.stdout), clean(proc2.stdout))
3830
-
3831
- proc2 = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', 'data2.txt', '--modularize'], stderr=PIPE, stdout=PIPE)
3832
- check(proc2.stdout)
3833
- self.assertEqual(proc2.stderr, '')
3817
+ def clean(txt):
3818
+ lines = txt.splitlines()
3819
+ lines = [l for l in lines if 'PACKAGE_UUID' not in l and 'loadPackage({' not in l]
3820
+ return ''.join(lines)
3834
3821
3835
3822
self.assertTextDataIdentical(clean(proc.stdout), clean(proc2.stdout))
3836
3823
@@ -3935,7 +3922,7 @@ def test_file_packager_returns_error_if_target_equal_to_jsoutput(self):
3935
3922
def test_file_packager_returns_error_if_emcc_and_modularize(self):
3936
3923
MESSAGE = 'error: Can\'t use modularize option together with --from-emcc since the code should be embedded within emcc\'s code'
3937
3924
err = self.expect_fail([FILE_PACKAGER, 'test.data', '--modularize', '--from-emcc'])
3938
- self.assertEqual (MESSAGE, err)
3925
+ self.assertContained (MESSAGE, err)
3939
3926
3940
3927
def test_file_packager_embed(self):
3941
3928
create_file('data.txt', 'hello data')
@@ -3968,13 +3955,13 @@ def test_file_packager_standalone_modularize(self):
3968
3955
3969
3956
create_file('data.txt', 'hello data')
3970
3957
err = self.run_process([FILE_PACKAGER, 'test.data', '--modularize', '--preload', 'data.txt', '--js-output=dataFileLoader.mjs'], stderr=PIPE).stderr
3971
- self.assertEqual (MESSAGE, err)
3958
+ self.assertContained (MESSAGE, err)
3972
3959
3973
3960
create_file('test.cpp', '''
3974
3961
#include <stdio.h>
3975
3962
#include <emscripten/bind.h>
3976
3963
3977
- int test_fun() {
3964
+ int EMSCRIPTEN_KEEPALIVE test_fun() {
3978
3965
FILE* f = fopen("data.txt", "r");
3979
3966
char buf[64];
3980
3967
int rtn = fread(buf, 1, 64, f);
@@ -3983,12 +3970,8 @@ def test_file_packager_standalone_modularize(self):
3983
3970
printf("%s\\n", buf);
3984
3971
return 0;
3985
3972
}
3986
-
3987
- EMSCRIPTEN_BINDINGS(my_module) {
3988
- emscripten::function("TestFun", &test_fun);
3989
- }
3990
3973
''')
3991
- self.run_process([EMCC, 'test.cpp', '-sFORCE_FILESYSTEM', '-sMODULARIZE', '-sEXPORT_ES6', '-o', 'moduleFile.mjs', '-lembind' ])
3974
+ self.run_process([EMCC, 'test.cpp', '-sFORCE_FILESYSTEM', '-sMODULARIZE', '-sEXPORT_ES6', '-o', 'moduleFile.mjs'])
3992
3975
3993
3976
create_file('run.js', '''
3994
3977
import loadDataFile from 'dataFileLoader.mjs'
@@ -3997,7 +3980,7 @@ def test_file_packager_standalone_modularize(self):
3997
3980
var module = loadModule();
3998
3981
module.then((mod) => {
3999
3982
loadDataFile(mod);
4000
- mod.TestFun ();
3983
+ mod._test_fun ();
4001
3984
});
4002
3985
''')
4003
3986
0 commit comments