spack.test package

Submodules

spack.test.architecture module

Test checks if the architecture class is created correctly and also that the functions are looking for the correct architecture name

spack.test.architecture.test_boolness()
spack.test.architecture.test_dict_functions_for_architecture()
spack.test.architecture.test_platform()
spack.test.architecture.test_user_back_end_input(config)

Test when user inputs backend that both the backend target and backend operating system match

spack.test.architecture.test_user_defaults(config)
spack.test.architecture.test_user_front_end_input(config)

Test when user inputs just frontend that both the frontend target and frontend operating system match

spack.test.architecture.test_user_input_combination(config)

spack.test.build_system_guess module

spack.test.build_system_guess.test_build_systems(url_and_build_system)
spack.test.build_system_guess.url_and_build_system(request, tmpdir)

Sets up the resources to be pulled by the stage with the appropriate file name and returns their url along with the correct build-system guess

spack.test.build_systems module

class spack.test.build_systems.TestAutotoolsPackage

Bases: object

pytestmark = [<MarkDecorator 'usefixtures' {'args': ('config', 'builtin_mock'), 'kwargs': {}}>]
test_with_or_without()
spack.test.build_systems.test_cmake_std_args(config, builtin_mock)

spack.test.cc module

This test checks that the Spack cc compiler wrapper is parsing arguments correctly.

class spack.test.cc.CompilerWrapperTest(methodName='runTest')

Bases: unittest.case.TestCase

check_cc(command, args, expected)
check_cpp(command, args, expected)
check_cxx(command, args, expected)
check_fc(command, args, expected)
check_ld(command, args, expected)
setUp()
tearDown()
test_all_deps()

Ensure includes and RPATHs for all deps are added.

test_as_mode()
test_ccld_mode()
test_cpp_mode()
test_dep_include()

Ensure a single dependency include directory is added.

test_dep_lib()

Ensure a single dependency RPATH is added.

test_dep_lib_no_lib()

Ensure a single dependency RPATH is added with no -L.

test_dep_lib_no_rpath()

Ensure a single dependency link flag is added with no dep RPATH.

test_dep_rpath()

Ensure RPATHs for root package are added.

test_flags()
test_ld_deps()

Ensure no (extra) -I args or -Wl, are passed in ld mode.

Ensure SPACK_LINK_DEPS controls -L for ld.

test_ld_deps_no_rpath()

Ensure SPACK_RPATH_DEPS controls RPATHs for ld.

test_ld_deps_reentrant()

Make sure ld -r is handled correctly on OS’s where it doesn’t support rpaths.

test_ld_mode()
test_vcheck_mode()

spack.test.compilers module

class spack.test.compilers.TestCompilers

Bases: object

pytestmark = [<MarkDecorator 'usefixtures' {'args': ('config',), 'kwargs': {}}>]
test_all_compilers()
test_get_compiler_duplicates()

spack.test.concretize module

class spack.test.concretize.TestConcretize

Bases: object

concretize_multi_provider()
pytestmark = [<MarkDecorator 'usefixtures' {'args': ('config', 'builtin_mock'), 'kwargs': {}}>]
test_compiler_child()
test_compiler_inheritance()
test_concretize(spec)
test_concretize_mention_build_dep()
test_concretize_preferred_version()
test_concretize_two_virtuals()

Test a package with multiple virtual dependencies.

test_concretize_two_virtuals_with_dual_provider()

Test a package with multiple virtual dependencies and force a provider that provides both.

test_concretize_two_virtuals_with_dual_provider_and_a_conflict()

Test a package with multiple virtual dependencies and force a provider that provides both, and another conflicting package that provides one.

test_concretize_two_virtuals_with_one_bound(refresh_builtin_mock)

Test a package with multiple virtual dependencies and one preset.

test_concretize_two_virtuals_with_two_bound()

Test a package with multiple virtual deps and two of them preset.

test_concretize_with_provides_when()

Make sure insufficient versions of MPI are not in providers list when we ask for some advanced version.

test_concretize_with_restricted_virtual()
test_conflicts_in_spec(conflict_spec)
test_different_compilers_get_different_flags()
test_external_and_virtual()
test_external_package()
test_external_package_module()
test_find_spec_children()
test_find_spec_none()
test_find_spec_parents()

Tests the spec finding logic used by concretization.

test_find_spec_self()
test_find_spec_sibling()
test_my_dep_depends_on_provider_of_my_virtual_dep()
test_no_compilers_for_arch()
test_no_matching_compiler_specs()
test_nobuild_package()
test_provides_handles_multiple_providers_of_same_vesrion()
test_regression_issue_4492()
test_virtual_is_fully_expanded_for_callpath()
test_virtual_is_fully_expanded_for_mpileaks()
spack.test.concretize.check_concretize(abstract_spec)
spack.test.concretize.check_spec(abstract, concrete)
spack.test.concretize.conflict_spec(request)

Spec to be concretized

spack.test.concretize.spec(request)

Spec to be concretized

spack.test.concretize_preferences module

class spack.test.concretize_preferences.TestConcretizePreferences

Bases: object

pytestmark = [<MarkDecorator 'usefixtures' {'args': ('concretize_scope', 'builtin_mock'), 'kwargs': {}}>]
test_all_is_not_a_virtual()

Verify that all is allowed in packages.yaml.

test_develop()

Test concretization with develop version

test_external_mpi()
test_no_virtuals_in_packages_yaml()

Verify that virtuals are not allowed in packages.yaml.

test_preferred_compilers(refresh_builtin_mock)

Test preferred compilers are applied correctly

test_preferred_providers()

Test preferred providers of virtual packages are applied correctly

test_preferred_variants()

Test preferred variants are applied correctly

test_preferred_versions()

Test preferred package versions are applied correctly

test_preferred_versions_mixed_version_types()
spack.test.concretize_preferences.assert_variant_values(spec, **variants)
spack.test.concretize_preferences.concretize(abstract_spec)
spack.test.concretize_preferences.concretize_scope(config, tmpdir)

Adds a scope for concretization preferences

