def test_environment(self):
    self.set_setting('ASSERTIONS', 1)

    def test():
        self.do_run_in_out_file_test('tests', 'core', 'test_hello_world', assert_returncode=None)
        js = open('src.c.o.js').read()
        assert (('require(' in js) == ('node' in self.get_setting('ENVIRONMENT'))), 'we should have require() calls only if node js specified'
    for engine in JS_ENGINES:
        print(engine)
        self.banned_js_engines = [e for e in JS_ENGINES if (e != engine)]
        if (engine == NODE_JS):
            right = 'node'
            wrong = 'shell'
        else:
            right = 'shell'
            wrong = 'node'
        self.set_setting('ENVIRONMENT', right)
        print('ENVIRONMENT =', self.get_setting('ENVIRONMENT'))
        test()
        self.set_setting('ENVIRONMENT', wrong)
        print('ENVIRONMENT =', self.get_setting('ENVIRONMENT'))
        try:
            test()
            raise Exception('unexpected success')
        except Exception as e:
            self.assertContained('not compiled for this environment', str(e))
        self.set_setting('ENVIRONMENT', ((right + ',') + wrong))
        print('ENVIRONMENT =', self.get_setting('ENVIRONMENT'))
        test()
def test_environment(self):
    self.set_setting('ASSERTIONS', 1)

    def test():
        self.do_run_in_out_file_test('tests', 'core', 'test_hello_world', assert_returncode=None)
        js = open('src.c.o.js').read()
        assert (('require(' in js) == ('node' in self.get_setting('ENVIRONMENT'))), 'we should have require() calls only if node js specified'
    for engine in JS_ENGINES:
        print(engine)
        self.banned_js_engines = [e for e in JS_ENGINES if (e != engine)]
        if (engine == NODE_JS):
            right = 'node'
            wrong = 'shell'
        else:
            right = 'shell'
            wrong = 'node'
        self.set_setting('ENVIRONMENT', right)
        print('ENVIRONMENT =', self.get_setting('ENVIRONMENT'))
        test()
        self.set_setting('ENVIRONMENT', wrong)
        print('ENVIRONMENT =', self.get_setting('ENVIRONMENT'))
        try:
            test()
            raise Exception('unexpected success')
        except Exception as e:
            self.assertContained('not compiled for this environment', str(e))
        self.set_setting('ENVIRONMENT', ((right + ',') + wrong))
        print('ENVIRONMENT =', self.get_setting('ENVIRONMENT'))
        test()