spack location: fix usage without args (#22755)

This commit is contained in:
Harmen Stoppels 2021-04-06 10:17:58 +02:00 committed by GitHub
parent 8c5f4c9c94
commit 0fcda35a71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -131,12 +131,11 @@ def location(parser, args):
print(pkg.stage.source_path) print(pkg.stage.source_path)
return return
# source and build dir remain, they require the spec to be staged # source dir remains, which requires the spec to be staged
if not pkg.stage.expanded: if not pkg.stage.expanded:
tty.die("Source directory does not exist yet. " tty.die("Source directory does not exist yet. "
"Run this to create it:", "Run this to create it:",
"spack stage " + " ".join(args.spec)) "spack stage " + " ".join(args.spec))
if args.source_dir: # Default to source dir.
print(pkg.stage.source_path) print(pkg.stage.source_path)
return

View file

@ -53,10 +53,12 @@ def test_location_build_dir(mock_spec):
assert location('--build-dir', spec.name).strip() == pkg.stage.source_path assert location('--build-dir', spec.name).strip() == pkg.stage.source_path
@pytest.mark.regression('22738')
def test_location_source_dir(mock_spec): def test_location_source_dir(mock_spec):
"""Tests spack location --source-dir.""" """Tests spack location --source-dir."""
spec, pkg = mock_spec spec, pkg = mock_spec
assert location('--source-dir', spec.name).strip() == pkg.stage.source_path assert location('--source-dir', spec.name).strip() == pkg.stage.source_path
assert location(spec.name).strip() == pkg.stage.source_path
def test_location_source_dir_missing(): def test_location_source_dir_missing():