spack.test.concretize_preferences.update_packages(pkgname, section, value)

Update config and reread package list

spack.test.config module

class spack.test.config.TestConfig

Bases: object

check_canonical(var, expected)

Ensure that <expected> is substituted properly for <var> in strings containing <var> in various positions.

pytestmark = [<MarkDecorator 'usefixtures' {'args': ('config',), 'kwargs': {}}>]
test_read_config(write_config_file)
test_read_config_merge_list(write_config_file)
test_read_config_override_all(write_config_file)
test_read_config_override_key(write_config_file)
test_read_config_override_list(write_config_file)
test_substitute_config_variables()
test_substitute_tempdir()
test_substitute_user()
test_write_key_in_memory(compiler_specs)
test_write_key_to_disk(compiler_specs)
test_write_list_in_memory()
test_write_to_same_priority_file(compiler_specs)
spack.test.config.check_compiler_config(comps, *compiler_names)

Check that named compilers in comps match Spack’s config.

spack.test.config.compiler_specs()

Returns a couple of compiler specs needed for the tests

spack.test.config.config(tmpdir)

Mocks the configuration scope.

spack.test.config.test_keys_are_ordered()
spack.test.config.write_config_file(tmpdir)

Returns a function that writes a config file.

spack.test.conftest module

spack.test.conftest.builtin_mock(repo_path)

Uses the ‘builtin.mock’ repository instead of ‘builtin’

spack.test.conftest.config(configuration_dir)

Hooks the mock configuration files into spack.config

spack.test.conftest.configuration_dir(tmpdir_factory, linux_os)

Copies mock configuration files in a temporary directory. Returns the directory path.

spack.test.conftest.database(tmpdir_factory, builtin_mock, config)

Creates a mock database with some packages installed note that the ref count for dyninst here will be 3, as it’s recycled across each install.

spack.test.conftest.install_mockery(tmpdir, config, builtin_mock)

Hooks a fake install directory and a fake db into Spack.

spack.test.conftest.linux_os()

Returns a named tuple with attributes ‘name’ and ‘version’ representing the OS.

spack.test.conftest.mock_archive()

Creates a very simple archive directory with a configure script and a makefile that installs to a prefix. Tars it up into an archive.

spack.test.conftest.mock_fetch(mock_archive)

Fake the URL for a package so it downloads from a file.

spack.test.conftest.mock_fetch_cache(monkeypatch)

Substitutes spack.fetch_cache with a mock object that does nothing and raises on fetch.

spack.test.conftest.mock_git_repository()

Creates a very simple git repository with two branches and two commits.

spack.test.conftest.mock_hg_repository()

Creates a very simple hg repository with two commits.

spack.test.conftest.mock_svn_repository()

Creates a very simple svn repository with two commits.

spack.test.conftest.refresh_builtin_mock(builtin_mock, repo_path)

Refreshes the state of spack.repo

spack.test.conftest.refresh_db_on_exit(database)

“Restores the state of the database after a test.

spack.test.conftest.repo_path()

Session scoped RepoPath object pointing to the mock repository

spack.test.database module

These tests check the database is functioning properly, both in memory and in its file

spack.test.database.test_005_db_exists(database)

Make sure db cache file exists after creating.

spack.test.database.test_010_all_install_sanity(database)

Ensure that the install layout reflects what we think it does.

spack.test.database.test_015_write_and_read(database)
spack.test.database.test_020_db_sanity(database)

Make sure query() returns what’s actually in the db.

spack.test.database.test_025_reindex(database)

Make sure reindex works and ref counts are valid.

spack.test.database.test_030_db_sanity_from_another_process(database, refresh_db_on_exit)
spack.test.database.test_040_ref_counts(database)

Ensure that we got ref counts right when we read the DB.

spack.test.database.test_050_basic_query(database)

Ensure querying database is consistent with what is installed.

spack.test.database.test_060_remove_and_add_root_package(database)
spack.test.database.test_070_remove_and_add_dependency_package(database)
spack.test.database.test_080_root_ref_counts(database)
spack.test.database.test_090_non_root_ref_counts(database)
spack.test.database.test_100_no_write_with_exception_on_remove(database)
spack.test.database.test_110_no_write_with_exception_on_install(database)
spack.test.database.test_default_queries(database)
spack.test.database.test_external_entries_in_db(database)

spack.test.directory_layout module

This test verifies that the Spack directory layout works properly.

spack.test.directory_layout.layout_and_dir(tmpdir)

Returns a directory layout and the corresponding directory.

spack.test.directory_layout.test_find(layout_and_dir, config, builtin_mock)

Test that finding specs within an install layout works.

spack.test.directory_layout.test_handle_unknown_package(layout_and_dir, config, builtin_mock)

This test ensures that spack can at least do some operations with packages that are installed but that it does not know about. This is actually not such an uncommon scenario with spack; it can happen when you switch from a git branch where you’re working on a new package.

This test ensures that the directory layout stores enough information about installed packages’ specs to uninstall or query them again if the package goes away.

spack.test.directory_layout.test_read_and_write_spec(layout_and_dir, config, builtin_mock)

This goes through each package in spack and creates a directory for it. It then ensures that the spec for the directory’s installed package can be read back in consistently, and finally that the directory can be removed by the directory layout.

spack.test.directory_layout.test_yaml_directory_layout_parameters(tmpdir, config)

This tests the various parameters that can be used to configure the install location

spack.test.environment module

spack.test.environment.env(prepare_environment_for_tests)

Returns an empty EnvironmentModifications object.

spack.test.environment.files_to_be_sourced()

Returns a list of files to be sourced

spack.test.environment.miscellaneous_paths()

Returns a list of paths, including system ones.

spack.test.environment.prepare_environment_for_tests()

Sets a few dummy variables in the current environment, that will be useful for the tests below.

spack.test.environment.test_append_flags(env)

Tests appending to a value in the environment.

spack.test.environment.test_extend(env)

Tests that we can construct a list of environment modifications starting from another list.

spack.test.environment.test_extra_arguments(env)

Tests that we can attach extra arguments to any command.

