| 
									
										
										
										
											2013-06-02 13:54:46 -07:00
										 |  |  | #!/usr/bin/env python | 
					
						
							| 
									
										
										
										
											2016-08-09 13:23:53 -07:00
										 |  |  | # flake8: noqa | 
					
						
							| 
									
										
										
										
											2014-01-08 10:21:02 +01:00
										 |  |  | ############################################################################## | 
					
						
							| 
									
										
										
										
											2016-05-11 21:22:25 -07:00
										 |  |  | # Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC. | 
					
						
							| 
									
										
										
										
											2014-01-08 10:21:02 +01:00
										 |  |  | # Produced at the Lawrence Livermore National Laboratory. | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # This file is part of Spack. | 
					
						
							| 
									
										
										
										
											2016-05-11 21:22:25 -07:00
										 |  |  | # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. | 
					
						
							| 
									
										
										
										
											2014-01-08 10:21:02 +01:00
										 |  |  | # LLNL-CODE-647188 | 
					
						
							|  |  |  | # | 
					
						
							| 
									
										
										
										
											2015-12-09 01:24:15 -08:00
										 |  |  | # For details, see https://github.com/llnl/spack | 
					
						
							| 
									
										
										
										
											2014-01-08 10:21:02 +01:00
										 |  |  | # Please also see the LICENSE file for our notice and the LGPL. | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # This program is free software; you can redistribute it and/or modify | 
					
						
							| 
									
										
										
										
											2016-05-11 21:22:25 -07:00
										 |  |  | # it under the terms of the GNU Lesser General Public License (as | 
					
						
							|  |  |  | # published by the Free Software Foundation) version 2.1, February 1999. | 
					
						
							| 
									
										
										
										
											2014-01-08 10:21:02 +01:00
										 |  |  | # | 
					
						
							|  |  |  | # This program is distributed in the hope that it will be useful, but | 
					
						
							|  |  |  | # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF | 
					
						
							|  |  |  | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and | 
					
						
							| 
									
										
										
										
											2016-05-11 21:22:25 -07:00
										 |  |  | # conditions of the GNU Lesser General Public License for more details. | 
					
						
							| 
									
										
										
										
											2014-01-08 10:21:02 +01:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2016-05-11 21:22:25 -07:00
										 |  |  | # You should have received a copy of the GNU Lesser General Public | 
					
						
							|  |  |  | # License along with this program; if not, write to the Free Software | 
					
						
							|  |  |  | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 
					
						
							| 
									
										
										
										
											2014-01-08 10:21:02 +01:00
										 |  |  | ############################################################################## | 
					
						
							| 
									
										
										
										
											2017-03-07 14:25:48 -08:00
										 |  |  | from __future__ import print_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-02 13:54:46 -07:00
										 |  |  | import sys | 
					
						
							| 
									
										
										
										
											2017-03-07 09:31:15 -08:00
										 |  |  | if sys.version_info[:2] < (2, 6): | 
					
						
							| 
									
										
										
										
											2014-12-19 11:09:37 -08:00
										 |  |  |     v_info = sys.version_info[:3] | 
					
						
							| 
									
										
										
										
											2017-03-07 09:31:15 -08:00
										 |  |  |     sys.exit("Spack requires Python 2.6 or higher." | 
					
						
							| 
									
										
										
										
											2016-08-09 13:23:53 -07:00
										 |  |  |              "This is Python %d.%d.%d." % v_info) | 
					
						
							| 
									
										
										
										
											2013-02-13 17:50:44 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | import os | 
					
						
							| 
									
										
											  
											
												unit tests: replace nose with pytest  (#2502)
* Porting: substitute nose with ytest
This huge commit substitutes nose with pytest as a testing system. Things done here:
* deleted external/nose as it is no longer used
* moved mock resources in their own directory 'test/mock/'
* ported two tests (cmd/find, build_system) to pytest native syntax as an example
* build_environment, log: used monkeypatch instead of try/catch
* moved global mocking of fetch_cache to an auto-used fixture
* moved global mocking from test/__init__.py to conftest.py
* made `spack test` a wrapper around pytest
* run-unit-tests: avoid running python 2.6 tests under coverage to speed them up
* use `pytest --cov` instead of coverage run to cut down testing time
* mock/packages_test: moved mock yaml configuration to files instead of leaving it in the code as string literals
* concretize.py: ported tests to native pytest, reverted multiprocessing in pytest.ini as it was creating the wrong report for coveralls
* conftest.py, fixtures: added docstrings
* concretize_preferences.py: uses fixtures instead of subclassing MockPackagesTest
* directory_layout.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: uses fixtures instead of subclassing MockPackagesTest
* optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
* packages.py: uses fixtures instead of subclassing MockPackagesTest
* provider_index.py: uses fixtures instead of subclassing MockPackagesTest
* spec_yaml.py: uses fixtures instead of subclassing MockPackagesTest
* multimethod.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: now uses mock_archive_url
* git_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* hg_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* svn_fetch.py, mirror.py: uses fixtures instead of subclassing MockPackagesTest
repo.py: deleted
* test_compiler_cmd.py: uses fixtures instead of subclassing MockPackagesTest
* cmd/module.py, cmd/uninstall.py: uses fixtures instead of subclassing MockDatabase
* database.py: uses fixtures instead of subclassing MockDatabase, removed mock/database
* pytest: uncluttering fixture implementations
* database: changing the scope to 'module'
* config.py: uses fixtures instead of subclassing MockPackagesTest
* spec_dag.py, spec_semantics.py: uses fixtures instead of subclassing MockPackagesTest
* stage.py: uses fixtures instead of subclassing MockPackagesTest. Removed mock directory
* pytest: added docstrings to all the fixtures
* pytest: final cleanup
* build_system_guess.py: fixed naming and docstrings as suggested by @scheibelp
* spec_syntax.py: added expected failure on parsing multiple specs closes #1976
* Add pytest and pytest-cov to Spack externals.
* Make `spack flake8` ignore externals.
* run-unit-tests runs spack test and not pytest.
* Remove all the special stuff for `spack test`
- Remove `conftest.py` magic and all the special case stuff in `bin/spack`
- Spack commands can optionally take unknown arguments, if they want to
  handle them.
- `spack test` is now a command like the others.
- `spack test` now just delegates its arguments to `pytest`, but it does
  it by receiving unknown arguments and NOT taking an explicit
  help argument.
* Fix error in fixtures.
* Improve `spack test` command a bit.
- Now supports an approximation of the old simple interface
- Also supports full pytest options if you want them.
* Use external coverage instead of pytest-cov
* Make coverage use parallel-mode.
* change __init__.py docs to include pytest
											
										 
											2016-12-29 16:48:48 +01:00
										 |  |  | import inspect | 
					
						
							| 
									
										
										
										
											2013-02-13 17:50:44 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Find spack's location and its prefix. | 
					
						
							| 
									
										
										
										
											2013-05-15 16:47:50 -07:00
										 |  |  | SPACK_FILE = os.path.realpath(os.path.expanduser(__file__)) | 
					
						
							|  |  |  | os.environ["SPACK_FILE"] = SPACK_FILE | 
					
						
							| 
									
										
										
										
											2013-02-13 17:50:44 -08:00
										 |  |  | SPACK_PREFIX = os.path.dirname(os.path.dirname(SPACK_FILE)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Allow spack libs to be imported in our scripts | 
					
						
							|  |  |  | SPACK_LIB_PATH = os.path.join(SPACK_PREFIX, "lib", "spack") | 
					
						
							|  |  |  | sys.path.insert(0, SPACK_LIB_PATH) | 
					
						
							| 
									
										
										
										
											2016-10-12 18:25:18 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Add external libs | 
					
						
							| 
									
										
										
										
											2015-11-11 18:04:22 -08:00
										 |  |  | SPACK_EXTERNAL_LIBS = os.path.join(SPACK_LIB_PATH, "external") | 
					
						
							|  |  |  | sys.path.insert(0, SPACK_EXTERNAL_LIBS) | 
					
						
							| 
									
										
										
										
											2013-02-13 17:50:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-07 09:32:43 -08:00
										 |  |  | # Handle vendoring of YAML specially, as it has two versions. | 
					
						
							|  |  |  | if sys.version_info[0] == 2: | 
					
						
							|  |  |  |     SPACK_YAML_LIBS = os.path.join(SPACK_EXTERNAL_LIBS, "yaml/lib") | 
					
						
							|  |  |  | else: | 
					
						
							|  |  |  |     SPACK_YAML_LIBS = os.path.join(SPACK_EXTERNAL_LIBS, "yaml/lib3") | 
					
						
							|  |  |  | sys.path.insert(0, SPACK_YAML_LIBS) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-23 17:39:59 -08:00
										 |  |  | # Quick and dirty check to clean orphaned .pyc files left over from | 
					
						
							|  |  |  | # previous revisions.  These files were present in earlier versions of | 
					
						
							|  |  |  | # Spack, were removed, but shadow system modules that Spack still | 
					
						
							|  |  |  | # imports.  If we leave them, Spack will fail in mysterious ways. | 
					
						
							|  |  |  | # TODO: more elegant solution for orphaned pyc files. | 
					
						
							| 
									
										
										
										
											2016-08-30 10:47:38 -05:00
										 |  |  | orphaned_pyc_files = [ | 
					
						
							|  |  |  |     os.path.join(SPACK_EXTERNAL_LIBS, 'functools.pyc'), | 
					
						
							|  |  |  |     os.path.join(SPACK_EXTERNAL_LIBS, 'ordereddict.pyc'), | 
					
						
							|  |  |  |     os.path.join(SPACK_LIB_PATH, 'spack', 'platforms', 'cray_xc.pyc'), | 
					
						
							|  |  |  |     os.path.join(SPACK_LIB_PATH, 'spack', 'cmd', 'package-list.pyc'), | 
					
						
							|  |  |  |     os.path.join(SPACK_LIB_PATH, 'spack', 'cmd', 'test-install.pyc'), | 
					
						
							| 
									
										
										
										
											2016-10-30 18:29:44 -07:00
										 |  |  |     os.path.join(SPACK_LIB_PATH, 'spack', 'cmd', 'url-parse.pyc'), | 
					
						
							|  |  |  |     os.path.join(SPACK_LIB_PATH, 'spack', 'test', 'yaml.pyc') | 
					
						
							| 
									
										
										
										
											2016-08-30 10:47:38 -05:00
										 |  |  | ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-23 17:39:59 -08:00
										 |  |  | for pyc_file in orphaned_pyc_files: | 
					
						
							|  |  |  |     if not os.path.exists(pyc_file): | 
					
						
							|  |  |  |         continue | 
					
						
							|  |  |  |     try: | 
					
						
							|  |  |  |         os.remove(pyc_file) | 
					
						
							|  |  |  |     except OSError as e: | 
					
						
							| 
									
										
										
										
											2017-03-07 14:25:48 -08:00
										 |  |  |         print("WARNING: Spack may fail mysteriously. " | 
					
						
							|  |  |  |               "Couldn't remove orphaned .pyc file: %s" % pyc_file) | 
					
						
							| 
									
										
										
										
											2015-11-23 17:39:59 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-16 16:03:49 -07:00
										 |  |  | # If there is no working directory, use the spack prefix. | 
					
						
							|  |  |  | try: | 
					
						
							| 
									
										
										
										
											2014-05-19 16:07:42 -07:00
										 |  |  |     working_dir = os.getcwd() | 
					
						
							| 
									
										
										
										
											2014-03-16 16:03:49 -07:00
										 |  |  | except OSError: | 
					
						
							|  |  |  |     os.chdir(SPACK_PREFIX) | 
					
						
							| 
									
										
										
										
											2014-07-02 23:22:38 -07:00
										 |  |  |     working_dir = SPACK_PREFIX | 
					
						
							| 
									
										
										
										
											2014-03-16 16:03:49 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-13 17:50:44 -08:00
										 |  |  | # clean up the scope and start using spack package instead. | 
					
						
							|  |  |  | del SPACK_FILE, SPACK_PREFIX, SPACK_LIB_PATH | 
					
						
							| 
									
										
										
										
											2014-03-12 22:24:47 -04:00
										 |  |  | import llnl.util.tty as tty | 
					
						
							| 
									
										
										
										
											2015-05-17 22:29:08 -07:00
										 |  |  | from llnl.util.tty.color import * | 
					
						
							| 
									
										
										
										
											2013-02-13 17:50:44 -08:00
										 |  |  | import spack | 
					
						
							| 
									
										
										
										
											2013-10-07 17:57:27 -07:00
										 |  |  | from spack.error import SpackError | 
					
						
							| 
									
										
										
										
											2016-06-08 14:22:26 -06:00
										 |  |  | import argparse | 
					
						
							| 
									
										
										
										
											2013-02-13 17:50:44 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Command parsing | 
					
						
							|  |  |  | parser = argparse.ArgumentParser( | 
					
						
							| 
									
										
										
										
											2015-05-17 22:29:08 -07:00
										 |  |  |     formatter_class=argparse.RawTextHelpFormatter, | 
					
						
							|  |  |  |     description="Spack: the Supercomputing PACKage Manager." + colorize(""" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | spec expressions: | 
					
						
							|  |  |  |   PACKAGE [CONSTRAINTS] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     CONSTRAINTS: | 
					
						
							|  |  |  |       @c{@version} | 
					
						
							|  |  |  |       @g{%compiler  @compiler_version} | 
					
						
							|  |  |  |       @B{+variant} | 
					
						
							|  |  |  |       @r{-variant} or @r{~variant} | 
					
						
							|  |  |  |       @m{=architecture} | 
					
						
							|  |  |  |       [^DEPENDENCY [CONSTRAINTS] ...]""")) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  | parser.add_argument('-d', '--debug', action='store_true', | 
					
						
							| 
									
										
										
										
											2017-01-26 04:33:01 -06:00
										 |  |  |                     help="write out debug logs during compile") | 
					
						
							| 
									
										
										
										
											2015-12-16 15:54:15 -08:00
										 |  |  | parser.add_argument('-D', '--pdb', action='store_true', | 
					
						
							| 
									
										
										
										
											2017-01-26 04:33:01 -06:00
										 |  |  |                     help="run spack under the pdb debugger") | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  | parser.add_argument('-k', '--insecure', action='store_true', | 
					
						
							| 
									
										
										
										
											2017-01-26 04:33:01 -06:00
										 |  |  |                     help="do not check ssl certificates when downloading") | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  | parser.add_argument('-m', '--mock', action='store_true', | 
					
						
							| 
									
										
										
										
											2017-01-26 04:33:01 -06:00
										 |  |  |                     help="use mock packages instead of real ones") | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  | parser.add_argument('-p', '--profile', action='store_true', | 
					
						
							| 
									
										
										
										
											2017-01-26 04:33:01 -06:00
										 |  |  |                     help="profile execution using cProfile") | 
					
						
							| 
									
										
										
										
											2015-04-07 10:29:07 -07:00
										 |  |  | parser.add_argument('-v', '--verbose', action='store_true', | 
					
						
							| 
									
										
										
										
											2017-01-26 04:33:01 -06:00
										 |  |  |                     help="print additional output during builds") | 
					
						
							| 
									
										
										
										
											2016-11-15 15:17:03 -05:00
										 |  |  | parser.add_argument('-s', '--stacktrace', action='store_true', | 
					
						
							| 
									
										
										
										
											2017-01-26 04:33:01 -06:00
										 |  |  |                     help="add stacktrace information to all printed statements") | 
					
						
							| 
									
										
										
										
											2015-04-07 10:29:07 -07:00
										 |  |  | parser.add_argument('-V', '--version', action='version', | 
					
						
							|  |  |  |                     version="%s" % spack.spack_version) | 
					
						
							| 
									
										
										
										
											2013-02-13 17:50:44 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # each command module implements a parser() function, to which we pass its | 
					
						
							|  |  |  | # subparser for setup. | 
					
						
							| 
									
										
										
										
											2013-12-12 04:25:31 -08:00
										 |  |  | subparsers = parser.add_subparsers(metavar='SUBCOMMAND', dest="command") | 
					
						
							| 
									
										
										
										
											2013-02-13 17:50:44 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												unit tests: replace nose with pytest  (#2502)
* Porting: substitute nose with ytest
This huge commit substitutes nose with pytest as a testing system. Things done here:
* deleted external/nose as it is no longer used
* moved mock resources in their own directory 'test/mock/'
* ported two tests (cmd/find, build_system) to pytest native syntax as an example
* build_environment, log: used monkeypatch instead of try/catch
* moved global mocking of fetch_cache to an auto-used fixture
* moved global mocking from test/__init__.py to conftest.py
* made `spack test` a wrapper around pytest
* run-unit-tests: avoid running python 2.6 tests under coverage to speed them up
* use `pytest --cov` instead of coverage run to cut down testing time
* mock/packages_test: moved mock yaml configuration to files instead of leaving it in the code as string literals
* concretize.py: ported tests to native pytest, reverted multiprocessing in pytest.ini as it was creating the wrong report for coveralls
* conftest.py, fixtures: added docstrings
* concretize_preferences.py: uses fixtures instead of subclassing MockPackagesTest
* directory_layout.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: uses fixtures instead of subclassing MockPackagesTest
* optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
* packages.py: uses fixtures instead of subclassing MockPackagesTest
* provider_index.py: uses fixtures instead of subclassing MockPackagesTest
* spec_yaml.py: uses fixtures instead of subclassing MockPackagesTest
* multimethod.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: now uses mock_archive_url
* git_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* hg_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* svn_fetch.py, mirror.py: uses fixtures instead of subclassing MockPackagesTest
repo.py: deleted
* test_compiler_cmd.py: uses fixtures instead of subclassing MockPackagesTest
* cmd/module.py, cmd/uninstall.py: uses fixtures instead of subclassing MockDatabase
* database.py: uses fixtures instead of subclassing MockDatabase, removed mock/database
* pytest: uncluttering fixture implementations
* database: changing the scope to 'module'
* config.py: uses fixtures instead of subclassing MockPackagesTest
* spec_dag.py, spec_semantics.py: uses fixtures instead of subclassing MockPackagesTest
* stage.py: uses fixtures instead of subclassing MockPackagesTest. Removed mock directory
* pytest: added docstrings to all the fixtures
* pytest: final cleanup
* build_system_guess.py: fixed naming and docstrings as suggested by @scheibelp
* spec_syntax.py: added expected failure on parsing multiple specs closes #1976
* Add pytest and pytest-cov to Spack externals.
* Make `spack flake8` ignore externals.
* run-unit-tests runs spack test and not pytest.
* Remove all the special stuff for `spack test`
- Remove `conftest.py` magic and all the special case stuff in `bin/spack`
- Spack commands can optionally take unknown arguments, if they want to
  handle them.
- `spack test` is now a command like the others.
- `spack test` now just delegates its arguments to `pytest`, but it does
  it by receiving unknown arguments and NOT taking an explicit
  help argument.
* Fix error in fixtures.
* Improve `spack test` command a bit.
- Now supports an approximation of the old simple interface
- Also supports full pytest options if you want them.
* Use external coverage instead of pytest-cov
* Make coverage use parallel-mode.
* change __init__.py docs to include pytest
											
										 
											2016-12-29 16:48:48 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-13 17:50:44 -08:00
										 |  |  | import spack.cmd | 
					
						
							|  |  |  | for cmd in spack.cmd.commands: | 
					
						
							|  |  |  |     module = spack.cmd.get_module(cmd) | 
					
						
							| 
									
										
										
										
											2016-08-30 12:05:14 -05:00
										 |  |  |     cmd_name = cmd.replace('_', '-') | 
					
						
							|  |  |  |     subparser = subparsers.add_parser(cmd_name, help=module.description) | 
					
						
							| 
									
										
										
										
											2013-02-13 17:50:44 -08:00
										 |  |  |     module.setup_parser(subparser) | 
					
						
							| 
									
										
										
										
											2014-08-16 14:53:57 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-09 13:23:53 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												unit tests: replace nose with pytest  (#2502)
* Porting: substitute nose with ytest
This huge commit substitutes nose with pytest as a testing system. Things done here:
* deleted external/nose as it is no longer used
* moved mock resources in their own directory 'test/mock/'
* ported two tests (cmd/find, build_system) to pytest native syntax as an example
* build_environment, log: used monkeypatch instead of try/catch
* moved global mocking of fetch_cache to an auto-used fixture
* moved global mocking from test/__init__.py to conftest.py
* made `spack test` a wrapper around pytest
* run-unit-tests: avoid running python 2.6 tests under coverage to speed them up
* use `pytest --cov` instead of coverage run to cut down testing time
* mock/packages_test: moved mock yaml configuration to files instead of leaving it in the code as string literals
* concretize.py: ported tests to native pytest, reverted multiprocessing in pytest.ini as it was creating the wrong report for coveralls
* conftest.py, fixtures: added docstrings
* concretize_preferences.py: uses fixtures instead of subclassing MockPackagesTest
* directory_layout.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: uses fixtures instead of subclassing MockPackagesTest
* optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
* packages.py: uses fixtures instead of subclassing MockPackagesTest
* provider_index.py: uses fixtures instead of subclassing MockPackagesTest
* spec_yaml.py: uses fixtures instead of subclassing MockPackagesTest
* multimethod.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: now uses mock_archive_url
* git_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* hg_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* svn_fetch.py, mirror.py: uses fixtures instead of subclassing MockPackagesTest
repo.py: deleted
* test_compiler_cmd.py: uses fixtures instead of subclassing MockPackagesTest
* cmd/module.py, cmd/uninstall.py: uses fixtures instead of subclassing MockDatabase
* database.py: uses fixtures instead of subclassing MockDatabase, removed mock/database
* pytest: uncluttering fixture implementations
* database: changing the scope to 'module'
* config.py: uses fixtures instead of subclassing MockPackagesTest
* spec_dag.py, spec_semantics.py: uses fixtures instead of subclassing MockPackagesTest
* stage.py: uses fixtures instead of subclassing MockPackagesTest. Removed mock directory
* pytest: added docstrings to all the fixtures
* pytest: final cleanup
* build_system_guess.py: fixed naming and docstrings as suggested by @scheibelp
* spec_syntax.py: added expected failure on parsing multiple specs closes #1976
* Add pytest and pytest-cov to Spack externals.
* Make `spack flake8` ignore externals.
* run-unit-tests runs spack test and not pytest.
* Remove all the special stuff for `spack test`
- Remove `conftest.py` magic and all the special case stuff in `bin/spack`
- Spack commands can optionally take unknown arguments, if they want to
  handle them.
- `spack test` is now a command like the others.
- `spack test` now just delegates its arguments to `pytest`, but it does
  it by receiving unknown arguments and NOT taking an explicit
  help argument.
* Fix error in fixtures.
* Improve `spack test` command a bit.
- Now supports an approximation of the old simple interface
- Also supports full pytest options if you want them.
* Use external coverage instead of pytest-cov
* Make coverage use parallel-mode.
* change __init__.py docs to include pytest
											
										 
											2016-12-29 16:48:48 +01:00
										 |  |  | def _main(args, unknown_args): | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  |     # Set up environment based on args. | 
					
						
							|  |  |  |     tty.set_verbose(args.verbose) | 
					
						
							|  |  |  |     tty.set_debug(args.debug) | 
					
						
							| 
									
										
										
										
											2016-11-15 15:17:03 -05:00
										 |  |  |     tty.set_stacktrace(args.stacktrace) | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  |     spack.debug = args.debug | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-12 14:52:41 -07:00
										 |  |  |     if spack.debug: | 
					
						
							|  |  |  |         import spack.util.debug as debug | 
					
						
							|  |  |  |         debug.register_interrupt_handler() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-13 01:23:40 -08:00
										 |  |  |     # Run any available pre-run hooks | 
					
						
							|  |  |  |     spack.hooks.pre_run() | 
					
						
							| 
									
										
										
										
											2016-05-26 20:30:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  |     spack.spack_working_dir = working_dir | 
					
						
							|  |  |  |     if args.mock: | 
					
						
							| 
									
										
										
										
											2015-11-28 16:21:31 -08:00
										 |  |  |         from spack.repository import RepoPath | 
					
						
							|  |  |  |         spack.repo.swap(RepoPath(spack.mock_packages_path)) | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # If the user asked for it, don't check ssl certs. | 
					
						
							|  |  |  |     if args.insecure: | 
					
						
							| 
									
										
										
										
											2016-08-09 13:23:53 -07:00
										 |  |  |         tty.warn("You asked for --insecure. Will NOT check SSL certificates.") | 
					
						
							| 
									
										
										
										
											2016-10-11 23:13:40 -07:00
										 |  |  |         spack.insecure = True | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Try to load the particular command asked for and run it | 
					
						
							| 
									
										
										
										
											2016-08-30 12:05:14 -05:00
										 |  |  |     command = spack.cmd.get_command(args.command.replace('-', '_')) | 
					
						
							| 
									
										
											  
											
												unit tests: replace nose with pytest  (#2502)
* Porting: substitute nose with ytest
This huge commit substitutes nose with pytest as a testing system. Things done here:
* deleted external/nose as it is no longer used
* moved mock resources in their own directory 'test/mock/'
* ported two tests (cmd/find, build_system) to pytest native syntax as an example
* build_environment, log: used monkeypatch instead of try/catch
* moved global mocking of fetch_cache to an auto-used fixture
* moved global mocking from test/__init__.py to conftest.py
* made `spack test` a wrapper around pytest
* run-unit-tests: avoid running python 2.6 tests under coverage to speed them up
* use `pytest --cov` instead of coverage run to cut down testing time
* mock/packages_test: moved mock yaml configuration to files instead of leaving it in the code as string literals
* concretize.py: ported tests to native pytest, reverted multiprocessing in pytest.ini as it was creating the wrong report for coveralls
* conftest.py, fixtures: added docstrings
* concretize_preferences.py: uses fixtures instead of subclassing MockPackagesTest
* directory_layout.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: uses fixtures instead of subclassing MockPackagesTest
* optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
* packages.py: uses fixtures instead of subclassing MockPackagesTest
* provider_index.py: uses fixtures instead of subclassing MockPackagesTest
* spec_yaml.py: uses fixtures instead of subclassing MockPackagesTest
* multimethod.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: now uses mock_archive_url
* git_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* hg_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* svn_fetch.py, mirror.py: uses fixtures instead of subclassing MockPackagesTest
repo.py: deleted
* test_compiler_cmd.py: uses fixtures instead of subclassing MockPackagesTest
* cmd/module.py, cmd/uninstall.py: uses fixtures instead of subclassing MockDatabase
* database.py: uses fixtures instead of subclassing MockDatabase, removed mock/database
* pytest: uncluttering fixture implementations
* database: changing the scope to 'module'
* config.py: uses fixtures instead of subclassing MockPackagesTest
* spec_dag.py, spec_semantics.py: uses fixtures instead of subclassing MockPackagesTest
* stage.py: uses fixtures instead of subclassing MockPackagesTest. Removed mock directory
* pytest: added docstrings to all the fixtures
* pytest: final cleanup
* build_system_guess.py: fixed naming and docstrings as suggested by @scheibelp
* spec_syntax.py: added expected failure on parsing multiple specs closes #1976
* Add pytest and pytest-cov to Spack externals.
* Make `spack flake8` ignore externals.
* run-unit-tests runs spack test and not pytest.
* Remove all the special stuff for `spack test`
- Remove `conftest.py` magic and all the special case stuff in `bin/spack`
- Spack commands can optionally take unknown arguments, if they want to
  handle them.
- `spack test` is now a command like the others.
- `spack test` now just delegates its arguments to `pytest`, but it does
  it by receiving unknown arguments and NOT taking an explicit
  help argument.
* Fix error in fixtures.
* Improve `spack test` command a bit.
- Now supports an approximation of the old simple interface
- Also supports full pytest options if you want them.
* Use external coverage instead of pytest-cov
* Make coverage use parallel-mode.
* change __init__.py docs to include pytest
											
										 
											2016-12-29 16:48:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Allow commands to inject an optional argument and get unknown args | 
					
						
							|  |  |  |     # if they want to handle them. | 
					
						
							|  |  |  |     info = dict(inspect.getmembers(command)) | 
					
						
							|  |  |  |     varnames = info['__code__'].co_varnames | 
					
						
							|  |  |  |     argcount = info['__code__'].co_argcount | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Actually execute the command | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  |     try: | 
					
						
							| 
									
										
											  
											
												unit tests: replace nose with pytest  (#2502)
* Porting: substitute nose with ytest
This huge commit substitutes nose with pytest as a testing system. Things done here:
* deleted external/nose as it is no longer used
* moved mock resources in their own directory 'test/mock/'
* ported two tests (cmd/find, build_system) to pytest native syntax as an example
* build_environment, log: used monkeypatch instead of try/catch
* moved global mocking of fetch_cache to an auto-used fixture
* moved global mocking from test/__init__.py to conftest.py
* made `spack test` a wrapper around pytest
* run-unit-tests: avoid running python 2.6 tests under coverage to speed them up
* use `pytest --cov` instead of coverage run to cut down testing time
* mock/packages_test: moved mock yaml configuration to files instead of leaving it in the code as string literals
* concretize.py: ported tests to native pytest, reverted multiprocessing in pytest.ini as it was creating the wrong report for coveralls
* conftest.py, fixtures: added docstrings
* concretize_preferences.py: uses fixtures instead of subclassing MockPackagesTest
* directory_layout.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: uses fixtures instead of subclassing MockPackagesTest
* optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
* packages.py: uses fixtures instead of subclassing MockPackagesTest
* provider_index.py: uses fixtures instead of subclassing MockPackagesTest
* spec_yaml.py: uses fixtures instead of subclassing MockPackagesTest
* multimethod.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: now uses mock_archive_url
* git_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* hg_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* svn_fetch.py, mirror.py: uses fixtures instead of subclassing MockPackagesTest
repo.py: deleted
* test_compiler_cmd.py: uses fixtures instead of subclassing MockPackagesTest
* cmd/module.py, cmd/uninstall.py: uses fixtures instead of subclassing MockDatabase
* database.py: uses fixtures instead of subclassing MockDatabase, removed mock/database
* pytest: uncluttering fixture implementations
* database: changing the scope to 'module'
* config.py: uses fixtures instead of subclassing MockPackagesTest
* spec_dag.py, spec_semantics.py: uses fixtures instead of subclassing MockPackagesTest
* stage.py: uses fixtures instead of subclassing MockPackagesTest. Removed mock directory
* pytest: added docstrings to all the fixtures
* pytest: final cleanup
* build_system_guess.py: fixed naming and docstrings as suggested by @scheibelp
* spec_syntax.py: added expected failure on parsing multiple specs closes #1976
* Add pytest and pytest-cov to Spack externals.
* Make `spack flake8` ignore externals.
* run-unit-tests runs spack test and not pytest.
* Remove all the special stuff for `spack test`
- Remove `conftest.py` magic and all the special case stuff in `bin/spack`
- Spack commands can optionally take unknown arguments, if they want to
  handle them.
- `spack test` is now a command like the others.
- `spack test` now just delegates its arguments to `pytest`, but it does
  it by receiving unknown arguments and NOT taking an explicit
  help argument.
* Fix error in fixtures.
* Improve `spack test` command a bit.
- Now supports an approximation of the old simple interface
- Also supports full pytest options if you want them.
* Use external coverage instead of pytest-cov
* Make coverage use parallel-mode.
* change __init__.py docs to include pytest
											
										 
											2016-12-29 16:48:48 +01:00
										 |  |  |         if argcount == 3 and varnames[2] == 'unknown_args': | 
					
						
							|  |  |  |             return_val = command(parser, args, unknown_args) | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             if unknown_args: | 
					
						
							|  |  |  |                 tty.die('unrecognized arguments: %s' % ' '.join(unknown_args)) | 
					
						
							|  |  |  |             return_val = command(parser, args) | 
					
						
							| 
									
										
										
										
											2016-04-12 16:54:51 +02:00
										 |  |  |     except SpackError as e: | 
					
						
							| 
									
										
										
										
											2015-06-06 15:50:01 -07:00
										 |  |  |         e.die() | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  |     except KeyboardInterrupt: | 
					
						
							|  |  |  |         sys.stderr.write('\n') | 
					
						
							|  |  |  |         tty.die("Keyboard interrupt.") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-20 20:15:02 -05:00
										 |  |  |     # Allow commands to return values if they want to exit with some other code. | 
					
						
							| 
									
										
										
										
											2015-02-15 01:44:38 -08:00
										 |  |  |     if return_val is None: | 
					
						
							|  |  |  |         sys.exit(0) | 
					
						
							|  |  |  |     elif isinstance(return_val, int): | 
					
						
							|  |  |  |         sys.exit(return_val) | 
					
						
							| 
									
										
										
										
											2013-10-07 17:57:27 -07:00
										 |  |  |     else: | 
					
						
							| 
									
										
										
										
											2016-08-09 13:23:53 -07:00
										 |  |  |         tty.die("Bad return value from command %s: %s" | 
					
						
							|  |  |  |                 % (args.command, return_val)) | 
					
						
							| 
									
										
										
										
											2015-01-05 02:33:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												unit tests: replace nose with pytest  (#2502)
* Porting: substitute nose with ytest
This huge commit substitutes nose with pytest as a testing system. Things done here:
* deleted external/nose as it is no longer used
* moved mock resources in their own directory 'test/mock/'
* ported two tests (cmd/find, build_system) to pytest native syntax as an example
* build_environment, log: used monkeypatch instead of try/catch
* moved global mocking of fetch_cache to an auto-used fixture
* moved global mocking from test/__init__.py to conftest.py
* made `spack test` a wrapper around pytest
* run-unit-tests: avoid running python 2.6 tests under coverage to speed them up
* use `pytest --cov` instead of coverage run to cut down testing time
* mock/packages_test: moved mock yaml configuration to files instead of leaving it in the code as string literals
* concretize.py: ported tests to native pytest, reverted multiprocessing in pytest.ini as it was creating the wrong report for coveralls
* conftest.py, fixtures: added docstrings
* concretize_preferences.py: uses fixtures instead of subclassing MockPackagesTest
* directory_layout.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: uses fixtures instead of subclassing MockPackagesTest
* optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
* packages.py: uses fixtures instead of subclassing MockPackagesTest
* provider_index.py: uses fixtures instead of subclassing MockPackagesTest
* spec_yaml.py: uses fixtures instead of subclassing MockPackagesTest
* multimethod.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: now uses mock_archive_url
* git_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* hg_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* svn_fetch.py, mirror.py: uses fixtures instead of subclassing MockPackagesTest
repo.py: deleted
* test_compiler_cmd.py: uses fixtures instead of subclassing MockPackagesTest
* cmd/module.py, cmd/uninstall.py: uses fixtures instead of subclassing MockDatabase
* database.py: uses fixtures instead of subclassing MockDatabase, removed mock/database
* pytest: uncluttering fixture implementations
* database: changing the scope to 'module'
* config.py: uses fixtures instead of subclassing MockPackagesTest
* spec_dag.py, spec_semantics.py: uses fixtures instead of subclassing MockPackagesTest
* stage.py: uses fixtures instead of subclassing MockPackagesTest. Removed mock directory
* pytest: added docstrings to all the fixtures
* pytest: final cleanup
* build_system_guess.py: fixed naming and docstrings as suggested by @scheibelp
* spec_syntax.py: added expected failure on parsing multiple specs closes #1976
* Add pytest and pytest-cov to Spack externals.
* Make `spack flake8` ignore externals.
* run-unit-tests runs spack test and not pytest.
* Remove all the special stuff for `spack test`
- Remove `conftest.py` magic and all the special case stuff in `bin/spack`
- Spack commands can optionally take unknown arguments, if they want to
  handle them.
- `spack test` is now a command like the others.
- `spack test` now just delegates its arguments to `pytest`, but it does
  it by receiving unknown arguments and NOT taking an explicit
  help argument.
* Fix error in fixtures.
* Improve `spack test` command a bit.
- Now supports an approximation of the old simple interface
- Also supports full pytest options if you want them.
* Use external coverage instead of pytest-cov
* Make coverage use parallel-mode.
* change __init__.py docs to include pytest
											
										 
											2016-12-29 16:48:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | def main(args): | 
					
						
							|  |  |  |     # Just print help and exit if run with no arguments at all | 
					
						
							|  |  |  |     if len(args) == 1: | 
					
						
							|  |  |  |         parser.print_help() | 
					
						
							|  |  |  |         sys.exit(1) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # actually parse the args. | 
					
						
							|  |  |  |     args, unknown = parser.parse_known_args() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if args.profile: | 
					
						
							|  |  |  |         import cProfile | 
					
						
							| 
									
										
										
										
											2017-03-03 15:24:44 -06:00
										 |  |  |         cProfile.runctx('_main(args, unknown)', globals(), locals()) | 
					
						
							| 
									
										
											  
											
												unit tests: replace nose with pytest  (#2502)
* Porting: substitute nose with ytest
This huge commit substitutes nose with pytest as a testing system. Things done here:
* deleted external/nose as it is no longer used
* moved mock resources in their own directory 'test/mock/'
* ported two tests (cmd/find, build_system) to pytest native syntax as an example
* build_environment, log: used monkeypatch instead of try/catch
* moved global mocking of fetch_cache to an auto-used fixture
* moved global mocking from test/__init__.py to conftest.py
* made `spack test` a wrapper around pytest
* run-unit-tests: avoid running python 2.6 tests under coverage to speed them up
* use `pytest --cov` instead of coverage run to cut down testing time
* mock/packages_test: moved mock yaml configuration to files instead of leaving it in the code as string literals
* concretize.py: ported tests to native pytest, reverted multiprocessing in pytest.ini as it was creating the wrong report for coveralls
* conftest.py, fixtures: added docstrings
* concretize_preferences.py: uses fixtures instead of subclassing MockPackagesTest
* directory_layout.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: uses fixtures instead of subclassing MockPackagesTest
* optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
optional_deps.py: uses fixtures instead of subclassing MockPackagesTest
* packages.py: uses fixtures instead of subclassing MockPackagesTest
* provider_index.py: uses fixtures instead of subclassing MockPackagesTest
* spec_yaml.py: uses fixtures instead of subclassing MockPackagesTest
* multimethod.py: uses fixtures instead of subclassing MockPackagesTest
* install.py: now uses mock_archive_url
* git_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* hg_fetch.py: uses fixtures instead of subclassing MockPackagesTest
* svn_fetch.py, mirror.py: uses fixtures instead of subclassing MockPackagesTest
repo.py: deleted
* test_compiler_cmd.py: uses fixtures instead of subclassing MockPackagesTest
* cmd/module.py, cmd/uninstall.py: uses fixtures instead of subclassing MockDatabase
* database.py: uses fixtures instead of subclassing MockDatabase, removed mock/database
* pytest: uncluttering fixture implementations
* database: changing the scope to 'module'
* config.py: uses fixtures instead of subclassing MockPackagesTest
* spec_dag.py, spec_semantics.py: uses fixtures instead of subclassing MockPackagesTest
* stage.py: uses fixtures instead of subclassing MockPackagesTest. Removed mock directory
* pytest: added docstrings to all the fixtures
* pytest: final cleanup
* build_system_guess.py: fixed naming and docstrings as suggested by @scheibelp
* spec_syntax.py: added expected failure on parsing multiple specs closes #1976
* Add pytest and pytest-cov to Spack externals.
* Make `spack flake8` ignore externals.
* run-unit-tests runs spack test and not pytest.
* Remove all the special stuff for `spack test`
- Remove `conftest.py` magic and all the special case stuff in `bin/spack`
- Spack commands can optionally take unknown arguments, if they want to
  handle them.
- `spack test` is now a command like the others.
- `spack test` now just delegates its arguments to `pytest`, but it does
  it by receiving unknown arguments and NOT taking an explicit
  help argument.
* Fix error in fixtures.
* Improve `spack test` command a bit.
- Now supports an approximation of the old simple interface
- Also supports full pytest options if you want them.
* Use external coverage instead of pytest-cov
* Make coverage use parallel-mode.
* change __init__.py docs to include pytest
											
										 
											2016-12-29 16:48:48 +01:00
										 |  |  |     elif args.pdb: | 
					
						
							|  |  |  |         import pdb | 
					
						
							|  |  |  |         pdb.runctx('_main(args, unknown)', globals(), locals()) | 
					
						
							|  |  |  |     else: | 
					
						
							|  |  |  |         _main(args, unknown) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							|  |  |  |     main(sys.argv) |