From 9d7cc436732eaa21679480219a5c7ed96450eea0 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Mon, 6 Jun 2022 17:33:03 -0500 Subject: Package: Don't warn for missing source on bundle packages without code (#30913) --- lib/spack/spack/package_base.py | 2 +- lib/spack/spack/test/install.py | 18 ++++++++++++++++++ .../builtin.mock/packages/nosource-bundle/package.py | 17 +++++++++++++++++ .../repos/builtin.mock/packages/nosource/package.py | 4 ++-- 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 var/spack/repos/builtin.mock/packages/nosource-bundle/package.py diff --git a/lib/spack/spack/package_base.py b/lib/spack/spack/package_base.py index 1c736fb326..f88d907974 100644 --- a/lib/spack/spack/package_base.py +++ b/lib/spack/spack/package_base.py @@ -1721,7 +1721,7 @@ class PackageBase(six.with_metaclass(PackageMeta, PackageViewMixin, object)): # referenced by branch name rather than tag or commit ID. env = spack.environment.active_environment() from_local_sources = env and env.is_develop(self.spec) - if not self.spec.external and not from_local_sources: + if self.has_code and not self.spec.external and not from_local_sources: message = 'Missing a source id for {s.name}@{s.version}' tty.warn(message.format(s=self)) hash_content.append(''.encode('utf-8')) diff --git a/lib/spack/spack/test/install.py b/lib/spack/spack/test/install.py index 42c68fd6bd..845bdd92b2 100644 --- a/lib/spack/spack/test/install.py +++ b/lib/spack/spack/test/install.py @@ -414,9 +414,27 @@ def test_nosource_pkg_install( pkg.do_install() out = capfd.readouterr() assert "Installing dependency-install" in out[0] + + # Make sure a warning for missing code is issued assert "Missing a source id for nosource" in out[1] +@pytest.mark.disable_clean_stage_check +def test_nosource_bundle_pkg_install( + install_mockery, mock_fetch, mock_packages, capfd): + """Test install phases with the nosource-bundle package.""" + spec = Spec('nosource-bundle').concretized() + pkg = spec.package + + # Make sure install works even though there is no associated code. + pkg.do_install() + out = capfd.readouterr() + assert "Installing dependency-install" in out[0] + + # Make sure a warning for missing code is *not* issued + assert "Missing a source id for nosource" not in out[1] + + def test_nosource_pkg_install_post_install( install_mockery, mock_fetch, mock_packages): """Test install phases with the nosource package with post-install.""" diff --git a/var/spack/repos/builtin.mock/packages/nosource-bundle/package.py b/var/spack/repos/builtin.mock/packages/nosource-bundle/package.py new file mode 100644 index 0000000000..801900b0be --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/nosource-bundle/package.py @@ -0,0 +1,17 @@ +# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + + +from spack.package import * + + +class NosourceBundle(BundlePackage): + """Simple bundle package with one dependency""" + + homepage = "http://www.example.com" + + version('1.0') + + depends_on('dependency-install') diff --git a/var/spack/repos/builtin.mock/packages/nosource/package.py b/var/spack/repos/builtin.mock/packages/nosource/package.py index 29bb2d635b..5d08ffa3a1 100644 --- a/var/spack/repos/builtin.mock/packages/nosource/package.py +++ b/var/spack/repos/builtin.mock/packages/nosource/package.py @@ -7,8 +7,8 @@ from spack.package import * -class Nosource(BundlePackage): - """Simple bundle package with one dependency""" +class Nosource(Package): + """Simple package with no source and one dependency""" homepage = "http://www.example.com" -- cgit v1.2.3-70-g09d2