spack.test.environment.test_filter_system_paths(miscellaneous_paths)

Tests that the filtering of system paths works as expected.

spack.test.environment.test_inspect_path(tmpdir)
spack.test.environment.test_path_manipulation(env)

Tests manipulating list of paths in the environment.

spack.test.environment.test_set(env)

Tests setting values in the environment.

spack.test.environment.test_set_path(env)

Tests setting paths in an environment variable.

spack.test.environment.test_source_files(files_to_be_sourced)

Tests the construction of a list of environment modifications that are the result of sourcing a file.

spack.test.environment.test_unset(env)

Tests unsetting values in the environment.

spack.test.file_cache module

Test Spack’s FileCache.

spack.test.file_cache.file_cache(tmpdir)

Returns a properly initialized FileCache instance

spack.test.file_cache.test_write_and_read_cache_file(file_cache)

Test writing then reading a cached file.

spack.test.file_cache.test_write_and_remove_cache_file(file_cache)

Test two write transactions on a cached file. Then try to remove an entry from it.

spack.test.file_list module

class spack.test.file_list.TestHeaderList

Bases: object

test_add(header_list)
test_flags(header_list)
test_get_item(header_list)
test_joined_and_str(header_list)
test_paths_manipulation(header_list)
test_repr(header_list)
class spack.test.file_list.TestLibraryList

Bases: object

test_add(library_list)
test_flags(library_list)
test_get_item(library_list)
test_joined_and_str(library_list)
test_paths_manipulation(library_list)
test_repr(library_list)
spack.test.file_list.header_list()

Returns an instance of header list

spack.test.file_list.library_list()

Returns an instance of LibraryList.

spack.test.file_list.search_dir = '/home/docs/checkouts/readthedocs.org/user_builds/spack/checkouts/latest/lib/spack/spack/test/data/directory_search'

Directory where the data for the test below is stored

spack.test.file_list.test_searching_order(search_fn, search_list, root, kwargs)

spack.test.git_fetch module

spack.test.git_fetch.test_fetch(type_of_test, secure, mock_git_repository, config, refresh_builtin_mock)

Tries to:

  1. Fetch the repo using a fetch strategy constructed with supplied args (they depend on type_of_test).
  2. Check if the test_file is in the checked out repository.
  3. Assert that the repository is at the revision supplied.
  4. Add and remove some files, then reset the repo, and ensure it’s all there again.

spack.test.graph module

spack.test.graph.test_ascii_graph_mpileaks(builtin_mock)

Test dynamically graphing the mpileaks package.

spack.test.graph.test_dynamic_dot_graph_mpileaks(builtin_mock)

Test dynamically graphing the mpileaks package.

spack.test.graph.test_static_graph_mpileaks(builtin_mock)

Test a static spack graph for a simple package.

spack.test.graph.test_topo_sort(builtin_mock)

Test topo sort gives correct order.

spack.test.hg_fetch module

spack.test.hg_fetch.test_fetch(type_of_test, secure, mock_hg_repository, config, refresh_builtin_mock)

Tries to:

  1. Fetch the repo using a fetch strategy constructed with supplied args (they depend on type_of_test).
  2. Check if the test_file is in the checked out repository.
  3. Assert that the repository is at the revision supplied.
  4. Add and remove some files, then reset the repo, and ensure it’s all there again.

spack.test.install module

exception spack.test.install.MockInstallError(message, long_message=None)

Bases: spack.error.SpackError

class spack.test.install.MockStage(wrapped_stage)

Bases: object

destroy()
class spack.test.install.RemovePrefixChecker(wrapped_rm_prefix)

Bases: object

remove_prefix()
spack.test.install.mock_remove_prefix(*args)
spack.test.install.test_failing_build(install_mockery, mock_fetch)
spack.test.install.test_install_and_uninstall(install_mockery, mock_fetch)
spack.test.install.test_partial_install_delete_prefix_and_stage(install_mockery, mock_fetch)
spack.test.install.test_partial_install_keep_prefix(install_mockery, mock_fetch)
spack.test.install.test_second_install_no_overwrite_first(install_mockery, mock_fetch)
spack.test.install.test_store(install_mockery, mock_fetch)

spack.test.lock module

These tests ensure that our lock works correctly.

This can be run in two ways.

First, it can be run as a node-local test, with a typical invocation like this:

spack test lock

You can also run it as an MPI program, which allows you to test locks across nodes. So, e.g., you can run the test like this:

mpirun -n 7 spack test lock

And it will test locking correctness among MPI processes. Ideally, you want the MPI processes to span across multiple nodes, so, e.g., for SLURM you might do this:

srun -N 7 -n 7 -m cyclic spack test lock

You can use this to test whether your shared filesystem properly supports POSIX reader-writer locking with byte ranges through fcntl.

If you want to test on multiple filesystems, you can modify the locations list below. By default it looks like this:

locations = [
    tempfile.gettempdir(),  # standard tmp directory (potentially local)
    '/nfs/tmp2/%u',         # NFS tmp mount
    '/p/lscratch*/%u'       # Lustre scratch mount
]

Add names and paths for your preferred filesystem mounts to test on them; the tests are parametrized to run on all the filesystems listed in this dict. Note that ‘tmp’ will be skipped for MPI testing, as it is often a node-local filesystem, and multi-node tests will fail if the locks aren’t actually on a shared filesystem.

spack.test.lock.acquire_read(lock_path, start=0, length=0)
spack.test.lock.acquire_write(lock_path, start=0, length=0)
spack.test.lock.barrier_timeout = 5

This is the lock timeout for expected failures. This may need to be higher for some filesystems.

spack.test.lock.local_multiproc_test(*functions)

Order some processes using simple barrier synchronization.

spack.test.lock.locations = ['/tmp', '/nfs/tmp2/docs', '/p/lscratch*/docs']

This is the longest a failed multiproc test will take. Barriers will time out and raise an exception after this interval. In MPI mode, barriers don’t time out (they hang). See mpi_multiproc_test.

spack.test.lock.lock_dir(lock_test_directory)
spack.test.lock.lock_path(lock_dir)

