summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLevi Baber <baberlevi@gmail.com>2018-01-19 13:08:36 -0600
committerMassimiliano Culpo <massimiliano.culpo@gmail.com>2018-01-19 20:08:36 +0100
commit8d2e340e16713658b5fdf7b5184fa3c10b79881b (patch)
treed029757f64b4871fdcbd7990311b508bd7197e5d /lib
parenta102177db7f69974e61e9eaf3a5619c7c3960590 (diff)
downloadspack-8d2e340e16713658b5fdf7b5184fa3c10b79881b.tar.gz
spack-8d2e340e16713658b5fdf7b5184fa3c10b79881b.tar.bz2
spack-8d2e340e16713658b5fdf7b5184fa3c10b79881b.tar.xz
spack-8d2e340e16713658b5fdf7b5184fa3c10b79881b.zip
Add --full-path option to module find (#6838)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/module.py12
-rw-r--r--lib/spack/spack/test/cmd/module.py8
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/spack/spack/cmd/module.py b/lib/spack/spack/cmd/module.py
index 1ebead1f58..b097da972e 100644
--- a/lib/spack/spack/cmd/module.py
+++ b/lib/spack/spack/cmd/module.py
@@ -71,6 +71,11 @@ def setup_parser(subparser):
# spack module find
find_parser = sp.add_parser('find', help='find module files for packages')
+ find_parser.add_argument(
+ '--full-path',
+ help='display full path to module file',
+ action='store_true'
+ )
arguments.add_common_arguments(find_parser, ['constraint', 'module_type'])
# spack module rm
@@ -208,8 +213,11 @@ def find(module_types, specs, args):
msg += 'no {0} module has been generated for it.'
tty.die(msg.format(module_type, spec))
- # ... and if it is print its use name
- print(writer.layout.use_name)
+ # ... and if it is print its use name or full-path if requested
+ if args.full_path:
+ print(writer.layout.filename)
+ else:
+ print(writer.layout.use_name)
@subcommand('rm')
diff --git a/lib/spack/spack/test/cmd/module.py b/lib/spack/spack/test/cmd/module.py
index 0aa08b9aa6..f56083df6e 100644
--- a/lib/spack/spack/test/cmd/module.py
+++ b/lib/spack/spack/test/cmd/module.py
@@ -97,11 +97,15 @@ def test_remove_and_add_tcl(database, parser):
assert os.path.exists(item)
-def test_find(database, parser):
+@pytest.mark.parametrize('cli_args', [
+ ['--module-type', 'tcl', 'libelf'],
+ ['--module-type', 'tcl', '--full-path', 'libelf']
+])
+def test_find(database, parser, cli_args):
"""Tests the 'spack module find' under a few common scenarios."""
# Try to find it for tcl module files
- args = parser.parse_args(['find', '--module-type', 'tcl', 'libelf'])
+ args = parser.parse_args(['find'] + cli_args)
module.module(parser, args)