diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2018-07-24 23:57:22 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2018-08-03 15:18:34 -0500 |
commit | b5071312c4a92015026aa2f1eb77a2478884a27d (patch) | |
tree | 3bb3d8a3dbed9f80204bf2b59447f78321047368 /lib | |
parent | c73d237d087792a00b6c0aceaf56674e398ea8e0 (diff) | |
download | spack-b5071312c4a92015026aa2f1eb77a2478884a27d.tar.gz spack-b5071312c4a92015026aa2f1eb77a2478884a27d.tar.bz2 spack-b5071312c4a92015026aa2f1eb77a2478884a27d.tar.xz spack-b5071312c4a92015026aa2f1eb77a2478884a27d.zip |
spack spec: no extra newline with --yaml; error with no specs
- `spack spec` now returns an error if given no specs
- removed superfluous trailing newline from `spack spec --yaml` output
(only one newline now)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/spec.py | 11 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/spec.py | 6 |
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/spack/spack/cmd/spec.py b/lib/spack/spack/cmd/spec.py index fec5772776..bac8dd4727 100644 --- a/lib/spack/spack/cmd/spec.py +++ b/lib/spack/spack/cmd/spec.py @@ -25,7 +25,11 @@ from __future__ import print_function import argparse +import sys +import llnl.util.tty as tty + +import spack import spack.cmd import spack.cmd.common.arguments as arguments @@ -66,12 +70,17 @@ def spec(parser, args): 'show_types': args.types, 'install_status': args.install_status} + if not args.specs: + tty.die("spack spec requires at least one spec") + for spec in spack.cmd.parse_specs(args.specs): # With -y, just print YAML to output. if args.yaml: if spec.name in spack.repo.path or spec.virtual: spec.concretize() - print(spec.to_yaml()) + + # use write because to_yaml already has a newline. + sys.stdout.write(spec.to_yaml()) continue kwargs['hashes'] = False # Always False for input spec diff --git a/lib/spack/spack/test/cmd/spec.py b/lib/spack/spack/test/cmd/spec.py index 75d91bcddf..2c7404d28f 100644 --- a/lib/spack/spack/test/cmd/spec.py +++ b/lib/spack/spack/test/cmd/spec.py @@ -88,3 +88,9 @@ def test_spec_deptypes_edges(): assert types['dt-diamond-left'] == ['bl '] assert types['dt-diamond-right'] == ['bl '] assert types['dt-diamond-bottom'] == ['b ', 'blr '] + + +def test_spec_returncode(): + with pytest.raises(spack.main.SpackCommandError): + spec() + assert spec.returncode == 1 |