This lock is shared among all processes in a multiproc test.

spack.test.lock.lock_test_directory(request)

This fixture causes tests to be executed for many different mounts.

See the locations dict above for details.

spack.test.lock.mpi_multiproc_test(*functions)

SPMD version of multiproc test.

This needs to be run like so:

srun spack test lock

Each process executes its corresponding function. This is different from multiproc_test above, which spawns the processes. This will skip tests if there are too few processes to run them.

spack.test.lock.multiproc_test(*functions)

Order some processes using simple barrier synchronization.

spack.test.lock.private_lock_path(lock_dir)

In MPI mode, this is a private lock for each rank in a multiproc test.

For other modes, it is the same as a shared lock.

spack.test.lock.read_only(*args, **kwds)
spack.test.lock.test_complex_acquire_and_release_chain(lock_path)
spack.test.lock.test_read_lock_timeout_on_write(lock_path)
spack.test.lock.test_read_lock_timeout_on_write_2(lock_path)
spack.test.lock.test_read_lock_timeout_on_write_3(lock_path)
spack.test.lock.test_read_lock_timeout_on_write_ranges(lock_path)

small write lock, read whole file.

spack.test.lock.test_read_lock_timeout_on_write_ranges_2(lock_path)

small write lock, small read lock

spack.test.lock.test_read_lock_timeout_on_write_ranges_3(lock_path)

two write locks, overlapping read locks

spack.test.lock.test_transaction(lock_path)
spack.test.lock.test_transaction_with_context_manager(lock_path)
spack.test.lock.test_transaction_with_context_manager_and_exception(lock_path)
spack.test.lock.test_transaction_with_exception(lock_path)
spack.test.lock.test_upgrade_read_to_write(private_lock_path)

Test that a read lock can be upgraded to a write lock.

Note that to upgrade a read lock to a write lock, you have the be the only holder of a read lock. Client code needs to coordinate that for shared locks. For this test, we use a private lock just to test that an upgrade is possible.

spack.test.lock.test_upgrade_read_to_write_fails_with_readonly_file(private_lock_path)
spack.test.lock.test_write_lock_timeout_on_read(lock_path)
spack.test.lock.test_write_lock_timeout_on_read_2(lock_path)
spack.test.lock.test_write_lock_timeout_on_read_3(lock_path)
spack.test.lock.test_write_lock_timeout_on_read_ranges(lock_path)
spack.test.lock.test_write_lock_timeout_on_read_ranges_2(lock_path)
spack.test.lock.test_write_lock_timeout_on_read_ranges_3(lock_path)
spack.test.lock.test_write_lock_timeout_on_read_ranges_4(lock_path)
spack.test.lock.test_write_lock_timeout_on_read_ranges_5(lock_path)
spack.test.lock.test_write_lock_timeout_on_write(lock_path)
spack.test.lock.test_write_lock_timeout_on_write_2(lock_path)
spack.test.lock.test_write_lock_timeout_on_write_3(lock_path)
spack.test.lock.test_write_lock_timeout_on_write_ranges(lock_path)
spack.test.lock.test_write_lock_timeout_on_write_ranges_2(lock_path)
spack.test.lock.test_write_lock_timeout_on_write_ranges_3(lock_path)
spack.test.lock.test_write_lock_timeout_on_write_ranges_4(lock_path)
spack.test.lock.test_write_lock_timeout_with_multiple_readers_2_1(lock_path)
spack.test.lock.test_write_lock_timeout_with_multiple_readers_2_1_ranges(lock_path)
spack.test.lock.test_write_lock_timeout_with_multiple_readers_2_2(lock_path)
spack.test.lock.test_write_lock_timeout_with_multiple_readers_2_3_ranges(lock_path)
spack.test.lock.test_write_lock_timeout_with_multiple_readers_3_1(lock_path)
spack.test.lock.test_write_lock_timeout_with_multiple_readers_3_1_ranges(lock_path)
spack.test.lock.test_write_lock_timeout_with_multiple_readers_3_2(lock_path)
spack.test.lock.test_write_lock_timeout_with_multiple_readers_3_2_ranges(lock_path)
spack.test.lock.timeout_read(lock_path, start=0, length=0)
spack.test.lock.timeout_write(lock_path, start=0, length=0)

spack.test.log module

spack.test.log.test_log_python_output_and_echo_output(capfd, tmpdir)
spack.test.log.test_log_python_output_with_fd_stream(capfd, tmpdir)
spack.test.log.test_log_python_output_with_python_stream(capsys, tmpdir)
spack.test.log.test_log_subproc_and_echo_output(capfd, tmpdir)
spack.test.log.test_log_subproc_output(capsys, tmpdir)

spack.test.make_executable module

Tests for Spack’s built-in parallel make support.

This just tests whether the right args are getting passed to make.

class spack.test.make_executable.MakeExecutableTest(methodName='runTest')

Bases: unittest.case.TestCase

setUp()
tearDown()
test_make_explicit()
test_make_normal()
test_make_one_job()
test_make_parallel_disabled()
test_make_parallel_false()
test_make_parallel_precedence()

spack.test.mirror module

class spack.test.mirror.TestMirror

Bases: object

pytestmark = [<MarkDecorator 'usefixtures' {'args': ('config', 'refresh_builtin_mock'), 'kwargs': {}}>]
test_all_mirror(mock_git_repository, mock_svn_repository, mock_hg_repository, mock_archive)
test_git_mirror(mock_git_repository)
test_hg_mirror(mock_hg_repository)
test_svn_mirror(mock_svn_repository)
test_url_mirror(mock_archive)
spack.test.mirror.check_mirror()
spack.test.mirror.set_up_package(name, repository, url_attr)

Set up a mock package to be mirrored. Each package needs us to:

  1. Set up a mock repo/archive to fetch from.
  2. Point the package’s version args at that repo.

spack.test.module_parsing module

