Return early in do_fetch when there is no code or a package is external (#26926)
Co-authored-by: Ryan Krattiger <ryan.krattiger@kitware.com>
This commit is contained in:
parent
de8e795563
commit
cc8d8cc9cb
@ -76,10 +76,6 @@ def fetch(parser, args):
|
|||||||
if args.missing and package.installed:
|
if args.missing and package.installed:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Do not attempt to fetch externals (they're local)
|
|
||||||
if package.spec.external:
|
|
||||||
continue
|
|
||||||
|
|
||||||
package.do_fetch()
|
package.do_fetch()
|
||||||
|
|
||||||
package = spack.repo.get(spec)
|
package = spack.repo.get(spec)
|
||||||
|
@ -1333,9 +1333,9 @@ def do_fetch(self, mirror_only=False):
|
|||||||
Creates a stage directory and downloads the tarball for this package.
|
Creates a stage directory and downloads the tarball for this package.
|
||||||
Working directory will be set to the stage directory.
|
Working directory will be set to the stage directory.
|
||||||
"""
|
"""
|
||||||
if not self.has_code:
|
if not self.has_code or self.spec.external:
|
||||||
tty.debug('No fetch required for {0}: package has no code.'
|
tty.debug('No fetch required for {0}'.format(self.name))
|
||||||
.format(self.name))
|
return
|
||||||
|
|
||||||
checksum = spack.config.get('config:checksum')
|
checksum = spack.config.get('config:checksum')
|
||||||
fetch = self.stage.managed_by_spack
|
fetch = self.stage.managed_by_spack
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import spack.binary_distribution as bindist
|
import spack.binary_distribution as bindist
|
||||||
import spack.cmd.buildcache as buildcache
|
import spack.cmd.buildcache as buildcache
|
||||||
|
import spack.package
|
||||||
import spack.repo
|
import spack.repo
|
||||||
import spack.store
|
import spack.store
|
||||||
import spack.util.gpg
|
import spack.util.gpg
|
||||||
@ -598,3 +599,31 @@ def _instr(pkg):
|
|||||||
expected = pkg.download_instr if manual else 'All fetchers failed'
|
expected = pkg.download_instr if manual else 'All fetchers failed'
|
||||||
with pytest.raises(spack.fetch_strategy.FetchError, match=expected):
|
with pytest.raises(spack.fetch_strategy.FetchError, match=expected):
|
||||||
pkg.do_fetch()
|
pkg.do_fetch()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def fetching_not_allowed(monkeypatch):
|
||||||
|
class FetchingNotAllowed(spack.fetch_strategy.FetchStrategy):
|
||||||
|
def mirror_id(self):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def fetch(self):
|
||||||
|
raise Exception("Sources are fetched but shouldn't have been")
|
||||||
|
fetcher = FetchStrategyComposite()
|
||||||
|
fetcher.append(FetchingNotAllowed())
|
||||||
|
monkeypatch.setattr(spack.package.PackageBase, 'fetcher', fetcher)
|
||||||
|
|
||||||
|
|
||||||
|
def test_fetch_without_code_is_noop(install_mockery, fetching_not_allowed):
|
||||||
|
"""do_fetch for packages without code should be a no-op"""
|
||||||
|
pkg = Spec('a').concretized().package
|
||||||
|
pkg.has_code = False
|
||||||
|
pkg.do_fetch()
|
||||||
|
|
||||||
|
|
||||||
|
def test_fetch_external_package_is_noop(install_mockery, fetching_not_allowed):
|
||||||
|
"""do_fetch for packages without code should be a no-op"""
|
||||||
|
spec = Spec('a').concretized()
|
||||||
|
spec.external_path = "/some/where"
|
||||||
|
assert spec.external
|
||||||
|
spec.package.do_fetch()
|
||||||
|
Loading…
Reference in New Issue
Block a user