def test_find_external_merge(mutable_config, mutable_mock_repo): """Check that 'spack find external' doesn't overwrite an existing spec entry in packages.yaml. """ pkgs_cfg_init = { 'find-externals1': { 'externals': [{ 'spec': '[email protected]', 'prefix': '/preexisting-prefix/' }], 'buildable': False } } mutable_config.update_config('packages', pkgs_cfg_init) entries = [ ExternalPackageEntry( Spec.from_detection('[email protected]'), '/x/y1/' ), ExternalPackageEntry( Spec.from_detection('[email protected]'), '/x/y2/' ) ] pkg_to_entries = {'find-externals1': entries} spack.cmd.external._update_pkg_config(pkg_to_entries, False) pkgs_cfg = spack.config.get('packages') pkg_cfg = pkgs_cfg['find-externals1'] pkg_externals = pkg_cfg['externals'] assert {'spec': '[email protected]', 'prefix': '/preexisting-prefix/'} in pkg_externals assert {'spec': '[email protected]', 'prefix': '/x/y2/'} in pkg_externals
def test_find_external_merge(mutable_config, mutable_mock_repo): """Check that 'spack find external' doesn't overwrite an existing spec entry in packages.yaml. """ pkgs_cfg_init = { 'find-externals1': { 'externals': [{ 'spec': '[email protected]', 'prefix': '/preexisting-prefix/' }], 'buildable': False } } mutable_config.update_config('packages', pkgs_cfg_init) entries = [ spack.detection.DetectedPackage( Spec.from_detection('[email protected]'), '/x/y1/' ), spack.detection.DetectedPackage( Spec.from_detection('[email protected]'), '/x/y2/' ) ] pkg_to_entries = {'find-externals1': entries} scope = spack.config.default_modify_scope('packages') spack.detection.update_configuration(pkg_to_entries, scope=scope, buildable=True) pkgs_cfg = spack.config.get('packages') pkg_cfg = pkgs_cfg['find-externals1'] pkg_externals = pkg_cfg['externals'] assert {'spec': '[email protected]', 'prefix': '/preexisting-prefix/'} in pkg_externals assert {'spec': '[email protected]', 'prefix': '/x/y2/'} in pkg_externals
def test_find_external_update_config(mutable_config): entries = [ ExternalPackageEntry(Spec.from_detection('*****@*****.**'), '/x/y1/'), ExternalPackageEntry(Spec.from_detection('[email protected]'), '/x/y2/'), ] pkg_to_entries = {'cmake': entries} spack.cmd.external._update_pkg_config(pkg_to_entries, False) pkgs_cfg = spack.config.get('packages') cmake_cfg = pkgs_cfg['cmake'] cmake_externals = cmake_cfg['externals'] assert {'spec': '*****@*****.**', 'prefix': '/x/y1/'} in cmake_externals assert {'spec': '[email protected]', 'prefix': '/x/y2/'} in cmake_externals
def test_find_external_update_config(mutable_config): entries = [ spack.detection.DetectedPackage(Spec.from_detection('*****@*****.**'), '/x/y1/'), spack.detection.DetectedPackage(Spec.from_detection('[email protected]'), '/x/y2/'), ] pkg_to_entries = {'cmake': entries} scope = spack.config.default_modify_scope('packages') spack.detection.update_configuration(pkg_to_entries, scope=scope, buildable=True) pkgs_cfg = spack.config.get('packages') cmake_cfg = pkgs_cfg['cmake'] cmake_externals = cmake_cfg['externals'] assert {'spec': '*****@*****.**', 'prefix': '/x/y1/'} in cmake_externals assert {'spec': '[email protected]', 'prefix': '/x/y2/'} in cmake_externals
def create_external_detected_spec(env, spec): view = _get_first_view_containing_spec(env, spec) pruned_spec = _well_posed_spec_string_minus_dev_path(spec) prefix = view.get_projection_for_spec(spec) return spack.detection.DetectedPackage(Spec.from_detection(pruned_spec), prefix)