diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-08 18:49:20 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-08 18:49:20 -0700 |
commit | 2d0bd0061a4e57f999cf5c4bd537ffd8a2a0cdba (patch) | |
tree | 7538e0a56c506ff4e56c3e5b085f486b1f0bf0e4 | |
parent | 82a80c6724f7a8f17daf0ee7a01f124a9ab193ec (diff) |
add test harness support for proxying, test_sdl_canvas_proxy passes
-rwxr-xr-x | tests/runner.py | 6 | ||||
-rw-r--r-- | tests/sdl_canvas_proxy.c | 4 | ||||
-rw-r--r-- | tests/sdl_canvas_proxy.png | bin | 0 -> 4488 bytes | |||
-rw-r--r-- | tests/test_browser.py | 19 |
4 files changed, 24 insertions, 5 deletions
diff --git a/tests/runner.py b/tests/runner.py index 8747c340..ddc97ea4 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -646,7 +646,7 @@ class BrowserCore(RunnerCore): }); ''' % basename) - def btest(self, filename, expected=None, reference=None, force_c=False, reference_slack=0, + def btest(self, filename, expected=None, reference=None, force_c=False, reference_slack=0, manual_reference=False, post_build=None, args=[], outfile='test.html', message='.'): # TODO: use in all other tests # if we are provided the source and not a path, use that filename_is_src = '\n' in filename @@ -663,9 +663,11 @@ class BrowserCore(RunnerCore): expected = [str(i) for i in range(0, reference_slack+1)] shutil.copyfile(filepath, temp_filepath) self.reftest(path_from_root('tests', reference)) - args = args + ['--pre-js', 'reftest.js', '-s', 'GL_TESTING=1'] + if not manual_reference: + args = args + ['--pre-js', 'reftest.js', '-s', 'GL_TESTING=1'] Popen([PYTHON, EMCC, temp_filepath, '-o', outfile] + args).communicate() assert os.path.exists(outfile) + if post_build: post_build() if type(expected) is str: expected = [expected] self.run_browser(outfile, message, ['/report_result?' + e for e in expected]) diff --git a/tests/sdl_canvas_proxy.c b/tests/sdl_canvas_proxy.c index ae0a8f23..2b33be29 100644 --- a/tests/sdl_canvas_proxy.c +++ b/tests/sdl_canvas_proxy.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> +#include <emscripten.h> int main(int argc, char **argv) { SDL_Init(SDL_INIT_VIDEO); @@ -17,8 +18,7 @@ int main(int argc, char **argv) { SDL_Quit(); - printf("done.\n"); - + EM_ASM(window.close()); return 0; } diff --git a/tests/sdl_canvas_proxy.png b/tests/sdl_canvas_proxy.png Binary files differnew file mode 100644 index 00000000..cc96acfd --- /dev/null +++ b/tests/sdl_canvas_proxy.png diff --git a/tests/test_browser.py b/tests/test_browser.py index 7465711b..c2910c80 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -628,7 +628,24 @@ If manually bisecting: self.run_browser('page.html', '', '/report_result?1') def test_sdl_canvas_proxy(self): - self.btest('sdl_canvas_proxy.c', '1', args=['--proxy-to-worker']) + def post(): + html = open('test.html').read() + html = html.replace('</body>', ''' +<script> +function assert(x, y) { if (!x) throw 'assertion failed ' + y } + +%s + +var windowClose = window.close; +window.close = function() { + doReftest(); + setTimeout(windowClose, 1000); +}; +</script> +</body>''' % open('reftest.js').read()) + open('test.html', 'w').write(html) + + self.btest('sdl_canvas_proxy.c', reference='sdl_canvas_proxy.png', args=['--proxy-to-worker'], manual_reference=True, post_build=post) def test_sdl_key(self): open(os.path.join(self.get_dir(), 'pre.js'), 'w').write(''' |