spack.test.module_parsing.save_env()
spack.test.module_parsing.test_get_argument_from_module_line()
spack.test.module_parsing.test_get_module_cmd_fails(save_env)
spack.test.module_parsing.test_get_module_cmd_from_bash_parens(save_env)
spack.test.module_parsing.test_get_module_cmd_from_bash_ticks(save_env)
spack.test.module_parsing.test_get_module_cmd_from_bash_using_modules()
spack.test.module_parsing.test_get_module_cmd_from_which(tmpdir, save_env)
spack.test.module_parsing.test_get_path_from_module(save_env)

spack.test.multimethod module

Test for multi_method dispatch.

spack.test.multimethod.test_default_works(builtin_mock)
spack.test.multimethod.test_dependency_match(builtin_mock)
spack.test.multimethod.test_mpi_version(builtin_mock)
spack.test.multimethod.test_multimethod_with_base_class(builtin_mock)
spack.test.multimethod.test_no_version_match(builtin_mock)
spack.test.multimethod.test_one_version_match(builtin_mock)
spack.test.multimethod.test_target_match(builtin_mock)
spack.test.multimethod.test_undefined_mpi_version(builtin_mock)
spack.test.multimethod.test_version_overlap(builtin_mock)
spack.test.multimethod.test_virtual_dep_match(builtin_mock)

spack.test.namespace_trie module

spack.test.namespace_trie.test_add_multiple(trie)
spack.test.namespace_trie.test_add_none_multiple(trie)
spack.test.namespace_trie.test_add_none_single(trie)
spack.test.namespace_trie.test_add_single(trie)
spack.test.namespace_trie.test_add_three(trie)
spack.test.namespace_trie.trie()

spack.test.optional_deps module

spack.test.optional_deps.spec_and_expected(request)

Parameters for the normalization test.

spack.test.optional_deps.test_default_variant(config, builtin_mock)
spack.test.optional_deps.test_normalize(spec_and_expected, config, builtin_mock)

spack.test.package_sanity module

This test does sanity checks on Spack’s builtin package database.

spack.test.package_sanity.check_db()

Get all packages in a DB to make sure they work.

spack.test.package_sanity.test_all_versions_are_lowercase()

Spack package names must be lowercase, and use - instead of _.

spack.test.package_sanity.test_get_all_mock_packages()

Get the mock packages once each too.

spack.test.package_sanity.test_get_all_packages()

Get all packages once and make sure that works.

spack.test.packages module

class spack.test.packages.TestPackage

Bases: object

pytestmark = [<MarkDecorator 'usefixtures' {'args': ('config', 'builtin_mock'), 'kwargs': {}}>]
test_dependency_extensions()
test_import_class_from_package()
test_import_module_from_package()
test_import_namespace_container_modules()
test_import_package()
test_import_package_as()
test_inheritance_of_diretives()
test_load_package()
test_nonexisting_package_filename()
test_package_class_names()
test_package_filename()
test_package_name()

spack.test.packaging module

This test checks the binary packaging infrastructure

spack.test.packaging.fake_fetchify(url, pkg)

Fake the URL for a package so it downloads from a file.

spack.test.packaging.has_gnupg2()
spack.test.packaging.test_packaging(mock_archive, tmpdir)
spack.test.packaging.test_relocate()
spack.test.packaging.test_relocate_elf()
spack.test.packaging.test_relocate_macho()
spack.test.packaging.testing_gpg_directory(tmpdir)

spack.test.patch module

spack.test.patch.mock_apply(monkeypatch)

Monkeypatches Patch.apply to test only the additional behavior of derived classes.

spack.test.patch.mock_stage(tmpdir, monkeypatch)
spack.test.patch.test_url_patch_expansion(mock_stage, filename, md5)

spack.test.pattern module

spack.test.pattern.composite(interface, implementation, request)

Returns a composite that contains an instance of implementation(1) and one of implementation(2).

spack.test.pattern.implementation(interface)

Returns an implementation of the interface

spack.test.pattern.interface()

Returns the interface class for the composite.

spack.test.pattern.test_composite_interface_calls(interface, composite)
spack.test.pattern.test_composite_no_methods()
spack.test.pattern.test_composite_wrong_container(interface)

spack.test.provider_index module

Tests for provider index cache files.

Tests assume that mock packages provide this:

{'blas':   {
     blas: set([netlib-blas, openblas, openblas-with-lapack])},
 'lapack': {lapack: set([netlib-lapack, openblas-with-lapack])},
 'mpi': {mpi@:1: set([mpich@:1]),
                  mpi@:2.0: set([mpich2]),
                  mpi@:2.1: set([mpich2@1.1:]),
                  mpi@:2.2: set([mpich2@1.2:]),
                  mpi@:3: set([mpich@3:]),
                  mpi@:10.0: set([zmpi])},
  'stuff': {stuff: set([externalvirtual])}}
spack.test.provider_index.test_copy(builtin_mock)
spack.test.provider_index.test_equal(builtin_mock)
spack.test.provider_index.test_mpi_providers(builtin_mock)
spack.test.provider_index.test_providers_for_simple(builtin_mock)
spack.test.provider_index.test_yaml_round_trip(builtin_mock)

spack.test.python_version module

Check that Spack complies with minimum supported python versions.

We ensure that all Spack files work with Python2 >= 2.6 and Python3 >= 3.0.

We’d like to drop 2.6 support at some point, but there are still many HPC systems that ship with RHEL6/CentOS 6, which have Python 2.6 as the default version. Once those go away, we can likely drop 2.6 and increase the minimum supported Python 3 version, as well.

spack.test.python_version.check_python_versions(files)

Check that a set of Python files works with supported Ptyhon versions

spack.test.python_version.pyfiles(search_paths, exclude=())

Generator that yields all the python files in the search paths.

Parameters:
  • search_paths (list of str) – list of paths to search for python files
  • exclude (list of str) – file paths to exclude from search
Yields:

python files in the search path.

spack.test.python_version.test_core_module_compatibility()

Test that all core spack modules work with supported Python versions.

spack.test.python_version.test_package_module_compatibility()

Test that all spack packages work with supported Python versions.

spack.test.sbang module

Test that Spack’s shebang filtering works correctly.

