aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library.js3
-rw-r--r--tests/runner.py22
2 files changed, 21 insertions, 4 deletions
diff --git a/src/library.js b/src/library.js
index b099fd92..a9476b73 100644
--- a/src/library.js
+++ b/src/library.js
@@ -246,8 +246,7 @@ LibraryManager.library = {
// Makes sure a file's contents are loaded. Returns whether the file has
// been loaded successfully. No-op for files that have been loaded already.
forceLoadFile: function(obj) {
- if (obj.isDevice || obj.isFolder || obj.link ||
- 'contents' in obj) return true;
+ if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
var success = true;
if (typeof XMLHttpRequest !== 'undefined') {
// Browser.
diff --git a/tests/runner.py b/tests/runner.py
index 5ad9077a..602a02aa 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -3873,11 +3873,28 @@ Child2:9
#include<stdio.h>
int main() {
printf("*closured*\\n");
+
+ FILE *file = fopen("somefile.binary", "rb");
+ char buffer[1024];
+ size_t read = fread(buffer, 1, 4, file);
+ printf("data: %d", buffer[0]);
+ for (int i = 1; i < 4; i++)
+ printf(",%d", buffer[i]);
+ printf("\\n");
+
return 0;
}
'''
- def add_cc(filename):
+ def post(filename):
+ src = open(filename, 'r').read().replace(
+ '// {{PRE_RUN_ADDITIONS}}',
+ '''
+ FS.createDataFile('/', 'somefile.binary', [100, 200, 50, 25, 10, 77, 123], true, false);
+ '''
+ )
+ open(filename, 'w').write(src)
+
Popen(['java', '-jar', CLOSURE_COMPILER,
'--compilation_level', 'ADVANCED_OPTIMIZATIONS',
'--formatting', 'PRETTY_PRINT',
@@ -3888,7 +3905,8 @@ Child2:9
assert re.search('function \w\(', src) # see before
assert 'function _main()' not in src # closure should have wiped it out
open(filename, 'w').write(src)
- self.do_run(src, '*closured*', post_build=add_cc)
+
+ self.do_run(src, '*closured*\ndata: 100,200,50,25\n', post_build=post)
def test_safe_heap(self):
global SAFE_HEAP, SAFE_HEAP_LINES, USE_TYPED_ARRAYS