aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/runner.py15
-rw-r--r--tools/js_optimizer.py10
2 files changed, 17 insertions, 8 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 881b9a36..3401c621 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -10456,8 +10456,10 @@ fi
def test_jcache(self):
PRE_LOAD_MSG = 'loading pre from jcache'
PRE_SAVE_MSG = 'saving pre to jcache'
- FUNC_CHUNKS_LOAD_MSG = 'funcchunks from jcache'
- FUNC_CHUNKS_SAVE_MSG = 'funcchunks to jcache'
+ FUNC_CHUNKS_LOAD_MSG = ' funcchunks from jcache'
+ FUNC_CHUNKS_SAVE_MSG = ' funcchunks to jcache'
+ JSFUNC_CHUNKS_LOAD_MSG = 'jsfuncchunks from jcache'
+ JSFUNC_CHUNKS_SAVE_MSG = 'jsfuncchunks to jcache'
restore()
Cache.erase()
@@ -10484,16 +10486,21 @@ fi
]:
print >> sys.stderr, args, input_file, expect_save, expect_load
self.clear()
- out, err = Popen(['python', EMCC, path_from_root('tests', input_file)] + args, stdout=PIPE, stderr=PIPE).communicate()
+ out, err = Popen(['python', EMCC, '-O2', '--closure', '0', path_from_root('tests', input_file)] + args, stdout=PIPE, stderr=PIPE).communicate()
+ self.assertContained('hello, world!', run_js('a.out.js'))
assert (PRE_SAVE_MSG in err) == expect_save, err
assert (PRE_LOAD_MSG in err) == expect_load, err
assert (FUNC_CHUNKS_SAVE_MSG in err) == expect_save, err
assert (FUNC_CHUNKS_LOAD_MSG in err) == expect_load, err
+ assert (JSFUNC_CHUNKS_SAVE_MSG in err) == expect_save, err
+ assert (JSFUNC_CHUNKS_LOAD_MSG in err) == expect_load, err
curr = open('a.out.js').read()
if input_file not in srcs:
srcs[input_file] = curr
else:
- assert curr == srcs[input_file], err
+ #open('/home/alon/Dev/emscripten/a', 'w').write(srcs[input_file])
+ #open('/home/alon/Dev/emscripten/b', 'w').write(curr)
+ assert len(curr) == len(srcs[input_file]), 'contents may shift in order, but must remain the same size %d vs %d' % (len(curr), len(srcs[input_file])) + '\n' + err
used_jcache = used_jcache or ('--jcache' in args)
assert used_jcache == os.path.exists(JCache.get_cachename('emscript_files'))
diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py
index 18f10ebc..a63fc794 100644
--- a/tools/js_optimizer.py
+++ b/tools/js_optimizer.py
@@ -81,7 +81,7 @@ def run(filename, passes, js_engine, jcache):
return True
chunks = filter(load_from_cache, chunks)
if len(cached_outputs) > 0:
- if out and DEBUG: print >> sys.stderr, ' loading %d funcchunks from jcache' % len(cached_outputs)
+ if DEBUG: print >> sys.stderr, ' loading %d jsfuncchunks from jcache' % len(cached_outputs)
else:
cached_outputs = []
@@ -95,8 +95,10 @@ def run(filename, passes, js_engine, jcache):
f.close()
return temp_file
filenames = [write_chunk(chunks[i], i) for i in range(len(chunks))]
+ elif len(chunks) == 1:
+ filenames = [filename] # avoid copying a single file
else:
- filenames = [filename]
+ filenames = []
if len(filenames) > 0:
# XXX Use '--nocrankshaft' to disable crankshaft to work around v8 bug 1895, needed for older v8/node (node 0.6.8+ should be ok)
@@ -132,8 +134,8 @@ def run(filename, passes, js_engine, jcache):
chunk = chunks[i]
keys = [chunk]
shortkey = shared.JCache.get_shortkey(keys)
- shared.JCache.set(shortkey, keys, outputs[i])
- if out and DEBUG and len(chunks) > 0: print >> sys.stderr, ' saving %d funcchunks to jcache' % len(chunks)
+ shared.JCache.set(shortkey, keys, open(filenames[i]).read())
+ if DEBUG and len(chunks) > 0: print >> sys.stderr, ' saving %d jsfuncchunks to jcache' % len(chunks)
return filename