MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / test_extern_prepost

Method test_extern_prepost

test/test_other.py:3013–3032  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3011 cflags=['--pre-js', 'pre.js', '--pre-js', 'pre2.js'])
3012
3013 def test_extern_prepost(self):
3014 create_file('extern-pre.js', '// I am an external pre.\n')
3015 create_file('extern-post.js', '// I am an external post.\n')
3016 self.run_process([EMCC, '-O2', test_file('hello_world.c'), '--extern-pre-js', 'extern-pre.js', '--extern-post-js', 'extern-post.js', '--closure=1'])
3017 # the files should be included, and externally - not as part of optimized
3018 # code, so they are the very first and last things, and they are not
3019 # minified.
3020 js = read_file('a.out.js')
3021 js_size = len(js)
3022 print('js_size', js_size)
3023 pre_offset = js.index('// I am an external pre.')
3024 post_offset = js.index('// I am an external post.')
3025 # ignore some slack - newlines and other things. we just care about the
3026 # big picture here
3027 SLACK = 50
3028 self.assertLess(pre_offset, post_offset)
3029 self.assertLess(pre_offset, SLACK)
3030 self.assertGreater(post_offset, js_size - SLACK)
3031 # make sure the slack is tiny compared to the whole program
3032 self.assertGreater(js_size, 50 * SLACK)
3033
3034 @parameterized({
3035 'minifyGlobals': (['minifyGlobals'],),

Callers

nothing calls this directly

Calls 6

create_fileFunction · 0.90
test_fileFunction · 0.90
read_fileFunction · 0.90
run_processMethod · 0.80
printFunction · 0.50
indexMethod · 0.45

Tested by

no test coverage detected