aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJez Ng <me@jezng.com>2013-06-10 14:52:46 -0700
committerJez Ng <me@jezng.com>2013-06-19 01:22:02 -0700
commitbe5d45fe2932f9452c623b63720cb7d9857a1baa (patch)
tree757b51205f0d4698a83dd240d3ff7cab778a992d /tests
parentaf52a9aacbe6b137b231a42e745bfb8002ffca8b (diff)
Add test for HTML source map generation.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runner.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index f90911d5..b3cfd1ae 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -11731,6 +11731,37 @@ elif 'browser' in str(sys.argv):
self.btest('hello_world_sdl.cpp', reference='htmltest.png',
message='You should see "hello, world!" and a colored cube.')
+ def test_html_source_map(self):
+ cpp_file = os.path.join(self.get_dir(), 'src.cpp')
+ html_file = os.path.join(self.get_dir(), 'src.html')
+ # browsers will try to 'guess' the corresponding original line if a
+ # generated line is unmapped, so if we want to make sure that our
+ # numbering is correct, we need to provide a couple of 'possible wrong
+ # answers'. thus, we add some printf calls so that the cpp file gets
+ # multiple mapped lines. in other words, if the program consists of a
+ # single 'throw' statement, browsers may just map any thrown exception to
+ # that line, because it will be the only mapped line.
+ with open(cpp_file, 'w') as f:
+ f.write(r'''
+ #include <cstdio>
+
+ int main() {
+ printf("Starting test\n");
+ try {
+ throw 42; // line 8
+ } catch (int e) { }
+ printf("done\n");
+ return 0;
+ }
+ ''')
+ Popen([PYTHON, EMCC, cpp_file, '-o', html_file, '-g']).communicate()
+ webbrowser.open_new('file://' + html_file)
+ print '''
+Set the debugger to pause on exceptions
+You should see an exception thrown at src.cpp:7.
+Press any key to continue.'''
+ raw_input()
+
def build_native_lzma(self):
lzma_native = path_from_root('third_party', 'lzma.js', 'lzma-native')
if os.path.isfile(lzma_native) and os.access(lzma_native, os.X_OK): return