@@ -7282,21 +7282,33 @@ def test_override_js_execution_environment(self):
72827282 seen = self.run_js('test.js', engine=engine, assert_returncode=NON_ZERO)
72837283 self.assertContained('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node', seen)
72847284
7285+ @requires_node
7286+ @with_env_modify({'FOO': 'bar'})
7287+ def test_node_environ(self):
7288+ create_file('src.c', r'''
7289+ #include <stdlib.h>
7290+ #include <stdio.h>
7291+ int main() {
7292+ printf("|%s|\n", getenv("FOO"));
7293+ }
7294+ ''')
7295+ self.do_runf('src.c', '|bar|')
7296+
72857297 def test_override_c_environ(self):
72867298 create_file('pre.js', r'''
72877299 var Module = {
72887300 preRun: [function() { ENV.hello = 'world'; ENV.LANG = undefined; }]
72897301 };
72907302 ''')
7291- create_file('src.cpp ', r'''
7303+ create_file('src.c ', r'''
72927304 #include <stdlib.h>
72937305 #include <stdio.h>
72947306 int main() {
72957307 printf("|%s|\n", getenv("hello"));
72967308 printf("LANG is %s\n", getenv("LANG") ? "set" : "not set");
72977309 }
72987310 ''')
7299- self.run_process([EMXX , 'src.cpp ', '--pre-js', 'pre.js'])
7311+ self.run_process([EMCC , 'src.c ', '--pre-js', 'pre.js'])
73007312 output = self.run_js('a.out.js')
73017313 self.assertContained('|world|', output)
73027314 self.assertContained('LANG is not set', output)
@@ -7306,10 +7318,10 @@ def test_override_c_environ(self):
73067318 preRun: [function(module) { module.ENV.hello = 'world' }]
73077319 };
73087320 ''')
7309- self.run_process([EMXX , 'src.cpp ', '--pre-js', 'pre.js', '-sEXPORTED_RUNTIME_METHODS=ENV'])
7321+ self.run_process([EMCC , 'src.c ', '--pre-js', 'pre.js', '-sEXPORTED_RUNTIME_METHODS=ENV'])
73107322 self.assertContained('|world|', self.run_js('a.out.js'))
73117323
7312- self.run_process([EMXX , 'src.cpp ', '--pre-js', 'pre.js', '-sEXPORTED_RUNTIME_METHODS=ENV', '-sMODULARIZE'])
7324+ self.run_process([EMCC , 'src.c ', '--pre-js', 'pre.js', '-sEXPORTED_RUNTIME_METHODS=ENV', '-sMODULARIZE'])
73137325 output = self.run_process(config.NODE_JS + ['-e', 'require("./a.out.js")();'], stdout=PIPE, stderr=PIPE)
73147326 self.assertContained('|world|', output.stdout)
73157327
0 commit comments