class spack.test.sbang.ScriptDirectory

Bases: object

Directory full of test scripts to run sbang instrumentation on.

destroy()
spack.test.sbang.script_dir()
spack.test.sbang.test_shebang_handles_non_writable_files(script_dir)
spack.test.sbang.test_shebang_handling(script_dir)

spack.test.spack_yaml module

Test Spack’s custom YAML format.

spack.test.spack_yaml.data()

Returns the data loaded from a test file

spack.test.spack_yaml.test_dict_order(data)
spack.test.spack_yaml.test_line_numbers(data)
spack.test.spack_yaml.test_parse(data)
spack.test.spack_yaml.test_yaml_aliases()

spack.test.spec_dag module

These tests check Spec DAG operations using dummy packages.

class spack.test.spec_dag.TestSpecDag

Bases: object

check_diamond_deptypes(spec)

Validate deptypes in dt-diamond spec.

This ensures that concretization works properly when two packages depend on the same dependency in different ways.

check_diamond_normalized_dag(spec)
pytestmark = [<MarkDecorator 'usefixtures' {'args': ('refresh_builtin_mock',), 'kwargs': {}}>]
test_canonical_deptype()
test_concretize_deptypes()

Ensure that dependency types are preserved after concretization.

test_conflicting_package_constraints(set_dependency)
test_conflicting_spec_constraints()
test_construct_spec_with_deptypes()

Ensure that it is possible to construct a spec with explicit dependency types.

test_contains()
test_copy_concretized()
test_copy_dependencies()
test_copy_deptypes()

Ensure that dependency types are preserved by spec copy.

test_copy_normalized()
test_copy_simple()
test_dependents_and_dependencies_are_correct()
test_deptype_traversal()
test_deptype_traversal_full()
test_deptype_traversal_run()
test_deptype_traversal_with_builddeps()
test_edge_traversals()

Make sure child and parent traversals of specs work.

test_equal()
test_getitem_exceptional_paths()
test_getitem_query()
test_hash_bits()

Ensure getting first n bits of a base32-encoded DAG hash works.

test_invalid_dep()
test_invalid_literal_spec()
test_normalize_a_lot()
test_normalize_diamond_deptypes()

Ensure that dependency types are preserved even if the same thing is depended on in two different ways.

test_normalize_mpileaks()
test_normalize_twice()

Make sure normalize can be run twice on the same spec, and that it is idempotent.

test_normalize_with_virtual_package()
test_normalize_with_virtual_spec()
test_postorder_edge_traversal()
test_postorder_node_traversal()
test_postorder_path_traversal()
test_preorder_edge_traversal()
test_preorder_node_traversal()
test_preorder_path_traversal()
test_traversal_directions()

Make sure child and parent traversals of specs work.

test_unsatisfiable_architecture(set_dependency)
test_unsatisfiable_compiler(set_dependency)
test_unsatisfiable_compiler_version(set_dependency)
test_unsatisfiable_version(set_dependency)
spack.test.spec_dag.saved_deps()

Returns a dictionary to save the dependencies.

spack.test.spec_dag.set_dependency(saved_deps)

Returns a function that alters the dependency information for a package.

spack.test.spec_semantics module

class spack.test.spec_semantics.TestSpecSematics

Bases: object

This tests satisfies(), constrain() and other semantic operations on specs.

pytestmark = [<MarkDecorator 'usefixtures' {'args': ('config', 'builtin_mock'), 'kwargs': {}}>]
test_constrain_architecture()
test_constrain_changed()
test_constrain_compiler()
test_constrain_compiler_flags()
test_constrain_dependency_changed()
test_constrain_dependency_not_changed()
test_constrain_multi_value_variant()
test_constrain_not_changed()
test_constrain_variants()
test_copy_satisfies_transitive()
test_dep_index()
test_exceptional_paths_for_constructor()
test_indirect_unsatisfied_single_valued_variant()
test_invalid_constraint()
test_satisfies()
test_satisfies_architecture()
test_satisfies_compiler()
test_satisfies_compiler_version()
test_satisfies_dependencies()
test_satisfies_dependency_versions()
test_satisfies_matching_compiler_flag()
test_satisfies_matching_variant()
test_satisfies_multi_value_variant()
test_satisfies_namespace()
test_satisfies_namespaced_dep()

Ensure spec from same or unspecified namespace satisfies namespace constraint.

test_satisfies_same_spec_with_different_hash()

Ensure that concrete specs are matched exactly by hash.

test_satisfies_single_valued_variant()

Tests that the case reported in https://github.com/LLNL/spack/pull/2386#issuecomment-282147639 is handled correctly.

test_satisfies_unconstrained_compiler_flag()
test_satisfies_unconstrained_variant()
test_satisfies_virtual()
test_satisfies_virtual_dep_with_virtual_constraint()

Ensure we can satisfy virtual constraints when there are multiple vdep providers in the specs.

test_satisfies_virtual_dependencies()
test_satisfies_virtual_dependency_versions()
test_self_index()
test_spec_contains_deps()
test_unsatisfiable_compiler_flag()
test_unsatisfiable_compiler_flag_mismatch()
test_unsatisfiable_multi_value_variant()
test_unsatisfiable_variant_mismatch()
test_unsatisfiable_variant_types()
test_unsatisfiable_variants()
test_unsatisfied_single_valued_variant()
test_virtual_index()
spack.test.spec_semantics.argument_factory(argument_spec, left)
spack.test.spec_semantics.check_constrain(expected, spec, constraint)
spack.test.spec_semantics.check_constrain_changed(spec, constraint)
spack.test.spec_semantics.check_constrain_not_changed(spec, constraint)
spack.test.spec_semantics.check_invalid_constraint(spec, constraint)
spack.test.spec_semantics.check_satisfies(target_spec, argument_spec, target_concrete=False)
spack.test.spec_semantics.check_unsatisfiable(target_spec, argument_spec, target_concrete=False)
spack.test.spec_semantics.target_factory(spec_string, target_concrete)

spack.test.spec_syntax module

class spack.test.spec_syntax.TestSpecSyntax

