Add --full-path option to module find (#6838)
This commit is contained in:
		 Levi Baber
					Levi Baber
				
			
				
					committed by
					
						 Massimiliano Culpo
						Massimiliano Culpo
					
				
			
			
				
	
			
			
			 Massimiliano Culpo
						Massimiliano Culpo
					
				
			
						parent
						
							a102177db7
						
					
				
				
					commit
					8d2e340e16
				
			| @@ -71,6 +71,11 @@ def setup_parser(subparser): | |||||||
|  |  | ||||||
|     # spack module find |     # spack module find | ||||||
|     find_parser = sp.add_parser('find', help='find module files for packages') |     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']) |     arguments.add_common_arguments(find_parser, ['constraint', 'module_type']) | ||||||
|  |  | ||||||
|     # spack module rm |     # spack module rm | ||||||
| @@ -208,8 +213,11 @@ def find(module_types, specs, args): | |||||||
|         msg += 'no {0} module has been generated for it.' |         msg += 'no {0} module has been generated for it.' | ||||||
|         tty.die(msg.format(module_type, spec)) |         tty.die(msg.format(module_type, spec)) | ||||||
|  |  | ||||||
|     # ... and if it is print its use name |     # ... and if it is print its use name or full-path if requested | ||||||
|     print(writer.layout.use_name) |     if args.full_path: | ||||||
|  |         print(writer.layout.filename) | ||||||
|  |     else: | ||||||
|  |         print(writer.layout.use_name) | ||||||
|  |  | ||||||
|  |  | ||||||
| @subcommand('rm') | @subcommand('rm') | ||||||
|   | |||||||
| @@ -97,11 +97,15 @@ def test_remove_and_add_tcl(database, parser): | |||||||
|         assert os.path.exists(item) |         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.""" |     """Tests the 'spack module find' under a few common scenarios.""" | ||||||
|  |  | ||||||
|     # Try to find it for tcl module files |     # 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) |     module.module(parser, args) | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user