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

Method test_node

test/test_sanity.py:296–337  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

294
295 @no_windows('Test relies on Unix-specific shell script')
296 def test_node(self):
297 NODE_WARNING = 'node version appears too old'
298 NODE_WARNING_2 = 'cannot check node version'
299
300 restore_and_set_up()
301 cmd = [EMCC, test_file('hello_world.c')]
302
303 # Clang should report the version number we expect, and emcc should not warn
304 output = self.do(cmd)
305 self.assertNotContained(NODE_WARNING, output)
306
307 # Fake a different node version
308 restore_and_set_up()
309 add_to_config('NODE_JS = "' + self.in_dir('fake', 'nodejs') + '"')
310
311 ensure_dir('fake')
312
313 for version, succeed in (('v0.8.0', False),
314 ('v4.1.0', False),
315 ('v10.18.0', False),
316 ('v16.20.0', False),
317 ('v18.19.1', True),
318 ('v18.19.1-pre', True),
319 ('cheez', False)):
320 print(version, succeed)
321 delete_file(SANITY_FILE)
322 utils.write_file(self.in_dir('fake', 'nodejs'), '''#!/bin/sh
323if [ $1 = "--version" ]; then
324echo "%s"
325else
326%s $@
327fi
328''' % (version, ' '.join(config.NODE_JS)))
329 make_executable(self.in_dir('fake', 'nodejs'))
330 if not succeed:
331 if version[0] == 'v':
332 self.check_working(cmd, NODE_WARNING)
333 else:
334 self.check_working(cmd, NODE_WARNING_2)
335 else:
336 output = self.do(cmd)
337 self.assertNotContained(NODE_WARNING, output)
338
339 def test_emcc(self):
340 SANITY_FAIL_MESSAGE = 'sanity check failed to run'

Callers

nothing calls this directly

Calls 13

doMethod · 0.95
check_workingMethod · 0.95
test_fileFunction · 0.90
ensure_dirFunction · 0.90
delete_fileFunction · 0.90
make_executableFunction · 0.90
restore_and_set_upFunction · 0.85
add_to_configFunction · 0.85
assertNotContainedMethod · 0.80
in_dirMethod · 0.80
write_fileMethod · 0.80
printFunction · 0.50

Tested by

no test coverage detected