def test_unhealthy_if_system_node_goes_missing(tmpdir): bin_dir = tmpdir.join('bin').ensure_dir() node_bin = bin_dir.join('node') node_bin.mksymlinkto(shutil.which('node')) prefix_dir = tmpdir.join('prefix').ensure_dir() prefix_dir.join('package.json').write('{"name": "t", "version": "1.0.0"}') path = ('PATH', (str(bin_dir), os.pathsep, envcontext.Var('PATH'))) with envcontext.envcontext((path, )): prefix = Prefix(str(prefix_dir)) node.install_environment(prefix, 'system', ()) assert node.healthy(prefix, 'system') node_bin.remove() assert not node.healthy(prefix, 'system')
def test_installs_without_links_outside_env(tmpdir): tmpdir.join('bin/main.js').ensure().write( '#!/usr/bin/env node\n' '_ = require("lodash"); console.log("success!")\n', ) tmpdir.join('package.json').write( json.dumps({ 'name': 'foo', 'version': '0.0.1', 'bin': {'foo': './bin/main.js'}, 'dependencies': {'lodash': '*'}, }), ) prefix = Prefix(str(tmpdir)) node.install_environment(prefix, 'system', ()) assert node.healthy(prefix, 'system') # this directory shouldn't exist, make sure we succeed without it existing cmd_output('rm', '-rf', str(tmpdir.join('node_modules'))) with node.in_env(prefix, 'system'): assert cmd_output('foo')[1] == 'success!\n'
def test_healthy_system_node(tmpdir): tmpdir.join('package.json').write('{"name": "t", "version": "1.0.0"}') prefix = Prefix(str(tmpdir)) node.install_environment(prefix, 'system', ()) assert node.healthy(prefix, 'system')