aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-03-16 12:39:12 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-03-16 12:39:12 -0700
commit1a2df275c5fb4bf9f3df3550bd8cdb156268ff83 (patch)
tree3c26bff9aa401569c52e9636aed6423084b4db16 /tests/runner.py
parent37011d48e315393cb0e271fd00a490585fba5b9d (diff)
source code compression option in emcc
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 66aa63b4..28e918b7 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6220,6 +6220,28 @@ f.close()
emscripten_run_script(output);
''')
+ def test_emcc_compression(self):
+ open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(r'''
+ #include <stdio.h>
+ #include <emscripten.h>
+ int main() {
+ printf("hello compressed world\n");
+ int result = 1;
+ REPORT_RESULT();
+ return 0;
+ }
+ '''))
+
+ Popen([EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-o', 'page.html',
+ '--compression', '%s,%s,%s' % (path_from_root('third_party', 'lzma.js', 'lzma-native'),
+ path_from_root('third_party', 'lzma.js', 'lzma-decoder.js'),
+ 'LZMA.decompress')]).communicate()
+ assert os.path.exists(os.path.join(self.get_dir(), 'page.js')), 'must be side js'
+ assert os.path.exists(os.path.join(self.get_dir(), 'page.js.compress')), 'must be side compressed js'
+ assert os.stat(os.path.join(self.get_dir(), 'page.js')).st_size > os.stat(os.path.join(self.get_dir(), 'page.js.compress')).st_size, 'compressed file must be smaller'
+ shutil.move(os.path.join(self.get_dir(), 'page.js'), 'page.js.renamedsoitcannotbefound');
+ self.run_browser('page.html', '', '/report_result?1')
+
def test_emcc_preload_file(self):
open(os.path.join(self.get_dir(), 'somefile.txt'), 'w').write('''load me right before running the code please''')
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(r'''
@@ -6291,9 +6313,6 @@ f.close()
Popen([EMCC, os.path.join(self.get_dir(), 'sdl_image.c'), '--preload-file', 'screenshot.jpg', '-o', 'page.html']).communicate()
self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?600')
- def test_emcc_compression(self):
- pass # test compression of both the compiled code itself in a side file, and of data files
-
def test_emcc_worker(self):
# Test running in a web worker
output = Popen([EMCC, path_from_root('tests', 'hello_world_worker.cpp'), '-o', 'worker.js'], stdout=PIPE, stderr=PIPE).communicate()