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_environment module

spack.test.build_environment.build_environment()
spack.test.build_environment.test_static_to_shared_library(build_environment)

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.compilers.test_compiler_flags_from_config_are_grouped()

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_flags_from_user_are_grouped()
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

class spack.test.conftest.MockPackage(name, dependencies, dependency_types, conditions=None, versions=None)

Bases: object

class spack.test.conftest.MockPackageMultiRepo(packages)

Bases: object

exists(name)
get(spec)
get_pkg_class(name)
is_virtual(name)
repo_for_pkg(name)
spack.test.conftest.builtin_mock(repo_path)

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

spack.test.conftest.check_for_leftover_stage_files(request, mock_stage, _ignore_stage_files)

Ensure that each test leaves a clean stage when done.

This can be disabled for tests that are expected to dirty the stage by adding:

@pytest.mark.disable_clean_stage_check

to tests that need it.

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, DB, and stage directory into Spack.

spack.test.conftest.linux_os()

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

spack.test.conftest.mock_archive(tmpdir_factory)

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(tmpdir_factory)

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

spack.test.conftest.mock_hg_repository(tmpdir_factory)

Creates a very simple hg repository with two commits.

spack.test.conftest.mock_stage(tmpdir_factory)

Mocks up a fake stage directory for use by tests.

spack.test.conftest.mock_svn_repository(tmpdir_factory)

Creates a very simple svn repository with two commits.

spack.test.conftest.no_chdir()

Ensure that no test changes Spack’s working dirctory.

This prevents Spack tests (and therefore Spack commands) from changing the working directory and causing other tests to fail mysteriously. Tests should use working_dir or py.path’s .as_cwd() instead of os.chdir to avoid failing this check.

We assert that the working directory hasn’t changed, unless the original wd somehow ceased to exist.

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.remove_whatever_it_is(path)

Type-agnostic remove.

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_115_reindex_with_packages_not_in_repo(database, refresh_db_on_exit)
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_exclude_paths_from_inspection()
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.flag_handlers module

class spack.test.flag_handlers.TestFlagHandlers

Bases: object

pytestmark = [<MarkDecorator 'usefixtures' {'args': ('config',), 'kwargs': {}}>]
test_add_build_system_flags_autotools(temp_env)
test_add_build_system_flags_cmake(temp_env)
test_build_system_flags_autotools(temp_env)
test_build_system_flags_cmake(temp_env)
test_build_system_flags_not_implemented(temp_env)
test_env_flags(temp_env)
test_inject_flags(temp_env)
test_ld_flags_cmake(temp_env)
test_ld_libs_cmake(temp_env)
test_no_build_system_flags(temp_env)
test_unbound_method(temp_env)
spack.test.flag_handlers.add_O3_to_build_system_cflags(pkg, name, flags)
spack.test.flag_handlers.temp_env()

spack.test.git_fetch module

spack.test.git_fetch.git_version(request)

Tests GitFetchStrategy behavior for different git versions.

GitFetchStrategy tries to optimize using features of newer git versions, but needs to work with older git versions. To ensure code paths for old versions still work, we fake it out here and make it use the backward-compatibility code paths with newer git versions.

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

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

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

Bases: object

remove_prefix()
spack.test.install.mock_remove_prefix(*args)
spack.test.install.test_dont_add_patches_to_installed_package(install_mockery, mock_fetch)
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_installed_dependency_request_conflicts(install_mockery, mock_fetch, refresh_builtin_mock)
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.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_elf_paths()
spack.test.packaging.test_macho_paths()
spack.test.packaging.test_needs_relocation()
spack.test.packaging.test_packaging(mock_archive, tmpdir)
spack.test.packaging.test_relocate_macho(tmpdir)
spack.test.packaging.test_relocate_text()
spack.test.packaging.testing_gpg_directory(tmpdir)

spack.test.patch module

spack.test.patch.mock_stage(tmpdir, monkeypatch)
spack.test.patch.test_conditional_patched_dependencies(builtin_mock, config)

Test whether conditional patched dependencies work.

spack.test.patch.test_conditional_patched_deps_with_conditions(builtin_mock, config)

Test whether conditional patched dependencies with conditions work.

spack.test.patch.test_multiple_patched_dependencies(builtin_mock, config)

Test whether multiple patched dependencies work.

spack.test.patch.test_patch_in_spec(builtin_mock, config)

Test whether patches in a package appear in the spec.

spack.test.patch.test_patched_dependency(builtin_mock, config)

Test whether patched dependencies work.

spack.test.patch.test_url_patch(mock_stage, filename, sha256, archive_sha256)

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.repo module

spack.test.repo.extra_repo(tmpdir_factory)
spack.test.repo.repo_for_test()
spack.test.repo.test_repo_getpkg(repo_for_test)
spack.test.repo.test_repo_multi_getpkg(repo_for_test, extra_repo)
spack.test.repo.test_repo_multi_getpkgclass(repo_for_test, extra_repo)
spack.test.repo.test_repo_pkg_with_unknown_namespace(repo_for_test)
spack.test.repo.test_repo_unknown_pkg(repo_for_test)

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 in the saved_deps fixture.

spack.test.spec_dag.test_test_deptype()

Ensure that test-only dependencies are only included for specified packages in the following spec DAG:

  w
 /|
x y
  |
  z

w->y deptypes are (link, build), w->x and y->z deptypes are (test)

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/spack/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 information 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_expand_archive(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_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 B

Bases: spack.tengine.Context

bar
context_properties = ['bar']
class C

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

context_properties = ['foobar', 'foo', 'bar']
foo
foobar
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.test_activations module

class spack.test.test_activations.FakeExtensionPackage(name, prefix)

Bases: object

class spack.test.test_activations.FakeSpec(package)

Bases: object

dag_hash()
spack.test.test_activations.create_dir_structure(tmpdir, dir_structure)
spack.test.test_activations.perl_and_extension_dirs(tmpdir)
spack.test.test_activations.python_and_extension_dirs(tmpdir)
spack.test.test_activations.test_perl_activation(tmpdir)
spack.test.test_activations.test_perl_activation_view(tmpdir, perl_and_extension_dirs)
spack.test.test_activations.test_perl_activation_with_files(tmpdir, perl_and_extension_dirs)
spack.test.test_activations.test_python_activation(tmpdir)
spack.test.test_activations.test_python_activation_view(tmpdir, python_and_extension_dirs)
spack.test.test_activations.test_python_activation_with_files(tmpdir, python_and_extension_dirs)

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_from_list_url(builtin_mock, config)
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