Bases: object

check_lex(tokens, spec)

Check that the provided spec parses to the provided token list.

check_parse(expected, spec=None, remove_arch=True)

Assert that the provided spec is able to be parsed.

If this is called with one argument, it assumes that the string is canonical (i.e., no spaces and ~ instead of - for variants) and that it will convert back to the string it came from.

If this is called with two arguments, the first argument is the expected canonical form and the second is a non-canonical input to be parsed.

test_ambiguous()
test_ambiguous_hash(database)
test_anonymous_specs()
test_anonymous_specs_with_multiple_parts()
test_canonicalize()
test_dep_spec_by_hash(database)
test_dependencies_with_versions()
test_duplicate_architecture()
test_duplicate_architecture_component()
test_duplicate_compiler()
test_duplicate_dependency()
test_duplicate_variant()
test_full_specs()
test_invalid_hash(database)
test_kv_with_quotes()
test_kv_with_spaces()
test_kv_without_quotes()
test_minimal_spaces()
test_multiple_specs()
test_multiple_specs_after_kv()
test_multiple_specs_long_second()
test_multiple_specs_with_hash(database)
test_nonexistent_hash(database)

Ensure we get errors for nonexistant hashes.

test_package_names()
test_parse_errors()
test_redundant_spec(database)

Check that redundant spec constraints raise errors.

TODO (TG): does this need to be an error? Or should concrete specs only raise errors if constraints cause a contradiction?

test_simple_dependence()
test_spaces_between_dependences()
test_spaces_between_options()
test_spec_by_hash(database)
test_way_too_many_spaces()
spack.test.spec_syntax.test_parse_anonymous_specs(spec, anon_spec, spec_name)

spack.test.spec_yaml module

Test YAML serialization for specs.

YAML format preserves DAG informatoin in the spec.

spack.test.spec_yaml.check_yaml_round_trip(spec)
spack.test.spec_yaml.reverse_all_dicts(data)

Descend into data and reverse all the dictionaries

spack.test.spec_yaml.test_ambiguous_version_spec(builtin_mock)
spack.test.spec_yaml.test_concrete_spec(config, builtin_mock)
spack.test.spec_yaml.test_external_spec(config, builtin_mock)
spack.test.spec_yaml.test_normal_spec(builtin_mock)
spack.test.spec_yaml.test_ordered_read_not_required_for_consistent_dag_hash(config, builtin_mock)

Make sure ordered serialization isn’t required to preserve hashes.

For consistent hashes, we require that YAML and json documents have their keys serialized in a deterministic order. However, we don’t want to require them to be serialized in order. This ensures that is not required.

spack.test.spec_yaml.test_simple_spec()
spack.test.spec_yaml.test_using_ordered_dict(builtin_mock)

Checks that dicts are ordered

Necessary to make sure that dag_hash is stable across python versions and processes.

spack.test.spec_yaml.test_yaml_multivalue()
spack.test.spec_yaml.test_yaml_subdag(config, builtin_mock)

spack.test.stage module

Test that the Stage class works correctly.

class spack.test.stage.TestStage

Bases: object

pytestmark = [<MarkDecorator 'usefixtures' {'args': ('builtin_mock',), 'kwargs': {}}>]
stage_name = 'spack-test-stage'
test_chdir(mock_archive)
test_expand_archive(mock_archive)
test_expand_archive_with_chdir(mock_archive)
test_fetch(mock_archive)
test_keep_exceptions(mock_archive)
test_keep_without_exceptions(mock_archive)
test_no_keep_with_exceptions(mock_archive)
test_no_keep_without_exceptions(mock_archive)
test_no_search_if_default_succeeds(mock_archive, failing_search_fn)
test_no_search_mirror_only(failing_fetch_strategy, failing_search_fn)
test_restage(mock_archive)
test_search_if_default_fails(failing_fetch_strategy, search_fn)
test_setup_and_destroy_name_with_tmp(mock_archive)
test_setup_and_destroy_name_without_tmp(mock_archive)
test_setup_and_destroy_no_name_with_tmp(mock_archive)
test_setup_and_destroy_no_name_without_tmp(mock_archive)
spack.test.stage.check_chdir(stage, stage_name)
spack.test.stage.check_chdir_to_source(stage, stage_name)
spack.test.stage.check_destroy(stage, stage_name)

Figure out whether a stage was destroyed correctly.

spack.test.stage.check_expand_archive(stage, stage_name, mock_archive)
spack.test.stage.check_fetch(stage, stage_name)
spack.test.stage.check_setup(stage, stage_name, archive)

Figure out whether a stage was set up correctly.

spack.test.stage.failing_fetch_strategy()

Returns a fetch strategy that fails.

spack.test.stage.failing_search_fn()

Returns a search function that fails! Always!

spack.test.stage.get_stage_path(stage, stage_name)

Figure out where a stage should be living. This depends on whether it’s named.

spack.test.stage.mock_archive(tmpdir, monkeypatch)

Creates a mock archive with the structure expected by the tests

spack.test.stage.search_fn()

Returns a search function that always succeeds.

spack.test.stage.tmpdir_for_stage(mock_archive)

Uses a temporary directory for staging

spack.test.svn_fetch module

spack.test.svn_fetch.test_fetch(type_of_test, secure, mock_svn_repository, config, refresh_builtin_mock)

Tries to:

  1. Fetch the repo using a fetch strategy constructed with supplied args (they depend on type_of_test).
  2. Check if the test_file is in the checked out repository.
  3. Assert that the repository is at the revision supplied.
  4. Add and remove some files, then reset the repo, and ensure it’s all there again.

spack.test.tengine module

class spack.test.tengine.TestContext

Bases: object

class A

Bases: spack.tengine.Context

context_properties = ['foo']
foo
class TestContext.B

Bases: spack.tengine.Context

bar
context_properties = ['bar']
class TestContext.C

Bases: spack.test.tengine.A, spack.test.tengine.B

context_properties = ['foobar', 'foo', 'bar']
foo
foobar
TestContext.test_to_dict()

