diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-03-15 14:13:40 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-03-15 14:13:40 -0700 |
commit | 38821ffb775f923179c0607e03329be58cc2f86d (patch) | |
tree | d9df7b1e35f7ec0053ef739ac0a46e3f17ef8c63 | |
parent | 71bcdf42327d1c9e4414bd38d7275ebe175a03e4 (diff) |
html tests refactoring
-rwxr-xr-x | tests/runner.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/runner.py b/tests/runner.py index 4f72e67d..0208720b 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -6210,9 +6210,19 @@ f.close() assert os.path.exists('something.html'), output self.run_browser('something.html', 'You should see "hello, world!" and a colored cube.') + def with_report_result(self, code): + return code.replace('REPORT_RESULT();', ''' + char output[1000]; + sprintf(output, + "xhr = new XMLHttpRequest();" + "xhr.open('GET', 'http://localhost:8888/report_result?%d');" + "xhr.send();", result); + emscripten_run_script(output); +''') + 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(r''' + 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> @@ -6224,16 +6234,11 @@ f.close() fclose(f); printf("|%s|\n", buf); - int ok = !strcmp("load me right before", buf); - char output[1000]; - sprintf(output, - "xhr = new XMLHttpRequest();" - "xhr.open('GET', 'http://localhost:8888/report_result?%d');" - "xhr.send();", ok); - emscripten_run_script(output); + int result = !strcmp("load me right before", buf); + REPORT_RESULT(); return 0; } - ''') + ''')) Popen([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') |