aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py404
1 files changed, 376 insertions, 28 deletions
diff --git a/tests/runner.py b/tests/runner.py
index fcb84952..bf3bf119 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -355,7 +355,6 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows
js_engines = filter(lambda engine: engine not in self.banned_js_engines, js_engines)
if len(js_engines) == 0: return self.skip('No JS engine present to run this test with. Check %s and settings.py and the paths therein.' % EM_CONFIG)
for engine in js_engines:
- engine = filter(lambda arg: arg != '-n', engine) # SpiderMonkey issue 716255
js_output = self.run_generated_code(engine, filename + '.o.js', args)
if output_nicerizer is not None:
js_output = output_nicerizer(js_output)
@@ -909,6 +908,53 @@ m_divisor is 1091269979
code = open(os.path.join(self.get_dir(), 'src.cpp.o.js')).read()
assert 'goog.math.Long' not in code and 'jsbn' not in code, 'i64 precise math should not have been included if not actually used'
+ def test_i64_zextneg(self):
+ if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
+
+ src = r'''
+ #include <stdint.h>
+ #include <stdio.h>
+
+ int main(int argc, char *argv[])
+ {
+ uint8_t byte = 0x80;
+ uint16_t two = byte;
+ uint32_t four = byte;
+ uint64_t eight = byte;
+
+ printf("value: %d,%d,%d,%lld.\n", byte, two, four, eight);
+
+ return 0;
+ }
+ '''
+ self.do_run(src, 'value: 128,128,128,128.')
+
+ def test_i64_7z(self):
+ if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
+
+ src = r'''
+ #include <stdint.h>
+ #include <stdio.h>
+ uint64_t a, b;
+ int main(int argc, char *argv[])
+ {
+ a = argc;
+ b = argv[1][0];
+ if (a > a + b || a > a + b + 1) {
+ printf("one %lld, %lld", a, b);
+ return 0;
+ }
+ printf("zero %lld, %lld", a, b);
+ return 0;
+ }
+ '''
+ self.do_run(src, 'zero 2, 104', ['hallo'])
+
+ def test_sha1(self):
+ if self.emcc_args == None: return self.skip('needs ta2')
+
+ self.do_run(open(path_from_root('tests', 'sha1.c')).read(), 'SHA1=15dd99a1991e0b3826fede3deffc1feba42278e6')
+
def test_cube2hash(self):
# A good test of i64 math
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('requires ta2 C-style memory aliasing')
@@ -2702,7 +2748,7 @@ def process(filename):
output = Popen(['python', EMCC, all_name], stderr=PIPE).communicate()
# Check for warning in the generated code
generated = open(os.path.join(self.get_dir(), 'src.cpp.o.js')).read()
- assert 'Casting a function pointer type to another with a different number of arguments.' in output[1], 'Missing expected warning'
+ assert 'Casting a function pointer type to another with a different number of arguments' in output[1], 'Missing expected warning'
def test_stdlibs(self):
if Settings.USE_TYPED_ARRAYS == 2:
@@ -3546,6 +3592,7 @@ def process(filename):
printf("%g\n", strtod("0", &endptr));
printf("%g\n", strtod("0.", &endptr));
printf("%g\n", strtod("0.0", &endptr));
+ printf("%g\n", strtod("-0.0", &endptr));
printf("%g\n", strtod("1", &endptr));
printf("%g\n", strtod("1.", &endptr));
printf("%g\n", strtod("1.0", &endptr));
@@ -3570,6 +3617,7 @@ def process(filename):
0
0
0
+ 0
1
1
1
@@ -3588,6 +3636,7 @@ def process(filename):
'''
self.do_run(src, re.sub(r'\n\s+', '\n', expected))
+ self.do_run(src.replace('strtod', 'strtold'), re.sub(r'\n\s+', '\n', expected)) # XXX add real support for long double
def test_strtok(self):
src = r'''
@@ -3759,10 +3808,28 @@ at function.:blag
printf("|%s|\n", buffy);
sscanf("cheez somethingmoar\tyet more\n", "cheez %s", buffy);
printf("|%s|\n", buffy);
+
+ int numverts = -1;
+ printf("%d\n", sscanf(" numverts 1499\n", " numverts %d", &numverts)); // white space is the same, even if tab vs space
+ printf("%d\n", numverts);
+
+ int index;
+ float u, v;
+ short start, count;
+ printf("%d\n", sscanf(" vert 87 ( 0.481565 0.059481 ) 0 1\n", " vert %d ( %f %f ) %hu %hu", &index, &u, &v, &start, &count));
+ printf("%d,%.6f,%.6f,%hu,%hu\n", index, u, v, start, count);
+
+ int neg, neg2, neg3 = 0;
+ printf("%d\n", sscanf("-123 -765 -34-6", "%d %u %d", &neg, &neg2, &neg3));
+ printf("%d,%u,%d\n", neg, neg2, neg3);
+
return 0;
}
'''
- self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n-3.0300\n|some|\n|something|\n|somethingmoar|')
+ self.do_run(src, 'en-us : 2\nen-r : 99\nen : 3\n1.234567, 0.000000\n-3.0300\n|some|\n|something|\n|somethingmoar|\n' +
+ '1\n1499\n' +
+ '5\n87,0.481565,0.059481,0,1\n' +
+ '3\n-123,4294966531,-34\n')
def test_sscanf_2(self):
# doubles
@@ -4902,7 +4969,7 @@ def process(filename):
self.do_run(r'''
#define SQLITE_DISABLE_LFS
#define LONGDOUBLE_TYPE double
- #define SQLITE_INT64_TYPE int
+ #define SQLITE_INT64_TYPE long long int
#define SQLITE_THREADSAFE 0
''' + open(path_from_root('tests', 'sqlite', 'sqlite3.c'), 'r').read() +
open(path_from_root('tests', 'sqlite', 'benchmark.c'), 'r').read(),
@@ -6029,6 +6096,120 @@ def process(filename):
'''
self.do_run(src, 'hello, world!\ncleanup\nExit Status: 118')
+ def test_gc(self):
+ if self.emcc_args == None: return self.skip('needs ta2')
+
+ Settings.GC_SUPPORT = 1
+
+ src = r'''
+ #include <stdio.h>
+ #include <gc.h>
+ #include <assert.h>
+
+ void *global;
+
+ void finalizer(void *ptr, void *arg) {
+ printf("finalizing %d (global == %d)\n", (int)arg, ptr == global);
+ }
+
+ void finalizer2(void *ptr, void *arg) {
+ printf("finalizing2 %d (global == %d)\n", (int)arg, ptr == global);
+ }
+
+ int main() {
+ GC_INIT();
+
+ void *local, *local2, *local3, *local4;
+
+ // Hold on to global, drop locals
+
+ global = GC_MALLOC(1024); // rooted since in a static allocation
+ GC_REGISTER_FINALIZER_NO_ORDER(global, finalizer, 0, 0, 0);
+ printf("alloc %p\n", global);
+
+ local = GC_MALLOC(1024); // not rooted since stack is not scanned
+ GC_REGISTER_FINALIZER_NO_ORDER(local, finalizer, (void*)1, 0, 0);
+ printf("alloc %p\n", local);
+
+ assert((char*)local - (char*)global >= 1024 || (char*)global - (char*)local >= 1024);
+
+ local2 = GC_MALLOC(1024); // no finalizer
+ printf("alloc %p\n", local2);
+
+ local3 = GC_MALLOC(1024); // with finalizable2
+ GC_REGISTER_FINALIZER_NO_ORDER(local3, finalizer2, (void*)2, 0, 0);
+ printf("alloc %p\n", local);
+
+ local4 = GC_MALLOC(1024); // yet another
+ GC_REGISTER_FINALIZER_NO_ORDER(local4, finalizer2, (void*)3, 0, 0);
+ printf("alloc %p\n", local);
+
+ printf("basic test\n");
+
+ GC_FORCE_COLLECT();
+
+ printf("*\n");
+
+ GC_FREE(global); // force free will actually work
+
+ // scanning inside objects
+
+ global = GC_MALLOC(12);
+ GC_REGISTER_FINALIZER_NO_ORDER(global, finalizer, 0, 0, 0);
+ local = GC_MALLOC(12);
+ GC_REGISTER_FINALIZER_NO_ORDER(local, finalizer, (void*)1, 0, 0);
+ local2 = GC_MALLOC_ATOMIC(12);
+ GC_REGISTER_FINALIZER_NO_ORDER(local2, finalizer, (void*)2, 0, 0);
+ local3 = GC_MALLOC(12);
+ GC_REGISTER_FINALIZER_NO_ORDER(local3, finalizer, (void*)3, 0, 0);
+ local4 = GC_MALLOC(12);
+ GC_REGISTER_FINALIZER_NO_ORDER(local4, finalizer, (void*)4, 0, 0);
+
+ void **globalData = (void**)global;
+ globalData[0] = local;
+ globalData[1] = local2;
+
+ void **localData = (void**)local;
+ localData[0] = local3;
+
+ void **local2Data = (void**)local2;
+ local2Data[0] = local4; // actually ignored, because local2 is atomic, so 4 is freeable
+
+ printf("object scan test test\n");
+
+ GC_FORCE_COLLECT();
+
+ printf("*\n");
+
+ GC_FREE(global); // force free will actually work
+
+ printf("*\n");
+
+ GC_FORCE_COLLECT();
+
+ printf(".\n");
+
+ global = 0;
+
+ return 0;
+ }
+ '''
+ self.do_run(src, '''basic test
+finalizing 1 (global == 0)
+finalizing2 2 (global == 0)
+finalizing2 3 (global == 0)
+*
+finalizing 0 (global == 1)
+object scan test test
+finalizing 4 (global == 0)
+*
+finalizing 0 (global == 1)
+*
+finalizing 1 (global == 0)
+finalizing 2 (global == 0)
+finalizing 3 (global == 0)
+.
+''')
# Generate tests for everything
def make_run(fullname, name=-1, compiler=-1, llvm_opts=0, embetter=0, quantum_size=0, typed_arrays=0, emcc_args=None):
@@ -6126,6 +6307,10 @@ This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
''', output[0].replace('\r', ''), output[1].replace('\r', ''))
+ # -v, without input files
+ output = Popen(['python', compiler, '-v'], stdout=PIPE, stderr=PIPE).communicate()
+ self.assertContained('''clang version''', output[1].replace('\r', ''), output[1].replace('\r', ''))
+
# --help
output = Popen(['python', compiler, '--help'], stdout=PIPE, stderr=PIPE).communicate()
self.assertContained('''%s [options] file...
@@ -6354,6 +6539,26 @@ f.close()
# TODO: test normal project linking, static and dynamic: get_library should not need to be told what to link!
# TODO: deprecate llvm optimizations, dlmalloc, etc. in emscripten.py.
+ def test_catch_undef(self):
+ open(os.path.join(self.get_dir(), 'test.cpp'), 'w').write(r'''
+ #include <vector>
+ #include <stdio.h>
+
+ class Test {
+ public:
+ std::vector<int> vector;
+ };
+
+ Test globalInstance;
+
+ int main() {
+ printf("hello, world!\n");
+ return 1;
+ }
+ ''')
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'test.cpp'), '-fcatch-undefined-behavior']).communicate()
+ self.assertContained('hello, world!', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+
def test_l_link(self):
# Linking with -lLIBNAME and -L/DIRNAME should work
@@ -6570,6 +6775,38 @@ f.close()
Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--pre-js', 'before.js', '--post-js', 'after.js']).communicate()
self.assertContained('hello from main\nhello from js\n', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+ def test_sdl_endianness(self):
+ open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r'''
+ #include <stdio.h>
+ #include <SDL/SDL.h>
+
+ int main() {
+ printf("%d, %d, %d\n", SDL_BYTEORDER, SDL_LIL_ENDIAN, SDL_BIG_ENDIAN);
+ return 0;
+ }
+ ''')
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp')]).communicate()
+ self.assertContained('1234, 1234, 4321\n', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+
+ def test_warn_undefined(self):
+ open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r'''
+ #include <stdio.h>
+
+ extern "C" {
+ void something();
+ }
+
+ int main() {
+ something();
+ return 0;
+ }
+ ''')
+ output = Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-s', 'WARN_ON_UNDEFINED_SYMBOLS=1'], stderr=PIPE).communicate()
+ self.assertContained('Unresolved symbol: _something\n', output[1])
+
+ output = Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp')], stderr=PIPE).communicate()
+ self.assertNotContained('Unresolved symbol: _something\n', output[1])
+
def test_prepost(self):
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write('''
#include <stdio.h>
@@ -6629,6 +6866,8 @@ f.close()
['simplifyExpressionsPre', 'optimizeShiftsConservative']),
(path_from_root('tools', 'test-js-optimizer-t2.js'), open(path_from_root('tools', 'test-js-optimizer-t2-output.js')).read(),
['simplifyExpressionsPre', 'optimizeShiftsAggressive']),
+ (path_from_root('tools', 'test-js-optimizer-regs.js'), open(path_from_root('tools', 'test-js-optimizer-regs-output.js')).read(),
+ ['registerize']),
]:
output = Popen([NODE_JS, JS_OPTIMIZER, input] + passes, stdin=PIPE, stdout=PIPE).communicate()[0]
self.assertIdentical(expected, output.replace('\n\n', '\n'))
@@ -6664,6 +6903,23 @@ fscanfed: 10 - hello
''', output[0])
self.assertIdentical('texte\n', output[1])
+ def test_emconfig(self):
+ output = Popen(['python', EMCONFIG, 'LLVM_ROOT'], stdout=PIPE, stderr=PIPE).communicate()[0]
+ assert output == LLVM_ROOT + "\n"
+ invalid = 'Usage: em-config VAR_NAME\n'
+ # Don't accept variables that do not exist
+ output = Popen(['python', EMCONFIG, 'VAR_WHICH_DOES_NOT_EXIST'], stdout=PIPE, stderr=PIPE).communicate()[0]
+ assert output == invalid
+ # Don't accept no arguments
+ output = Popen(['python', EMCONFIG], stdout=PIPE, stderr=PIPE).communicate()[0]
+ assert output == invalid
+ # Don't accept more than one variable
+ output = Popen(['python', EMCONFIG, 'LLVM_ROOT', 'EMCC'], stdout=PIPE, stderr=PIPE).communicate()[0]
+ assert output == invalid
+ # Don't accept arbitrary python code
+ output = Popen(['python', EMCONFIG, 'sys.argv[1]'], stdout=PIPE, stderr=PIPE).communicate()[0]
+ assert output == invalid
+
elif 'browser' in str(sys.argv):
# Browser tests.
@@ -6739,7 +6995,7 @@ elif 'browser' in str(sys.argv):
browser.harness_queue.put('http://localhost:8888/' + html_file)
output = '[no http server activity]'
start = time.time()
- while time.time() - start < 5:
+ while time.time() - start < 60:
if not queue.empty():
output = queue.get()
break
@@ -6863,27 +7119,47 @@ elif 'browser' in str(sys.argv):
def test_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'''
- #include <stdio.h>
- #include <string.h>
- #include <emscripten.h>
- int main() {
- FILE *f = fopen("somefile.txt", "r");
- char buf[100];
- fread(buf, 1, 20, f);
- buf[20] = 0;
- fclose(f);
- printf("|%s|\n", buf);
+ def make_main(path):
+ print path
+ open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(r'''
+ #include <stdio.h>
+ #include <string.h>
+ #include <emscripten.h>
+ int main() {
+ FILE *f = fopen("%s", "r");
+ char buf[100];
+ fread(buf, 1, 20, f);
+ buf[20] = 0;
+ fclose(f);
+ printf("|%%s|\n", buf);
- int result = !strcmp("load me right before", buf);
- REPORT_RESULT();
- return 0;
- }
- '''))
+ int result = !strcmp("load me right before", buf);
+ REPORT_RESULT();
+ return 0;
+ }
+ ''' % path))
+ make_main('somefile.txt')
Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', 'somefile.txt', '-o', 'page.html']).communicate()
self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1')
+ # By absolute path
+
+ make_main(os.path.join(self.get_dir(), 'somefile.txt'))
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', os.path.join(self.get_dir(), 'somefile.txt'), '-o', 'page.html']).communicate()
+ self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1')
+
+ # With FS.preloadFile
+
+ open(os.path.join(self.get_dir(), 'pre.js'), 'w').write('''
+ Module.preRun = function() {
+ FS.createPreloadedFile('/', 'someotherfile.txt', 'somefile.txt', true, false);
+ };
+ ''')
+ make_main('someotherfile.txt')
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--pre-js', 'pre.js', '-o', 'page.html']).communicate()
+ self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1')
+
def test_multifile(self):
# a few files inside a directory
self.clear()
@@ -7050,10 +7326,11 @@ elif 'browser' in str(sys.argv):
Module['canvas'].dispatchEvent(event1);
}
}
+ window['simulateMouseEvent'] = simulateMouseEvent;
''')
open(os.path.join(self.get_dir(), 'sdl_mouse.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_mouse.c')).read()))
- Popen(['python', EMCC, os.path.join(self.get_dir(), 'sdl_mouse.c'), '-o', 'page.html', '--pre-js', 'pre.js']).communicate()
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'sdl_mouse.c'), '-O2', '--minify', '0', '-o', 'page.html', '--pre-js', 'pre.js']).communicate()
self.run_browser('page.html', '', '/report_result?740')
def test_sdl_audio(self):
@@ -7072,10 +7349,17 @@ elif 'browser' in str(sys.argv):
self.run_browser('something.html', '.', '/report_result?1')
def test_sdl_ogl(self):
- # SDL, OpenGL, textures, immediate mode
+ # SDL, OpenGL, textures, immediate mode. Closure for more coverage
shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
- self.reftest(path_from_root('tests', 'screenshot-gray.png'))
- Popen(['python', EMCC, path_from_root('tests', 'sdl_ogl.c'), '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate()
+ self.reftest(path_from_root('tests', 'screenshot-gray-purple.png'))
+ Popen(['python', EMCC, path_from_root('tests', 'sdl_ogl.c'), '-O2', '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate()
+ self.run_browser('something.html', 'You should see an image with gray at the top.', '/report_result?0')
+
+ def test_sdl_ogl_defaultmatrixmode(self):
+ # SDL, OpenGL, textures, immediate mode. Closure for more coverage
+ shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
+ self.reftest(path_from_root('tests', 'screenshot-gray-purple.png'))
+ Popen(['python', EMCC, path_from_root('tests', 'sdl_ogl_defaultMatrixMode.c'), '-O2', '--minify', '0', '-o', 'something.html', '--pre-js', 'reftest.js', '--preload-file', 'screenshot.png']).communicate()
self.run_browser('something.html', 'You should see an image with gray at the top.', '/report_result?0')
def test_sdl_ogl_p(self):
@@ -7165,10 +7449,74 @@ elif 'browser' in str(sys.argv):
Popen(['python', EMCC, program, '-o', 'program.html', '--pre-js', 'reftest.js'] + args).communicate()
self.run_browser('program.html', '', '/report_result?0')
+ def btest(self, filename, expected=None, reference=None, args=[]): # TODO: use in all other tests
+ if not reference:
+ open(os.path.join(self.get_dir(), filename), 'w').write(self.with_report_result(open(path_from_root('tests', filename)).read()))
+ else:
+ expected = '0' # 0 pixels difference than reference
+ shutil.copyfile(path_from_root('tests', filename), os.path.join(self.get_dir(), filename))
+ self.reftest(path_from_root('tests', reference))
+ args += ['--pre-js', 'reftest.js']
+ Popen(['python', EMCC, os.path.join(self.get_dir(), filename), '-o', 'test.html'] + args).communicate()
+ self.run_browser('test.html', '.', '/report_result?' + expected)
+
def test_emscripten_api(self):
- open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(self.with_report_result(open(path_from_root('tests', 'emscripten_api_browser.cpp')).read()))
- Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-o', 'page.html']).communicate()
- self.run_browser('page.html', '', '/report_result?1')
+ self.btest('emscripten_api_browser.cpp', '1')
+
+ def test_gc(self):
+ self.btest('browser_gc.cpp', '1')
+
+ def test_sdlglshader(self):
+ self.btest('sdlglshader.c', reference='sdlglshader.png', args=['--closure', '1'])
+
+ def test_gl_ps(self):
+ # pointers and a shader
+ shutil.copyfile(path_from_root('tests', 'screenshot.png'), os.path.join(self.get_dir(), 'screenshot.png'))
+ self.btest('gl_ps.c', reference='gl_ps.png', args=['--preload-file', 'screenshot.png'])
+
+ def test_cubegeom_pre(self):
+ self.btest('cubegeom_pre.c', expected='-1472804742')
+
+ def test_cubegeom_pre2(self):
+ self.btest('cubegeom_pre2.c', expected='-1472804742', args=['-s', 'GL_DEBUG=1']) # some coverage for GL_DEBUG not breaking the build
+
+ def test_cubegeom_pre3(self):
+ self.btest('cubegeom_pre3.c', expected='-1472804742')
+
+ def test_cubegeom(self):
+ self.btest('cubegeom.c', expected='188641320')
+
+ def test_cubegeom_color(self):
+ self.btest('cubegeom_color.c', expected='588472350')
+
+ def test_cubegeom_normal(self):
+ self.btest('cubegeom_normal.c', expected='752917084')
+
+ def test_cubegeom_mt(self):
+ self.btest('cubegeom_mt.c', expected='-457159152') # multitexture
+
+ def test_cubegeom_color2(self):
+ self.btest('cubegeom_color2.c', expected='1121999515')
+
+ def test_cubegeom_texturematrix(self):
+ self.btest('cubegeom_texturematrix.c', expected='1297500583')
+
+ def test_cube_explosion(self):
+ self.btest('cube_explosion.c', expected='667220544')
+
+ def test_pre_run_deps(self):
+ # Adding a dependency in preRun will delay run
+ open(os.path.join(self.get_dir(), 'pre.js'), 'w').write('''
+ Module.preRun = function() {
+ addRunDependency();
+ Module.print('preRun called, added a dependency...');
+ setTimeout(function() {
+ Module.okk = 10;
+ removeRunDependency()
+ }, 2000);
+ };
+ ''')
+ self.btest('pre_run_deps.cpp', expected='10', args=['--pre-js', 'pre.js'])
elif 'benchmark' in str(sys.argv):
# Benchmarks. Run them with argument |benchmark|. To run a specific test, do