Tests that all the context properties in a hierarchy are considered when building the context dictionary.

class spack.test.tengine.TestTengineEnvironment

Bases: object

pytestmark = [<MarkDecorator 'usefixtures' {'args': ('config',), 'kwargs': {}}>]
test_template_retrieval()

Tests the template retrieval mechanism hooked into config files

spack.test.url_fetch module

spack.test.url_fetch.checksum_type(request)
spack.test.url_fetch.test_fetch(mock_archive, secure, checksum_type, config, refresh_builtin_mock)

Fetch an archive and make sure we can checksum it.

spack.test.url_fetch.test_hash_detection(checksum_type)
spack.test.url_fetch.test_unknown_hash(checksum_type)

spack.test.url_parse module

Tests Spack’s ability to parse the name and version of a package based on its URL.

spack.test.url_parse.test_no_version(not_detectable_url)
spack.test.url_parse.test_url_parse_name_and_version(name, version, url)
spack.test.url_parse.test_url_parse_offset(name, noffset, ver, voffset, path)

Tests that the name, version and offsets are computed correctly.

Parameters:
  • name (str) – expected name
  • noffset (int) – name offset
  • ver (str) – expected version
  • voffset (int) – version offset
  • path (str) – url to be parsed
spack.test.url_parse.test_url_strip_name_suffixes(url, version, expected)
spack.test.url_parse.test_url_strip_version_suffixes(url, expected)

spack.test.url_substitution module

Tests Spack’s ability to substitute a different version into a URL.

spack.test.url_substitution.test_url_substitution(base_url, version, expected)

spack.test.variant module

class spack.test.variant.TestBoolValuedVariant

Bases: object

test_compatible()
test_constrain()
test_initialization()
test_satisfies()
test_yaml_entry()
class spack.test.variant.TestMultiValuedVariant

Bases: object

test_compatible()
test_constrain()
test_initialization()
test_satisfies()
test_yaml_entry()
class spack.test.variant.TestSingleValuedVariant

Bases: object

test_compatible()
test_constrain()
test_initialization()
test_satisfies()
test_yaml_entry()
class spack.test.variant.TestVariant

Bases: object

test_callable_validator()
test_representation()
test_validation()
class spack.test.variant.TestVariantMapTest

Bases: object

test_copy()
test_invalid_values()
test_satisfies_and_constrain()
test_set_item()
test_str()
test_substitute()
spack.test.variant.test_from_node_dict()

spack.test.versions module

These version tests were taken from the RPM source code. We try to maintain compatibility with RPM’s version semantics where it makes sense.

spack.test.versions.assert_canonical(canonical_list, version_list)

Asserts that a redundant list is reduced to canonical form.

spack.test.versions.assert_does_not_satisfy(v1, v2)

Asserts that ‘v1’ does not satisfy ‘v2’.

spack.test.versions.assert_in(needle, haystack)

Asserts that ‘needle’ is in ‘haystack’.

spack.test.versions.assert_no_overlap(v1, v2)

Asserts that two version ranges do not overlap.

spack.test.versions.assert_not_in(needle, haystack)

Asserts that ‘needle’ is not in ‘haystack’.

spack.test.versions.assert_overlaps(v1, v2)

Asserts that two version ranges overlaps.

spack.test.versions.assert_satisfies(v1, v2)

Asserts that ‘v1’ satisfies ‘v2’.

spack.test.versions.assert_ver_eq(a, b)

Asserts the results of comparisons when ‘a’ is equal to ‘b’.

spack.test.versions.assert_ver_gt(a, b)

Asserts the results of comparisons when ‘a’ is greater than ‘b’.

spack.test.versions.assert_ver_lt(a, b)

Asserts the results of comparisons when ‘a’ is less than ‘b’.

spack.test.versions.check_intersection(expected, a, b)

Asserts that ‘a’ intersect ‘b’ == ‘expected’.

spack.test.versions.check_union(expected, a, b)

Asserts that ‘a’ union ‘b’ == ‘expected’.

spack.test.versions.test_alpha()
spack.test.versions.test_alpha_beta()
spack.test.versions.test_alpha_with_dots()
spack.test.versions.test_basic_version_satisfaction()
spack.test.versions.test_basic_version_satisfaction_in_lists()
spack.test.versions.test_canonicalize_list()
spack.test.versions.test_close_numbers()
spack.test.versions.test_contains()
spack.test.versions.test_date_stamps()
spack.test.versions.test_double_alpha()
spack.test.versions.test_formatted_strings()
spack.test.versions.test_get_item()
spack.test.versions.test_in_list()
spack.test.versions.test_intersect_with_containment()
spack.test.versions.test_intersection()
spack.test.versions.test_lists_overlap()
spack.test.versions.test_num_alpha_with_no_separator()
spack.test.versions.test_nums_and_patch()
spack.test.versions.test_overlap_with_containment()
spack.test.versions.test_padded_numbers()
spack.test.versions.test_patch()
spack.test.versions.test_ranges_overlap()
spack.test.versions.test_rc_versions()
spack.test.versions.test_repr_and_str()
spack.test.versions.test_rpm_oddities()
spack.test.versions.test_satisfaction_with_lists()
spack.test.versions.test_three_segments()
spack.test.versions.test_two_segments()
spack.test.versions.test_underscores()
spack.test.versions.test_union_with_containment()
spack.test.versions.test_up_to()
spack.test.versions.test_version_range_satisfaction()
spack.test.versions.test_version_range_satisfaction_in_lists()
spack.test.versions.test_version_ranges()

spack.test.web module

Tests for web.py.

spack.test.web.test_find_exotic_versions_of_archive_2()
spack.test.web.test_find_exotic_versions_of_archive_3()
spack.test.web.test_find_versions_of_archive_0()
spack.test.web.test_find_versions_of_archive_1()
spack.test.web.test_find_versions_of_archive_2()
spack.test.web.test_find_versions_of_archive_3()
spack.test.web.test_spider_0()
spack.test.web.test_spider_1()
spack.test.web.test_spider_2()
spack.test.web.test_spider_3()

Module contents