spack.test package

Subpackages

Submodules

spack.test.abi module

Test ABI compatibility helpers

spack.test.abi.test_architecture_compatibility(target, constraint, expected)
spack.test.abi.test_compatibility(target, constraint, loose, expected)
spack.test.abi.test_compiler_compatibility(target, constraint, loose, expected)

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_arch_spec_container_semantic(item, architecture_str)
spack.test.architecture.test_boolness()
spack.test.architecture.test_dict_functions_for_architecture()
spack.test.architecture.test_operating_system_conversion_to_dict()
spack.test.architecture.test_optimization_flags(compiler_spec, target_name, expected_flags, config)
spack.test.architecture.test_optimization_flags_with_custom_versions(compiler, real_version, target_str, expected_flags, monkeypatch, config)
spack.test.architecture.test_platform()
spack.test.architecture.test_satisfy_strict_constraint_when_not_concrete(architecture_tuple, constraint_tuple)
spack.test.architecture.test_target_container_semantic(cpu_flag, target_name)
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, operating_system, target)

spack.test.bindist module

This test checks creating and install buildcaches

spack.test.bindist.cache_directory(tmpdir)
spack.test.bindist.config_directory(tmpdir_factory)
spack.test.bindist.default_config(tmpdir_factory, config_directory, monkeypatch)
spack.test.bindist.install_dir_default_layout(tmpdir)

Hooks a fake install directory with a default layout

spack.test.bindist.install_dir_non_default_layout(tmpdir)

Hooks a fake install directory with a non-default layout

spack.test.bindist.mirror_directory_def(session_mirror_def)
spack.test.bindist.mirror_directory_rel(session_mirror_rel)
spack.test.bindist.session_mirror_def(tmpdir_factory)
spack.test.bindist.session_mirror_rel(tmpdir_factory)
spack.test.bindist.test_built_spec_cache(tmpdir, install_mockery)

Because the buildcache list command fetches the buildcache index and uses it to populate the binary_distribution built spec cache, when this test calls get_mirrors_for_spec, it is testing the popluation of that cache from a buildcache index.

spack.test.bindist.test_default_rpaths_create_install_default_layout(tmpdir, mirror_directory_def, install_mockery)

Test the creation and installation of buildcaches with default rpaths into the default directory layout scheme.

spack.test.bindist.test_default_rpaths_install_nondefault_layout(tmpdir, install_mockery)

Test the creation and installation of buildcaches with default rpaths into the non-default directory layout scheme.

spack.test.bindist.test_push_and_fetch_keys(mock_gnupghome)
spack.test.bindist.test_relative_rpaths_create_default_layout(tmpdir, mirror_directory_rel, install_mockery)

Test the creation and installation of buildcaches with relative rpaths into the default directory layout scheme.

spack.test.bindist.test_relative_rpaths_install_default_layout(tmpdir, install_mockery)

Test the creation and installation of buildcaches with relative rpaths into the default directory layout scheme.

spack.test.bindist.test_relative_rpaths_install_nondefault(tmpdir, install_mockery)

Test the installation of buildcaches with relativized rpaths into the non-default directory layout scheme.

spack.test.bindist.test_spec_needs_rebuild(install_mockery_mutable_config, mock_packages, mock_fetch, monkeypatch, tmpdir)

Make sure needs_rebuild properly compares remote full_hash against locally computed one, avoiding unnecessary rebuilds

spack.test.build_distribution module

spack.test.build_distribution.test_build_tarball_overwrite(install_mockery, mock_fetch, monkeypatch, tmpdir)

spack.test.build_environment module

spack.test.build_environment.build_environment(working_env)
spack.test.build_environment.ensure_env_variables(config, mock_packages, monkeypatch, working_env)

Returns a function that takes a dictionary and updates os.environ for the test lifetime accordingly. Plugs-in mock config and repo.

spack.test.build_environment.test_cc_not_changed_by_modules(monkeypatch, working_env)
spack.test.build_environment.test_compiler_config_modifications(initial, modifications, expected, ensure_env_variables, monkeypatch)
spack.test.build_environment.test_package_inheritance_module_setup(config, mock_packages, working_env)
spack.test.build_environment.test_parallel_false_is_not_propagating(config, mock_packages)
spack.test.build_environment.test_set_build_environment_variables(config, mock_packages, working_env, monkeypatch, installation_dir_with_headers)

Check that build_environment supplies the needed library/include directories via the SPACK_LINK_DIRS and SPACK_INCLUDE_DIRS environment variables.

spack.test.build_environment.test_setting_dtags_based_on_config(config_setting, expected_flag, config, mock_packages)
spack.test.build_environment.test_spack_paths_before_module_paths(config, mock_packages, monkeypatch, working_env)
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 = [Mark(name='usefixtures', args=('config', 'mock_packages'), kwargs={})]
test_libtool_archive_files_are_deleted_by_default(mutable_database)
test_libtool_archive_files_might_be_installed_on_demand(mutable_database, monkeypatch)
test_none_is_allowed()
test_with_or_without()
class spack.test.build_systems.TestCMakePackage

Bases: object

pytestmark = [Mark(name='usefixtures', args=('config', 'mock_packages'), kwargs={})]
test_define()
test_define_from_variant()
class spack.test.build_systems.TestGNUMirrorPackage

Bases: object

pytestmark = [Mark(name='usefixtures', args=('config', 'mock_packages'), kwargs={})]
test_define()
class spack.test.build_systems.TestSourceforgePackage

Bases: object

pytestmark = [Mark(name='usefixtures', args=('config', 'mock_packages'), kwargs={})]
test_define()
class spack.test.build_systems.TestSourcewarePackage

Bases: object

pytestmark = [Mark(name='usefixtures', args=('config', 'mock_packages'), kwargs={})]
test_define()
class spack.test.build_systems.TestXorgPackage

Bases: object

pytestmark = [Mark(name='usefixtures', args=('config', 'mock_packages'), kwargs={})]
test_define()
spack.test.build_systems.test_affirmative_make_check(directory, config, mock_packages, working_env)

Tests that Spack correctly detects targets in a Makefile.

spack.test.build_systems.test_affirmative_ninja_check(directory, config, mock_packages, working_env)

Tests that Spack correctly detects targets in a Ninja build script.

spack.test.build_systems.test_cmake_bad_generator(config, mock_packages)
spack.test.build_systems.test_cmake_secondary_generator(config, mock_packages)
spack.test.build_systems.test_cmake_std_args(config, mock_packages)
spack.test.build_systems.test_negative_make_check(directory, config, mock_packages, working_env)

Tests that Spack correctly ignores false positives in a Makefile.

spack.test.build_systems.test_negative_ninja_check(directory, config, mock_packages, working_env)

Tests that Spack correctly ignores false positives in a Ninja build script.

spack.test.buildtask module

spack.test.buildtask.test_build_task_basics(install_mockery)
spack.test.buildtask.test_build_task_errors(install_mockery)
spack.test.buildtask.test_build_task_strings(install_mockery)

Tests of build_task repr and str for coverage purposes.

spack.test.cache_fetch module

spack.test.cache_fetch.test_fetch(tmpdir)

Ensure a fetch after expanding is effectively a no-op.

spack.test.cache_fetch.test_fetch_missing_cache(tmpdir)

Ensure raise a missing cache file.

spack.test.cc module

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

spack.test.cc.check_args(cc, args, expected)

Check output arguments that cc produces when called with args.

This assumes that cc will print debug command output with one element per line, so that we see whether arguments that should (or shouldn’t) contain spaces are parsed correctly.

spack.test.cc.dump_mode(cc, args)

Make cc dump the mode it detects, and return it.

spack.test.cc.pkg_prefix = '/spack-test-prefix'

The prefix of the package being mock installed

spack.test.cc.real_cc = '/bin/mycc'

the “real” compiler the wrapper is expected to invoke

spack.test.cc.test_as_mode()
spack.test.cc.test_cc_deps()

Ensure -L and RPATHs are not added in cc mode.

spack.test.cc.test_cc_flags(wrapper_flags)
spack.test.cc.test_ccache_prepend_for_cc()
spack.test.cc.test_ccld_deps()

Ensure all flags are added in ccld mode.

spack.test.cc.test_ccld_deps_isystem()

Ensure all flags are added in ccld mode. When a build uses -isystem, Spack should inject it’s include paths using -isystem. Spack will insert these after any provided -isystem includes, but before any system directories included using -isystem

spack.test.cc.test_ccld_mode()
spack.test.cc.test_ccld_with_system_dirs()

Ensure all flags are added in ccld mode.

spack.test.cc.test_ccld_with_system_dirs_isystem()

Ensure all flags are added in ccld mode. Ensure that includes are in the proper place when a build uses -isystem, and uses system directories in the include paths

spack.test.cc.test_cpp_flags(wrapper_flags)
spack.test.cc.test_cpp_mode()
spack.test.cc.test_cxx_flags(wrapper_flags)
spack.test.cc.test_dep_include()

Ensure a single dependency include directory is added.

spack.test.cc.test_dep_lib()

Ensure a single dependency RPATH is added.

spack.test.cc.test_dep_lib_no_lib()

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

spack.test.cc.test_dep_lib_no_rpath()

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

spack.test.cc.test_dep_rpath()

Ensure RPATHs for root package are added.

spack.test.cc.test_disable_new_dtags(wrapper_flags)
spack.test.cc.test_fc_flags(wrapper_flags)
spack.test.cc.test_filter_enable_new_dtags(wrapper_flags)
spack.test.cc.test_ld_deps()

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

Ensure SPACK_RPATH_DEPS controls -rpath for ld.

spack.test.cc.test_ld_deps_no_rpath()

Ensure SPACK_LINK_DEPS controls -L for ld.

spack.test.cc.test_ld_deps_partial()

Make sure ld -r (partial link) is handled correctly on OS’s where it doesn’t accept rpaths.

spack.test.cc.test_ld_flags(wrapper_flags)
spack.test.cc.test_ld_mode()
spack.test.cc.test_no_ccache_prepend_for_fc()
spack.test.cc.test_vcheck_mode()
spack.test.cc.wrapper_environment()
spack.test.cc.wrapper_flags()

spack.test.ci module

spack.test.ci.test_ci_workarounds()
spack.test.ci.test_configure_compilers(mutable_config)
spack.test.ci.test_get_concrete_specs(config, mock_packages)
spack.test.ci.test_import_signing_key(mock_gnupghome)
spack.test.ci.test_read_write_cdash_ids(config, tmp_scope, tmpdir, mock_packages)
spack.test.ci.test_register_cdash_build()
spack.test.ci.test_relate_cdash_builds(config, mock_packages)
spack.test.ci.test_urlencode_string()
spack.test.ci.tmp_scope()

Creates a temporary configuration scope

spack.test.cmd_extensions module

class spack.test.cmd_extensions.Extension(name, root)

Bases: object

Helper class to simplify the creation of simple command extension directory structures with a conventional format for testing.

add_command(command_name, contents)

Add a command to this command extension.

Parameters:
  • command_name (str) – The name of the command.
  • contents (str) – the desired contents of the new command module file.
spack.test.cmd_extensions.extension_creator(tmpdir, config)

Create a basic extension command directory structure

spack.test.cmd_extensions.hello_world_cmd(hello_world_extension)

Create and return an invokable “hello-world” extension command.

spack.test.cmd_extensions.hello_world_extension(extension_creator)

Create an extension with a hello-world command.

spack.test.cmd_extensions.hello_world_with_module_in_root(extension_creator)

Create a “hello-world” extension command with additional code in the root folder.

spack.test.cmd_extensions.test_command_with_import(extension_name, hello_world_with_module_in_root)

Ensure we can write a functioning command with multiple imported subcommands, including where the extension name contains a hyphen.

spack.test.cmd_extensions.test_duplicate_module_load(hello_world_cmd, capsys)

Ensure duplicate module load attempts are successful.

The command module will already have been loaded once by the hello_world_cmd fixture.

spack.test.cmd_extensions.test_extension_naming(extension_path, expected_exception, config)

Ensure that we are correctly validating configured extension paths for conformity with the rules: the basename should match spack-<name>; <name> may have embedded hyphens but not begin with one.

spack.test.cmd_extensions.test_failing_command(command_name, contents, exception, extension_creator)

Ensure that the configured command fails to import with the specified error.

spack.test.cmd_extensions.test_get_command_paths(config)

Exercise the construction of extension command search paths.

spack.test.cmd_extensions.test_missing_command()

Ensure that we raise the expected exception if the desired command is not present.

spack.test.cmd_extensions.test_missing_command_function(extension_creator, capsys)

Ensure we die as expected if a command module does not have the expected command function defined.

Ensure we can find an extension command even if it’s not in the first place we look.

spack.test.cmd_extensions.test_simple_command_extension(hello_world_cmd)

Basic test of a functioning command.

spack.test.concretize module

class spack.test.concretize.TestConcretize

Bases: object

concretize_difficult_packages(a, b)

Test a couple of large packages that are often broken due to current limitations in the concretizer

concretize_multi_provider()
pytestmark = [Mark(name='usefixtures', args=('mutable_config', 'mock_packages'), kwargs={})]
test_adjusting_default_target_based_on_compiler(spec, best_achievable, current_host)
test_architecture_deep_inheritance()

Make sure that indirect dependencies receive architecture information from the root even when partial architecture information is provided by an intermediate dependency.

test_architecture_inheritance()

test_architecture_inheritance is likely to fail with an UnavailableCompilerVersionError if the architecture is concretized incorrectly.

test_compiler_child()
test_compiler_flags_from_user_are_grouped()
test_compiler_inheritance()
test_compiler_version_matches_any_entry_in_compilers_yaml()
test_concretize(spec)
test_concretize_anonymous()
test_concretize_anonymous_dep()
test_concretize_enable_disable_compiler_existence_check()
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(mutable_mock_repo)

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_conflixt_in_external_specs(conflict_spec)
test_no_matching_compiler_specs(mock_low_high_config)
test_nobuild_package()
test_noversion_pkg(spec)

Test concretization failures for no-version packages.

test_provides_handles_multiple_providers_of_same_version()
test_regression_issue_4492()
test_regression_issue_7239()
test_regression_issue_7705()
test_regression_issue_7941()
test_simultaneous_concretization_of_specs(abstract_specs)
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.current_host(request, monkeypatch)
spack.test.concretize.spec(request)

Spec to be concretized

spack.test.concretize_preferences module

class spack.test.concretize_preferences.TestConcretizePreferences

Bases: object

pytestmark = [Mark(name='usefixtures', args=('concretize_scope', 'mock_packages'), kwargs={})]
test_buildable_false()
test_buildable_false_all()
test_buildable_false_all_true_package()
test_buildable_false_all_true_virtual()
test_buildable_false_virtual()
test_config_permissions_differ_read_write(configure_permissions)
test_config_permissions_from_all(configure_permissions)
test_config_permissions_from_package(configure_permissions)
test_config_perms_fail_write_gt_read(configure_permissions)
test_develop()

Test concretization with develop-like versions

test_external_module(monkeypatch)

Test that packages can find externals specified by module

The specific code for parsing the module is tested elsewhere. This just tests that the preference is accounted for

test_external_mpi()
test_preferred()

“Test packages with some version marked as preferred=True

test_preferred_compilers()

Test preferred compilers are applied correctly

test_preferred_providers()

Test preferred providers of virtual packages are applied correctly

test_preferred_target(mutable_mock_repo)

Test preferred compilers are applied correctly

test_preferred_variants()

Test preferred variants are applied correctly

test_preferred_variants_from_wildcard()

Test that ‘foo=*’ concretizes to any value

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(mutable_config, tmpdir)

Adds a scope for concretization preferences

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

Update config and reread package list

spack.test.config module

spack.test.config.check_compiler_config(comps, *compiler_names)

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

spack.test.config.check_schema(name, file_contents)

Check a Spack YAML schema against some data

spack.test.config.compiler_specs()

Returns a couple of compiler specs needed for the tests

spack.test.config.get_config_error(filename, schema, yaml_string)

Parse a YAML string and return the resulting ConfigFormatError.

Fail if there is no ConfigFormatError

spack.test.config.test_add_command_line_scopes(tmpdir, mutable_config)
spack.test.config.test_alternate_override(monkeypatch)

Ensure proper scope naming of override when conflict present.

spack.test.config.test_bad_command_line_scopes(tmpdir, mock_low_high_config)
spack.test.config.test_bad_compilers_yaml(tmpdir)
spack.test.config.test_bad_config_section(mock_low_high_config)

Test that getting or setting a bad section gives an error.

spack.test.config.test_bad_config_yaml(tmpdir)
spack.test.config.test_bad_env_yaml(tmpdir)
spack.test.config.test_bad_mirrors_yaml(tmpdir)
spack.test.config.test_bad_path_double_override(config)
spack.test.config.test_bad_repos_yaml(tmpdir)
spack.test.config.test_config_format_error(mutable_config)

This is raised when we try to write a bad configuration.

spack.test.config.test_config_parse_dict_in_list(tmpdir)
spack.test.config.test_config_parse_list_in_dict(tmpdir)
spack.test.config.test_config_parse_str_not_bool(tmpdir)
spack.test.config.test_dotkit_in_config_does_not_raise(mock_low_high_config, write_config_file, capsys)
spack.test.config.test_good_env_yaml(tmpdir)
spack.test.config.test_immutable_scope(tmpdir)
spack.test.config.test_internal_config_dict_override(mock_low_high_config, write_config_file)
spack.test.config.test_internal_config_filename(mock_low_high_config, write_config_file)
spack.test.config.test_internal_config_from_data()
spack.test.config.test_internal_config_list_override(mock_low_high_config, write_config_file)
spack.test.config.test_internal_config_section_override(mock_low_high_config, write_config_file)
spack.test.config.test_internal_config_update(mock_low_high_config, write_config_file)
spack.test.config.test_keys_are_ordered()

Test that keys in Spack YAML files retain their order from the file.

spack.test.config.test_list_merge_order()

“Test that source lists are prepended to dest.

spack.test.config.test_mark_internal()
spack.test.config.test_merge_with_defaults(mock_low_high_config, write_config_file)

This ensures that specified preferences merge with defaults as expected. Originally all defaults were initialized with the exact same object, which led to aliasing problems. Therefore the test configs used here leave ‘version’ blank for multiple packages in ‘packages_merge_low’.

spack.test.config.test_nested_override()

Ensure proper scope naming of nested overrides.

spack.test.config.test_ordereddict_merge_order()

“Test that source keys come before dest keys in merge_yaml results.

spack.test.config.test_read_config(mock_low_high_config, write_config_file)
spack.test.config.test_read_config_merge_list(mock_low_high_config, write_config_file)
spack.test.config.test_read_config_override_all(mock_low_high_config, write_config_file)
spack.test.config.test_read_config_override_key(mock_low_high_config, write_config_file)
spack.test.config.test_read_config_override_list(mock_low_high_config, write_config_file)
spack.test.config.test_set_bad_path(config)
spack.test.config.test_set_dict_override(mock_low_high_config, write_config_file)
spack.test.config.test_set_list_override(mock_low_high_config, write_config_file)
spack.test.config.test_set_section_override(mock_low_high_config, write_config_file)
spack.test.config.test_single_file_scope(tmpdir, config)
spack.test.config.test_single_file_scope_section_override(tmpdir, config)

Check that individual config sections can be overridden in an environment config. The config here primarily differs in that the packages section is intended to override all other scopes (using the “::” syntax).

spack.test.config.test_substitute_config_variables(mock_low_high_config)
spack.test.config.test_substitute_padding(mock_low_high_config)
spack.test.config.test_substitute_tempdir(mock_low_high_config)
spack.test.config.test_substitute_user(mock_low_high_config)
spack.test.config.test_write_empty_single_file_scope(tmpdir)
spack.test.config.test_write_key_in_memory(mock_low_high_config, compiler_specs)
spack.test.config.test_write_key_to_disk(mock_low_high_config, compiler_specs)
spack.test.config.test_write_list_in_memory(mock_low_high_config)
spack.test.config.test_write_to_same_priority_file(mock_low_high_config, compiler_specs)
spack.test.config.write_config_file(tmpdir)

Returns a function that writes a config file.

spack.test.config_values module

spack.test.config_values.test_set_install_hash_length(mock_packages, mutable_config, monkeypatch, tmpdir)
spack.test.config_values.test_set_install_hash_length_upper_case(mock_packages, mutable_config, monkeypatch, tmpdir)

spack.test.conftest module

class spack.test.conftest.MockBundle

Bases: object

has_code = False
name = 'mock-bundle'
versions = {}
class spack.test.conftest.MockLayout(root)

Bases: object

check_installed(spec)
path_for_spec(spec)
spack.test.conftest.check_for_leftover_stage_files(request, mock_stage, ignore_stage_files)

Ensure that each (mock_stage) test leaves a clean stage when done.

Tests that are expected to dirty the stage can disable the check by adding:

@pytest.mark.disable_clean_stage_check

and the associated stage files will be removed.

spack.test.conftest.clean_user_environment()
spack.test.conftest.clear_directive_functions()

Clear all overidden directive functions for subsequent tests.

spack.test.conftest.config(mock_configuration)

This fixture activates/deactivates the mock configuration.

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

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

spack.test.conftest.conflict_spec(request)

Specs which violate constraints specified with the “conflicts” directive in the “conflict” package.

spack.test.conftest.database(mock_store, mock_packages, config)

This activates the mock store, packages, AND config.

spack.test.conftest.default_config()

Isolates the default configuration from the user configs.

This ensures we can test the real default configuration without having tests fail when the user overrides the defaults that we test against.

spack.test.conftest.dirs_with_libfiles(tmpdir_factory)
spack.test.conftest.disable_compiler_execution(monkeypatch, request)

This fixture can be disabled for tests of the compiler link path functionality by:

@pytest.mark.enable_compiler_link_paths

If a test is marked in that way this is a no-op.

spack.test.conftest.gen_mock_layout(tmpdir)
spack.test.conftest.ignore_stage_files()

Session-scoped helper for check_for_leftover_stage_files.

Used to track which leftover files in the stage have been seen.

spack.test.conftest.install_mockery(tmpdir, config, mock_packages, monkeypatch)

Hooks a fake install directory, DB, and stage directory into Spack.

spack.test.conftest.install_mockery_mutable_config(tmpdir, mutable_config, mock_packages, monkeypatch)

Hooks a fake install directory, DB, and stage directory into Spack.

This is specifically for tests which want to use ‘install_mockery’ but also need to modify configuration (and hence would want to use ‘mutable config’): ‘install_mockery’ does not support this.

spack.test.conftest.installation_dir_with_headers(tmpdir_factory)

Mock installation tree with a few headers placed in different subdirectories. Shouldn’t be modified by tests as it is session scoped.

spack.test.conftest.invalid_spec(request)

Specs that do not parse cleanly due to invalid formatting.

spack.test.conftest.linux_os()

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

spack.test.conftest.mock_archive(request, 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_compiler_executable_verification(request, monkeypatch)

Mock the compiler executable verification to allow missing executables.

This fixture can be disabled for tests of the compiler verification functionality by:

@pytest.mark.enable_compiler_verification

If a test is marked in that way this is a no-op.

spack.test.conftest.mock_configuration(configuration_dir)

Create a persistent Configuration object from the configuration_dir.

spack.test.conftest.mock_directive_bundle()

Return a mock bundle package for directive tests.

spack.test.conftest.mock_executable(tmpdir)

Factory to create a mock executable in a temporary directory that output a custom string when run.

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.paths.fetch_cache with a mock object that does nothing and raises on fetch.

spack.test.conftest.mock_git_repository(tmpdir_factory)

Creates a simple git repository with two branches, two commits and two submodules. Each submodule has one commit.

spack.test.conftest.mock_gnupghome(monkeypatch)
spack.test.conftest.mock_hg_repository(tmpdir_factory)

Creates a very simple hg repository with two commits.

spack.test.conftest.mock_low_high_config(tmpdir)

Mocks two configuration scopes: ‘low’ and ‘high’.

spack.test.conftest.mock_packages(mock_repo_path, mock_pkg_install)

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

spack.test.conftest.mock_pkg_install(monkeypatch)
spack.test.conftest.mock_repo_path()
spack.test.conftest.mock_stage(tmpdir_factory, monkeypatch, request)

Establish the temporary build_stage for the mock archive.

spack.test.conftest.mock_store(tmpdir_factory, mock_repo_path, mock_configuration, _store_dir_and_cache)

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

This does not actually activate the store for use by Spack – see the database fixture for that.

spack.test.conftest.mock_svn_repository(tmpdir_factory)

Creates a very simple svn repository with two commits.

spack.test.conftest.mock_test_repo(tmpdir_factory)

Create an empty repository.

spack.test.conftest.module_configuration(monkeypatch, request)

Reads the module configuration file from the mock ones prepared for tests and monkeypatches the right classes to hook it in.

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

Like config, but tests can modify the configuration.

spack.test.conftest.mutable_database(database, _store_dir_and_cache)

Writeable version of the fixture, restored to its initial state after each test.

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

Empty configuration that can be modified by the tests.

spack.test.conftest.mutable_mock_env_path(tmpdir_factory)

Fixture for mocking the internal spack environments directory.

spack.test.conftest.mutable_mock_repo(mock_repo_path)

Function-scoped mock packages, for tests that need to modify them.

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.no_path_access(monkeypatch)
spack.test.conftest.pytest_addoption(parser)
spack.test.conftest.pytest_collection_modifyitems(config, items)
spack.test.conftest.remove_whatever_it_is(path)

Type-agnostic remove.

spack.test.conftest.reset_compiler_cache()

Ensure that the compiler cache is not shared across Spack tests

This cache can cause later tests to fail if left in a state incompatible with the new configuration. Since tests can make almost unlimited changes to their setup, default to not use the compiler cache across tests.

spack.test.conftest.use_configuration(config)

Context manager to swap out the global Spack configuration.

spack.test.conftest.use_repo(repo)

Context manager to swap out the global Spack repo path.

spack.test.conftest.use_store(store)

Context manager to swap out the global Spack store.

spack.test.conftest.working_env()

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(mutable_database)
spack.test.database.test_017_write_and_read_without_uuid(mutable_database, monkeypatch)
spack.test.database.test_020_db_sanity(database)

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

spack.test.database.test_025_reindex(mutable_database)

Make sure reindex works and ref counts are valid.

spack.test.database.test_026_reindex_after_deprecate(mutable_database)

Make sure reindex works and ref counts are valid after deprecation.

spack.test.database.test_030_db_sanity_from_another_process(mutable_database)
spack.test.database.test_040_ref_counts(database)

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

spack.test.database.test_041_ref_counts_deprecate(mutable_database)

Ensure that we have appropriate ref counts after deprecating

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(mutable_database)
spack.test.database.test_070_remove_and_add_dependency_package(mutable_database)
spack.test.database.test_080_root_ref_counts(mutable_database)
spack.test.database.test_090_non_root_ref_counts(mutable_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(mutable_database)
spack.test.database.test_add_to_upstream_after_downstream(upstream_and_downstream_db)

An upstream DB can add a package after it is installed in the downstream DB. When a package is recorded as installed in both, the results should refer to the downstream DB.

spack.test.database.test_cannot_write_upstream(tmpdir_factory, test_store, gen_mock_layout)
spack.test.database.test_clear_failure_forced(mutable_database, monkeypatch, capfd)

Add test coverage for clear_failure operation when force.

spack.test.database.test_clear_failure_keep(mutable_database, monkeypatch, capfd)

Add test coverage for clear_failure operation when to be retained.

spack.test.database.test_default_queries(database)
spack.test.database.test_external_entries_in_db(mutable_database)
spack.test.database.test_failed_spec_path_error(database)

Ensure spec not concrete check is covered.

spack.test.database.test_installed_upstream(upstream_and_downstream_db)
spack.test.database.test_mark_failed(mutable_database, monkeypatch, tmpdir, capsys)

Add coverage to mark_failed.

spack.test.database.test_old_external_entries_prefix(mutable_database)
spack.test.database.test_prefix_failed(mutable_database, monkeypatch)

Add coverage to prefix_failed operation.

spack.test.database.test_prefix_read_lock_error(mutable_database, monkeypatch)

Cover the prefix read lock exception.

spack.test.database.test_prefix_write_lock_error(mutable_database, monkeypatch)

Cover the prefix write lock exception.

spack.test.database.test_query_spec_with_conditional_dependency(mutable_database)
spack.test.database.test_query_spec_with_non_conditional_virtual_dependency(database)
spack.test.database.test_query_unused_specs(mutable_database)
spack.test.database.test_recursive_upstream_dbs(tmpdir_factory, test_store, gen_mock_layout)
spack.test.database.test_regression_issue_8036(mutable_database, usr_folder_exists)
spack.test.database.test_removed_upstream_dep(upstream_and_downstream_db)
spack.test.database.test_store(tmpdir)
spack.test.database.test_uninstall_by_spec(mutable_database)
spack.test.database.upstream_and_downstream_db(tmpdir_factory, gen_mock_layout)
spack.test.database.usr_folder_exists(monkeypatch)

The /usr folder is assumed to be existing in some tests. This fixture makes it such that its existence is mocked, so we have no requirements on the system running tests.

spack.test.directives module

spack.test.directives.test_false_directives_do_not_exist(mock_packages)

Ensure directives that evaluate to False at import time are added to dicts on packages.

spack.test.directives.test_true_directives_exist(mock_packages)

Ensure directives that evaluate to True at import time are added to dicts on packages.

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, mock_packages)

Test that finding specs within an install layout works.

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

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, mock_packages)

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_build_path(tmpdir, config)

This tests build path method.

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

spack.test.environment_modifications.env(prepare_environment_for_tests)

Returns an empty EnvironmentModifications object.

spack.test.environment_modifications.files_to_be_sourced()

Returns a list of files to be sourced

spack.test.environment_modifications.miscellaneous_paths()

Returns a list of paths, including system ones.

spack.test.environment_modifications.prepare_environment_for_tests(working_env)

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

spack.test.environment_modifications.test_append_flags(env)

Tests appending to a value in the environment.

spack.test.environment_modifications.test_blacklist_lmod_variables()
spack.test.environment_modifications.test_clear(env)
spack.test.environment_modifications.test_environment_from_sourcing_files(files, expected, deleted)
spack.test.environment_modifications.test_exclude_paths_from_inspection()
spack.test.environment_modifications.test_extend(env)

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

spack.test.environment_modifications.test_extra_arguments(env)

Tests that we can attach extra arguments to any command.

spack.test.environment_modifications.test_filter_system_paths(miscellaneous_paths)

Tests that the filtering of system paths works as expected.

spack.test.environment_modifications.test_from_environment_diff(before, after, search_list)
spack.test.environment_modifications.test_inspect_path(tmpdir)
spack.test.environment_modifications.test_path_manipulation(env)

Tests manipulating list of paths in the environment.

spack.test.environment_modifications.test_preserve_environment(prepare_environment_for_tests)
spack.test.environment_modifications.test_sanitize_literals(env, blacklist, whitelist)
spack.test.environment_modifications.test_sanitize_regex(env, blacklist, whitelist, expected, deleted)
spack.test.environment_modifications.test_set(env)

Tests setting values in the environment.

spack.test.environment_modifications.test_set_path(env)

Tests setting paths in an environment variable.

spack.test.environment_modifications.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_modifications.test_unset(env)

Tests unsetting values in the environment.

spack.test.fetch_strategy module

spack.test.fetch_strategy.test_fetchstrategy_bad_url_scheme()

Ensure that trying to make a fetch strategy from a URL with an unsupported scheme fails as expected.

spack.test.flag_handlers module

class spack.test.flag_handlers.TestFlagHandlers

Bases: object

pytestmark = [Mark(name='usefixtures', args=('config', 'mock_packages'), 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, monkeypatch)

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.mock_bad_git(monkeypatch)

Test GitFetchStrategy behavior with a bad git command for git >= 1.7.1 to trigger a SpackError.

spack.test.git_fetch.test_bad_git(tmpdir, mock_bad_git)

Trigger a SpackError when attempt a fetch with a bad git.

spack.test.git_fetch.test_debug_fetch(mock_packages, type_of_test, mock_git_repository, config)

Fetch the repo with debug enabled.

spack.test.git_fetch.test_fetch(type_of_test, secure, mock_git_repository, config, mutable_mock_repo, 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.git_fetch.test_get_full_repo(get_full_repo, git_version, mock_git_repository, config, mutable_mock_repo)

Ensure that we can clone a full repository.

spack.test.git_fetch.test_git_extra_fetch(tmpdir)

Ensure a fetch after ‘expanding’ is effectively a no-op.

spack.test.git_fetch.test_gitsubmodule(submodules, mock_git_repository, config, mutable_mock_repo)

Test GitFetchStrategy behavior with submodules

spack.test.git_fetch.test_gitsubmodules_delete(mock_git_repository, config, mutable_mock_repo)

Test GitFetchStrategy behavior with submodules_delete

spack.test.git_fetch.test_needs_stage()

Trigger a NoStageError when attempt a fetch without a stage.

spack.test.graph module

spack.test.graph.test_ascii_graph_mpileaks(mock_packages)

Test dynamically graphing the mpileaks package.

spack.test.graph.test_dynamic_dot_graph_mpileaks(mock_packages, config)

Test dynamically graphing the mpileaks package.

spack.test.graph.test_static_graph_mpileaks(mock_packages)

Test a static spack graph for a simple package.

spack.test.graph.test_topo_sort(mock_packages)

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, mutable_mock_repo)

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.hg_fetch.test_hg_extra_fetch(tmpdir)

Ensure a fetch after expanding is effectively a no-op.

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, capfd)
spack.test.install.test_flatten_deps(install_mockery, mock_fetch, mutable_mock_repo)

Explicitly test the flattening code for coverage purposes.

spack.test.install.test_install_and_uninstall(install_mockery, mock_fetch, monkeypatch)

Test dependency flattening/symlinks mock package.

spack.test.install.test_install_error()
spack.test.install.test_installed_dependency_request_conflicts(install_mockery, mock_fetch, mutable_mock_repo)
spack.test.install.test_installed_upstream(tmpdir_factory, install_mockery, mock_fetch, gen_mock_layout)

Check that when a dependency package is recorded as installed in an upstream database that it is not reinstalled.

spack.test.install.test_installed_upstream_external(tmpdir_factory, install_mockery, mock_fetch, gen_mock_layout)

Check that when a dependency package is recorded as installed in an upstream database that it is not reinstalled.

spack.test.install.test_log_install_with_build_files(install_mockery, monkeypatch)

Test the installer’s log function when have build files.

spack.test.install.test_log_install_without_build_files(install_mockery)

Test the installer log function when no build files are present.

spack.test.install.test_nosource_pkg_install(install_mockery, mock_fetch, mock_packages, capfd)

Test install phases with the nosource package.

spack.test.install.test_nosource_pkg_install_post_install(install_mockery, mock_fetch, mock_packages)

Test install phases with the nosource package with post-install.

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_pkg_build_paths(install_mockery)
spack.test.install.test_pkg_install_paths(install_mockery)
spack.test.install.test_second_install_no_overwrite_first(install_mockery, mock_fetch)
spack.test.install.test_store(install_mockery, mock_fetch)
spack.test.install.test_unconcretized_install(install_mockery, mock_fetch, mock_packages)

Test attempts to perform install phases with unconcretized spec.

spack.test.install.test_uninstall_by_spec_errors(mutable_database)

Test exceptional cases with the uninstall command.

spack.test.installer module

spack.test.installer.create_build_task(pkg)

Create a built task for the given (concretized) package

Parameters:pkg (PackageBase) – concretized package associated with the task
Returns:(BuildTask) A basic package build task
spack.test.installer.create_installer(spec_name)

Create an installer for the named spec

Parameters:spec_name (str) – Name of the explicit install spec
Returns:concretized spec installer (PackageInstaller): the associated package installer
Return type:spec (Spec)
spack.test.installer.test_add_bootstrap_compilers(install_mockery, monkeypatch)
spack.test.installer.test_check_deps_status_external(install_mockery, monkeypatch)
spack.test.installer.test_check_deps_status_install_failure(install_mockery, monkeypatch)
spack.test.installer.test_check_deps_status_upstream(install_mockery, monkeypatch)
spack.test.installer.test_check_deps_status_write_locked(install_mockery, monkeypatch)
spack.test.installer.test_cleanup_all_tasks(install_mockery, monkeypatch)

Test to ensure cover _cleanup_all_tasks.

spack.test.installer.test_cleanup_failed_err(install_mockery, tmpdir, monkeypatch, capsys)

Test _cleanup_failed exception path.

spack.test.installer.test_clear_failures_errs(install_mockery, monkeypatch, capsys)

Test the clear_failures exception paths.

spack.test.installer.test_clear_failures_success(install_mockery)

Test the clear_failures happy path.

spack.test.installer.test_dump_packages_deps_errs(install_mockery, tmpdir, monkeypatch, capsys)

Test error paths for dump_packages with dependencies.

spack.test.installer.test_dump_packages_deps_ok(install_mockery, tmpdir, mock_repo_path)

Test happy path for dump_packages with dependencies.

spack.test.installer.test_ensure_locked_err(install_mockery, monkeypatch, tmpdir, capsys)

Test _ensure_locked when a non-lock exception is raised.

spack.test.installer.test_ensure_locked_have(install_mockery, tmpdir, capsys)

Test _ensure_locked when already have lock.

spack.test.installer.test_ensure_locked_new_lock(install_mockery, tmpdir, lock_type, reads, writes)
spack.test.installer.test_ensure_locked_new_warn(install_mockery, monkeypatch, tmpdir, capsys)
spack.test.installer.test_fake_install(install_mockery)
spack.test.installer.test_hms(sec, result)
spack.test.installer.test_install_dir_exists(install_mockery, monkeypatch, capfd)

Cover capture of install directory exists error.

spack.test.installer.test_install_fail_fast_on_detect(install_mockery, monkeypatch, capsys)

Test fail_fast install when an install failure is detected.

spack.test.installer.test_install_fail_fast_on_except(install_mockery, monkeypatch, capsys)

Test fail_fast install when an install failure results from an error.

spack.test.installer.test_install_fail_on_interrupt(install_mockery, monkeypatch)

Test ctrl-c interrupted install.

spack.test.installer.test_install_failed(install_mockery, monkeypatch, capsys)

Test install with failed install.

spack.test.installer.test_install_from_cache_errors(install_mockery, capsys)

Test to ensure cover _install_from_cache errors.

spack.test.installer.test_install_from_cache_ok(install_mockery, monkeypatch)

Test to ensure cover _install_from_cache to the return.

spack.test.installer.test_install_lock_failures(install_mockery, monkeypatch, capfd)

Cover basic install lock failure handling in a single pass.

spack.test.installer.test_install_lock_installed_requeue(install_mockery, monkeypatch, capfd)

Cover basic install handling for installed package.

spack.test.installer.test_install_msg(monkeypatch)

Test results of call to install_msg based on debug level.

spack.test.installer.test_install_read_locked_requeue(install_mockery, monkeypatch, capfd)

Cover basic read lock handling for uninstalled package with requeue.

spack.test.installer.test_install_skip_patch(install_mockery, mock_fetch)

Test the path skip_patch install path.

spack.test.installer.test_install_task_add_compiler(install_mockery, monkeypatch, capfd)
spack.test.installer.test_install_task_use_cache(install_mockery, monkeypatch)
spack.test.installer.test_install_uninstalled_deps(install_mockery, monkeypatch, capsys)

Test install with uninstalled dependencies.

spack.test.installer.test_installer_ensure_ready_errors(install_mockery)
spack.test.installer.test_installer_init_errors(install_mockery)

Test to ensure cover installer constructor errors.

spack.test.installer.test_installer_init_queue(install_mockery)

Test of installer queue functions.

spack.test.installer.test_installer_last_phase_error(install_mockery, capsys)
spack.test.installer.test_installer_repr(install_mockery)
spack.test.installer.test_installer_str(install_mockery)
spack.test.installer.test_package_id_err(install_mockery)
spack.test.installer.test_package_id_ok(install_mockery)
spack.test.installer.test_packages_needed_to_bootstrap_compiler_none(install_mockery)
spack.test.installer.test_packages_needed_to_bootstrap_compiler_packages(install_mockery, monkeypatch)
spack.test.installer.test_prepare_for_install_on_installed(install_mockery, monkeypatch)

Test of _prepare_for_install’s early return for installed task path.

spack.test.installer.test_process_binary_cache_tarball_none(install_mockery, monkeypatch, capfd)

Tests of _process_binary_cache_tarball when no tarball.

spack.test.installer.test_process_binary_cache_tarball_tar(install_mockery, monkeypatch, capfd)

Tests of _process_binary_cache_tarball with a tar file.

spack.test.installer.test_process_external_package_module(install_mockery, monkeypatch, capfd)

Test to simply cover the external module message path.

spack.test.installer.test_release_lock_write_n_exception(install_mockery, tmpdir, capsys)

Test _release_lock for supposed write lock with exception.

spack.test.installer.test_requeue_task(install_mockery, capfd)

Test to ensure cover _requeue_task.

spack.test.installer.test_setup_install_dir_grp(install_mockery, monkeypatch, capfd)

Test _setup_install_dir’s group change.

spack.test.installer.test_try_install_from_binary_cache(install_mockery, mock_packages, monkeypatch, capsys)

Tests SystemExit path for_try_install_from_binary_cache.

spack.test.installer.test_update_failed_no_dependent_task(install_mockery)

Test _update_failed with missing dependent build tasks.

spack.test.main module

spack.test.main.test_get_version_bad_git(tmpdir, working_env)
spack.test.main.test_get_version_match_git(tmpdir, working_env)
spack.test.main.test_get_version_no_git(tmpdir, working_env)
spack.test.main.test_get_version_no_match_git(tmpdir, working_env)
spack.test.main.test_get_version_no_repo(tmpdir, monkeypatch)
spack.test.main.test_main_calls_get_version(tmpdir, capsys, working_env)

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

Hook method for setting up the test fixture before exercising it.

tearDown()

Hook method for deconstructing the test fixture after testing it.

test_make_explicit()
test_make_jobs_env()
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.MockFetcher

Bases: object

Mock fetcher object which implements the necessary functionality for testing MirrorCache

static archive(dst)
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.mirror.test_all_mirror(mock_git_repository, mock_svn_repository, mock_hg_repository, mock_archive)
spack.test.mirror.test_git_mirror(mock_git_repository)
spack.test.mirror.test_hg_mirror(mock_hg_repository)
spack.test.mirror.test_mirror_archive_paths_no_version(mock_packages, config, mock_archive)

Confirm that the cosmetic symlink created in the mirror cache (which may be relative) targets the storage path correctly.

spack.test.mirror.test_mirror_with_url_patches(mock_packages, config, monkeypatch)
spack.test.mirror.test_svn_mirror(mock_svn_repository)
spack.test.mirror.test_url_mirror(mock_archive)

spack.test.module_parsing module

spack.test.module_parsing.test_get_argument_from_module_line()
spack.test.module_parsing.test_get_path_from_empty_module()
spack.test.module_parsing.test_get_path_from_module_contents()
spack.test.module_parsing.test_get_path_from_module_faked(monkeypatch)
spack.test.module_parsing.test_module_function_change_env(tmpdir, working_env, monkeypatch)
spack.test.module_parsing.test_module_function_no_change(tmpdir, monkeypatch)
spack.test.module_parsing.test_pkg_dir_from_module_name()

spack.test.multimethod module

Test for multi_method dispatch.

spack.test.multimethod.pkg_name(request)

Make tests run on both multimethod and multimethod-inheritor.

This means we test all of our @when methods on a class that uses them directly, AND on a class that inherits them.

spack.test.multimethod.test_default_works(pkg_name)
spack.test.multimethod.test_dependency_match(pkg_name)
spack.test.multimethod.test_mpi_version(pkg_name)
spack.test.multimethod.test_multimethod_boolean(pkg_name)
spack.test.multimethod.test_multimethod_diamond_inheritance()
spack.test.multimethod.test_multimethod_inherited_and_overridden()
spack.test.multimethod.test_multimethod_with_base_class(pkg_name)
spack.test.multimethod.test_no_version_match(pkg_name)
spack.test.multimethod.test_one_version_match(pkg_name)
spack.test.multimethod.test_target_match(pkg_name)
spack.test.multimethod.test_undefined_mpi_version(pkg_name)
spack.test.multimethod.test_version_overlap(pkg_name)
spack.test.multimethod.test_virtual_dep_match(pkg_name)

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

spack.test.operating_system.test_cle_release_precedence(tmpdir, monkeypatch)

test that cle-release file takes precedence over clerelease file.

spack.test.operating_system.test_read_cle_release_file(tmpdir, monkeypatch)

test reading the Cray cle-release file

spack.test.operating_system.test_read_clerelease_file(tmpdir, monkeypatch)

test reading the Cray clerelease file

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, mock_packages)
spack.test.optional_deps.test_normalize(spec_and_expected, config, mock_packages)

spack.test.package_class module

Test class methods on Package objects.

This doesn’t include methods on package instances (like do_install(), etc.). Only methods like possible_dependencies() that deal with the static DSL metadata for packages.

spack.test.package_class.mpi_names(mock_repo_path)
spack.test.package_class.mpileaks_possible_deps(mock_packages, mpi_names)
spack.test.package_class.test_possible_dependencies(mock_packages, mpileaks_possible_deps)
spack.test.package_class.test_possible_dependencies_missing(mock_packages)
spack.test.package_class.test_possible_dependencies_virtual(mock_packages, mpi_names)
spack.test.package_class.test_possible_dependencies_with_deptypes(mock_packages)
spack.test.package_class.test_possible_dependencies_with_multiple_classes(mock_packages, mpileaks_possible_deps)
spack.test.package_class.test_possible_direct_dependencies(mock_packages, mpileaks_possible_deps)

spack.test.package_hash module

spack.test.package_hash.compare_sans_name(eq, spec1, spec2)
spack.test.package_hash.test_all_same_but_archive_hash(tmpdir, mock_packages, config)

Archive hash is not intended to be reflected in Package hash.

spack.test.package_hash.test_all_same_but_install(tmpdir, mock_packages, config)
spack.test.package_hash.test_all_same_but_name(tmpdir, mock_packages, config)
spack.test.package_hash.test_all_same_but_patch_contents(tmpdir, mock_packages, config)
spack.test.package_hash.test_all_same_but_patches_to_apply(tmpdir, mock_packages, config)
spack.test.package_hash.test_different_variants(tmpdir, mock_packages, config)
spack.test.package_hash.test_hash(tmpdir, mock_packages, config)

spack.test.package_sanity module

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

spack.test.package_sanity.check_repo()

Get all packages in the builtin repo to make sure they work.

spack.test.package_sanity.test_all_dependencies_exist()

Make sure no packages have nonexisting dependencies.

spack.test.package_sanity.test_all_packages_use_sha256_checksums()

Make sure that no packages use md5 checksums.

spack.test.package_sanity.test_all_versions_are_lowercase()

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

spack.test.package_sanity.test_all_virtual_packages_have_default_providers()

All virtual packages must have a default provider explicitly set.

spack.test.package_sanity.test_api_for_build_and_run_environment()

Ensure that every package uses the correct API to set build and run environment, and not the old one.

spack.test.package_sanity.test_docstring()

Ensure that every package has a docstring.

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.package_sanity.test_no_fixme()

Packages should not contain any boilerplate such as FIXME or example.com.

spack.test.package_sanity.test_package_version_consistency()

Make sure all versions on builtin packages produce a fetcher.

spack.test.package_sanity.test_prs_update_old_api()

Ensures that every package modified in a PR doesn’t contain deprecated calls to any method.

spack.test.package_sanity.test_variant_defaults_are_parsable_from_cli()

Ensures that variant defaults are parsable from cli.

spack.test.packages module

class spack.test.packages.TestPackage

Bases: object

pytestmark = [Mark(name='usefixtures', args=('config', 'mock_packages'), kwargs={})]
test_all_same_but_archive_hash()
test_content_hash_all_same_but_patch_contents()
test_content_hash_cannot_get_details_from_ast()

Packages hash-test1 and hash-test3 would be considered the same except that hash-test3 conditionally executes a phase based on a “when” directive that Spack cannot evaluate by examining the AST. This test ensures that Spack can compute a content hash for hash-test3. If Spack cannot determine when a phase applies, it adds it by default, so the test also ensures that the hashes differ where Spack includes a phase on account of AST-examination failure.

test_content_hash_different_variants()
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_inheritance_of_patches()
test_load_package()
test_nonexisting_package_filename()
test_package_class_names()
test_package_filename()
test_package_name()
test_parse_dynamic_function_call()
spack.test.packages.test_bundle_patch_directive(mock_directive_bundle, clear_directive_functions)

Test raising exception on a patch directive with a bundle package.

spack.test.packages.test_bundle_version_checksum(mock_directive_bundle, clear_directive_functions)

Test raising exception on a version checksum with a bundle package.

spack.test.packages.test_fetch_options(mock_packages, config)

Test fetch options inference.

spack.test.packages.test_git_top_level(mock_packages, config)

Ensure that top-level git attribute can be used as a default.

spack.test.packages.test_git_url_top_level_conflicts(mock_packages, config)

Test git fetch strategy inference when url is specified with git.

spack.test.packages.test_git_url_top_level_git_versions(mock_packages, config)

Test git fetch strategy inference when url is specified with git.

spack.test.packages.test_git_url_top_level_url_versions(mock_packages, config)

Test URL fetch strategy inference when url is specified with git.

spack.test.packages.test_hg_top_level(mock_packages, config)

Ensure that top-level hg attribute can be used as a default.

spack.test.packages.test_no_extrapolate_without_url(mock_packages, config)

Verify that we can’t extrapolate versions for non-URL packages.

spack.test.packages.test_rpath_args(mutable_database)

Test a package’s rpath_args property.

spack.test.packages.test_svn_top_level(mock_packages, config)

Ensure that top-level svn attribute can be used as a default.

spack.test.packages.test_two_vcs_fetchers_top_level(mock_packages, config)

Verify conflict when two VCS strategies are specified together.

spack.test.packages.test_url_for_version_with_no_urls(mock_packages, config)
spack.test.packages.test_url_for_version_with_only_overrides(mock_packages, config)
spack.test.packages.test_url_for_version_with_only_overrides_with_gaps(mock_packages, config)
spack.test.packages.test_urls_for_versions(mock_packages, config)

Version directive without a ‘url’ argument should use default url.

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.mock_download()

Mock a failing download strategy.

spack.test.packaging.test_buildcache(mock_archive, tmpdir)
spack.test.packaging.test_macho_make_paths()
spack.test.packaging.test_manual_download(install_mockery, mock_download, monkeypatch, manual, instr)

Ensure expected fetcher fail message based on manual download and instr.

spack.test.packaging.test_needs_relocation()
spack.test.packaging.test_relocate_text(tmpdir)
spack.test.packaging.test_replace_paths(tmpdir)

spack.test.patch module

spack.test.patch.check_multi_dependency_patch_specs(libelf, libdwarf, fake, owner, package_dir)

Validate patches on dependencies of patch-several-dependencies.

spack.test.patch.mock_patch_stage(tmpdir_factory, monkeypatch)
spack.test.patch.test_conditional_patched_dependencies(mock_packages, config)

Test whether conditional patched dependencies work.

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

Test whether conditional patched dependencies with conditions work.

spack.test.patch.test_file_patch_no_file()
spack.test.patch.test_multiple_patched_dependencies(mock_packages, config)

Test whether multiple patched dependencies work.

spack.test.patch.test_nested_directives(mock_packages)

Ensure pkg data structures are set up properly by nested directives.

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

Test whether patches in a package appear in the spec.

spack.test.patch.test_patch_mixed_versions_subset_constraint(mock_packages, config)

If we have a package with mixed x.y and x.y.z versions, make sure that a patch applied to a version range of x.y.z versions is not applied to an x.y version.

spack.test.patch.test_patch_order(mock_packages, config)
spack.test.patch.test_patched_dependency(mock_packages, config, install_mockery, mock_fetch)

Test whether patched dependencies work.

spack.test.patch.test_url_patch(mock_patch_stage, filename, sha256, archive_sha256)
spack.test.patch.test_write_and_read_sub_dags_with_patched_deps(mock_packages, config)

Test whether patched dependencies are still correct after writing and reading a sub-DAG of a concretized Spec.

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

spack.test.permissions.test_chmod_real_entries_ignores_suid_sgid(tmpdir)
spack.test.permissions.test_chmod_rejects_group_writable_suid(tmpdir)
spack.test.permissions.test_chmod_rejects_world_writable_sgid(tmpdir)
spack.test.permissions.test_chmod_rejects_world_writable_suid(tmpdir)

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(mock_packages)
spack.test.provider_index.test_equal(mock_packages)
spack.test.provider_index.test_mpi_providers(mock_packages)
spack.test.provider_index.test_provider_index_round_trip(mock_packages)
spack.test.provider_index.test_providers_for_simple(mock_packages)

spack.test.relocate module

spack.test.relocate.copy_binary()

Returns a function that copies a binary somewhere and returns the new location.

spack.test.relocate.expected_patchelf_path(request, mutable_database, monkeypatch)

Prepare the stage to tests different cases that can occur when searching for patchelf.

spack.test.relocate.hello_world(tmpdir)

Factory fixture that compiles an ELF binary setting its RPATH. Relative paths are encoded with $ORIGIN prepended.

spack.test.relocate.is_relocatable(request)
spack.test.relocate.mock_patchelf(tmpdir, mock_executable)
spack.test.relocate.rpaths_for(new_binary)

Return the RPATHs or RUNPATHs of a binary.

spack.test.relocate.source_file(tmpdir, is_relocatable)

Returns the path to a source file of a relocatable executable.

spack.test.relocate.test_existing_rpaths(patchelf_behavior, expected, mock_patchelf)
spack.test.relocate.test_file_is_relocatable(source_file, is_relocatable)
spack.test.relocate.test_file_is_relocatable_errors(tmpdir)
spack.test.relocate.test_make_elf_binaries_relative(hello_world, copy_binary, tmpdir)
spack.test.relocate.test_make_relative_paths(start_path, path_root, paths, expected)
spack.test.relocate.test_normalize_relative_paths(start_path, relative_paths, expected)
spack.test.relocate.test_patchelf_is_relocatable()
spack.test.relocate.test_raise_if_not_relocatable(monkeypatch)
spack.test.relocate.test_relocate_elf_binaries_absolute_paths(hello_world, copy_binary, tmpdir)
spack.test.relocate.test_relocate_elf_binaries_relative_paths(hello_world, copy_binary)
spack.test.relocate.test_relocate_text_bin(hello_world, copy_binary, tmpdir)
spack.test.relocate.test_relocate_text_bin_raise_if_new_prefix_is_longer()
spack.test.relocate.test_replace_prefix_bin(hello_world)
spack.test.relocate.test_search_patchelf(expected_patchelf_path)
spack.test.relocate.test_set_elf_rpaths(mock_patchelf)
spack.test.relocate.test_set_elf_rpaths_warning(mock_patchelf)
spack.test.relocate.text_in_bin(text, binary)

spack.test.repo module

spack.test.repo.extra_repo(tmpdir_factory)
spack.test.repo.test_repo_anonymous_pkg(mutable_mock_repo)
spack.test.repo.test_repo_getpkg(mutable_mock_repo)
spack.test.repo.test_repo_invisibles(mutable_mock_repo, extra_repo)
spack.test.repo.test_repo_last_mtime()
spack.test.repo.test_repo_multi_getpkg(mutable_mock_repo, extra_repo)
spack.test.repo.test_repo_multi_getpkgclass(mutable_mock_repo, extra_repo)
spack.test.repo.test_repo_pkg_with_unknown_namespace(mutable_mock_repo)
spack.test.repo.test_repo_unknown_pkg(mutable_mock_repo)

spack.test.s3_fetch module

spack.test.s3_fetch.test_s3fetchstrategy_bad_url(tmpdir)

Ensure fetch with bad URL fails as expected.

spack.test.s3_fetch.test_s3fetchstrategy_downloaded(tmpdir)

Ensure fetch with archive file already downloaded is a noop.

spack.test.s3_fetch.test_s3fetchstrategy_sans_url()

Ensure constructor with no URL fails.

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.check_sbang_installation()
spack.test.sbang.script_dir()
spack.test.sbang.test_install_sbang(install_mockery)
spack.test.sbang.test_shebang_handles_non_writable_files(script_dir)
spack.test.sbang.test_shebang_handling(script_dir)

spack.test.schema module

spack.test.schema.meta_schema()

Meta schema for JSON schema validation (Draft 4)

spack.test.schema.module_suffixes_schema()
spack.test.schema.test_deprecated_properties(module_suffixes_schema)
spack.test.schema.test_module_suffixes(module_suffixes_schema)
spack.test.schema.test_schema_validation(meta_schema, config_name)
spack.test.schema.test_validate_spec(validate_spec_schema)
spack.test.schema.validate_spec_schema()

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 = [Mark(name='usefixtures', args=('mutable_mock_repo', 'config'), 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_conditional_dep_with_user_constraints()

This sets up packages X->Y such that X depends on Y conditionally. It then constructs a Spec with X but with no constraints on X, so that the initial normalization pass cannot determine whether the constraints are met to add the dependency; this checks whether a user-specified constraint on Y is applied properly.

spack.test.spec_dag.test_installed_deps()

Preinstall a package P with a constrained build dependency D, then concretize a dependent package which also depends on P and D, specifying that the installed instance of P should be used. In this case, D should not be constrained by P since P is already built.

spack.test.spec_dag.test_specify_preinstalled_dep()

Specify the use of a preinstalled package during concretization with a transitive dependency that is only supplied by the preinstalled package.

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

class spack.test.spec_list.TestSpecList

Bases: object

default_constraints = [[mpileaks], [zmpi@1.0], [mpich@3.0], [hypre, %gcc@4.5.0], [hypre, %clang@3.3], [libelf]]
default_expansion = ['mpileaks', 'zmpi@1.0', 'mpich@3.0', {'matrix': [['hypre'], ['%gcc@4.5.0', '%clang@3.3']]}, 'libelf']
default_input = ['mpileaks', '$mpis', {'matrix': [['hypre'], ['$gccs', '$clangs']]}, 'libelf']
default_reference = {'clangs': <spack.spec_list.SpecList object>, 'gccs': <spack.spec_list.SpecList object>, 'mpis': <spack.spec_list.SpecList object>}
default_specs = [mpileaks, zmpi@1.0, mpich@3.0, hypre%gcc@4.5.0, hypre%clang@3.3, libelf]
test_spec_list_add()
test_spec_list_constraint_ordering()
test_spec_list_expansions()
test_spec_list_extension()
test_spec_list_matrix_exclude(mock_packages)
test_spec_list_nested_matrices()
test_spec_list_recursion_specs_as_constraints()
test_spec_list_remove()
test_spec_list_update_reference()

spack.test.spec_semantics module

class spack.test.spec_semantics.TestSpecSematics

Bases: object

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

pytestmark = [Mark(name='usefixtures', args=('config', 'mock_packages'), kwargs={})]
test_abstract_spec_prefix_error()
test_combination_of_wildcard_or_none()
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_empty_satisfies()
test_error_message_unknown_variant()
test_errors_in_variant_directive()
test_exceptional_paths_for_constructor()
test_forwarding_of_architecture_attributes()
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_dependencies_ordered()
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_spec_deprecated_formatting()
test_spec_flags_maintain_order()
test_spec_formatting()
test_spec_formatting_escapes()
test_target_constraints(spec, constraint, expected_result)
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.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, constraint_spec, target_concrete=False)
spack.test.spec_semantics.check_unsatisfiable(target_spec, constraint_spec, target_concrete=False)
spack.test.spec_semantics.make_spec(spec_like, concrete)
spack.test.spec_semantics.test_is_extension_after_round_trip_to_dict(config, spec_str)

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)

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(mutable_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_multiple_versions()
test_nice_error_for_no_space_after_spec_filename()

Ensure that omitted spaces don’t give weird errors about hashes.

test_nonexistent_hash(database)

Ensure we get errors for nonexistant hashes.

test_package_names()
test_parse_errors()
test_parse_filename_missing_slash_as_spec(mock_packages, tmpdir)

Ensure that libelf.yaml parses as a spec, NOT a file.

test_parse_yaml_dependency(mock_packages, tmpdir)
test_parse_yaml_dependency_relative_paths(mock_packages, tmpdir)
test_parse_yaml_error_handling()
test_parse_yaml_relative_paths(mock_packages, tmpdir)
test_parse_yaml_relative_subdir_path(mock_packages, tmpdir)
test_parse_yaml_simple(mock_packages, tmpdir)
test_parse_yaml_variant_error(mock_packages, tmpdir)
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_target_tokenization(expected_tokens, spec_string)
test_version_after_compiler()
test_way_too_many_spaces()
test_yaml_spec_not_filename(mock_packages, tmpdir)
test_yaml_specs()

spack.test.spec_yaml module

Test YAML serialization for specs.

YAML format preserves DAG information in the spec.

spack.test.spec_yaml.check_specs_equal(original_spec, spec_yaml_path)
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(mock_packages)
spack.test.spec_yaml.test_concrete_spec(config, mock_packages)
spack.test.spec_yaml.test_external_spec(config, mock_packages)
spack.test.spec_yaml.test_hashes_use_no_python_dicts(module)

Coarse check to make sure we don’t use dicts in Spec.to_node_dict().

Python dicts are not guaranteed to iterate in a deterministic order (at least not in all python versions) so we need to use lists and syaml_dicts. syaml_dicts are ordered and ensure that hashes in Spack are deterministic.

This test is intended to handle cases that are not covered by the consistency checks above, or that would be missed by a dynamic check. This test traverses the ASTs of functions that are used in our hash algorithms, finds instances of dictionaries being constructed, and prints out the line numbers where they occur.

spack.test.spec_yaml.test_normal_spec(mock_packages)
spack.test.spec_yaml.test_ordered_read_not_required_for_consistent_dag_hash(config, mock_packages)

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_save_dependency_spec_yamls_subset(tmpdir, config)
spack.test.spec_yaml.test_simple_spec()
spack.test.spec_yaml.test_to_record_dict(mock_packages, config)
spack.test.spec_yaml.test_using_ordered_dict(mock_packages)

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(config, mock_packages)
spack.test.spec_yaml.test_yaml_subdag(config, mock_packages)

spack.test.stage module

Test that the Stage class works correctly.

class spack.test.stage.TestStage

Bases: object

pytestmark = [Mark(name='usefixtures', args=('mock_packages',), kwargs={})]
stage_name = 'spack-test-stage'
test_composite_stage_with_expand_resource(composite_stage_with_expanding_resource)
test_composite_stage_with_expand_resource_default_placement(composite_stage_with_expanding_resource)

For a resource which refers to a compressed archive which expands to a directory, check that by default the resource is placed in the source_path of the root stage with the name of the decompressed directory.

test_composite_stage_with_noexpand_resource(mock_stage_archive, mock_noexpand_resource)
test_create_stage_root(tmpdir, no_path_access)

Test _create_stage_root permissions.

test_create_stage_root_bad_uid(tmpdir, monkeypatch)

Test the code path that uses an existing user path – whether $user in $tempdir or not – and triggers the generation of the UID mismatch warning.

This situation can happen with some config:build_stage settings for teams using a common service account for installing software.

test_diystage_path_invalid()

Ensure DIYStage for an invalid path behaves as expected.

test_diystage_path_none()

Ensure DIYStage for path=None behaves as expected.

test_diystage_path_valid(tmpdir)

Ensure DIYStage for a valid path behaves as expected.

test_diystage_preserve_file(tmpdir)

Ensure DIYStage preserves an existing file.

test_ensure_one_stage_entry(mock_stage_archive)
test_expand_archive(expected_file_list, mock_stage_archive)
test_expand_archive_extra_expand(mock_stage_archive)

Test expand with an extra expand after expand (i.e., no-op).

test_fetch(mock_stage_archive, debug)
test_first_accessible_path(tmpdir)

Test _first_accessible_path names.

test_get_stage_root_bad_path(clear_stage_root)

Ensure an invalid stage path root raises a StageError.

test_get_stage_root_in_spack(clear_stage_root)

Ensure an instance path is an accessible build stage path.

test_keep_exceptions(mock_stage_archive)
test_keep_without_exceptions(mock_stage_archive)
test_no_keep_with_exceptions(mock_stage_archive)
test_no_keep_without_exceptions(mock_stage_archive)
test_no_search_if_default_succeeds(mock_stage_archive, failing_search_fn)
test_no_search_mirror_only(failing_fetch_strategy, failing_search_fn)
test_noexpand_stage_file(mock_stage_archive, mock_noexpand_resource)

When creating a stage with a nonexpanding URL, the ‘archive_file’ property of the stage should refer to the path of that file.

test_resolve_paths()

Test _resolve_paths.

test_restage(mock_stage_archive)
test_search_if_default_fails(failing_fetch_strategy, search_fn, err_msg, expected)
test_setup_and_destroy_name_with_tmp(mock_stage_archive)
test_setup_and_destroy_name_without_tmp(mock_stage_archive)
test_setup_and_destroy_no_name_with_tmp(mock_stage_archive)
test_setup_and_destroy_no_name_without_tmp(mock_stage_archive)
test_source_path_available(mock_stage_archive)

Ensure source path available but does not exist on instantiation.

test_stage_constructor_no_fetcher()

Ensure Stage constructor with no URL or fetch strategy fails.

test_stage_constructor_with_path(tmpdir)

Ensure Stage constructor with a path uses it.

test_stage_purge(tmpdir, clear_stage_root, path, purged)

Test purging of stage directories.

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, expected_file_list)

Ensure the expanded archive directory contains the expected structure and files as described in the module-level comments above.

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

Ensure the fetch resulted in a properly placed archive file as described in the module-level comments.

spack.test.stage.check_setup(stage, stage_name, archive)

Figure out whether a stage was set up correctly.

spack.test.stage.check_stage_dir_perms(prefix, path)

Check the stage directory perms to ensure match expectations.

spack.test.stage.clear_stage_root(monkeypatch)

Ensure spack.stage._stage_root is not set at test start.

spack.test.stage.composite_stage_with_expanding_resource(mock_stage_archive, mock_expand_resource)

Sets up a composite for expanding resources prior to staging.

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_expand_resource(tmpdir)

Sets up an expandable resource in tmpdir prior to staging.

spack.test.stage.mock_noexpand_resource(tmpdir)

Set up a non-expandable resource in the tmpdir prior to staging.

spack.test.stage.mock_stage_archive(tmp_build_stage_dir)

Create the directories and files for the staged mock archive.

spack.test.stage.search_fn()

Returns a search function that always succeeds.

spack.test.stage.test_cannot_access(capsys)

Ensure can_access dies with the expected error.

spack.test.stage.test_stage_create_replace_path(tmp_build_stage_dir)

Ensure stage creation replaces a non-directory path.

spack.test.stage.tmp_build_stage_dir(tmpdir, clear_stage_root)

Use a temporary test directory for the stage root.

spack.test.svn_fetch module

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

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.svn_fetch.test_svn_extra_fetch(tmpdir)

Ensure a fetch after downloading is effectively a no-op.

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 = [Mark(name='usefixtures', args=('config',), kwargs={})]
test_template_retrieval()

Tests the template retrieval mechanism hooked into config files

spack.test.test_activations module

This includes tests for customized activation logic for specific packages (e.g. python and perl).

spack.test.test_activations.builtin_and_mock_packages()
spack.test.test_activations.create_dir_structure(tmpdir, dir_structure)
spack.test.test_activations.create_ext_pkg(name, prefix, extendee_spec, monkeypatch)
spack.test.test_activations.create_python_ext_pkg(name, prefix, python_spec, monkeypatch, namespace=None)
spack.test.test_activations.namespace_extensions(tmpdir, builtin_and_mock_packages)
spack.test.test_activations.perl_and_extension_dirs(tmpdir, builtin_and_mock_packages)
spack.test.test_activations.python_and_extension_dirs(tmpdir, builtin_and_mock_packages)
spack.test.test_activations.test_is_activated_upstream_extendee(tmpdir, builtin_and_mock_packages, monkeypatch)

When an extendee is installed upstream, make sure that the extension spec is never considered to be globally activated for it.

spack.test.test_activations.test_perl_activation(tmpdir, builtin_and_mock_packages, monkeypatch)
spack.test.test_activations.test_perl_activation_view(tmpdir, perl_and_extension_dirs, monkeypatch, builtin_and_mock_packages)
spack.test.test_activations.test_perl_activation_with_files(tmpdir, perl_and_extension_dirs, monkeypatch, builtin_and_mock_packages)
spack.test.test_activations.test_python_activation_view(tmpdir, python_and_extension_dirs, builtin_and_mock_packages, monkeypatch)
spack.test.test_activations.test_python_activation_with_files(tmpdir, python_and_extension_dirs, monkeypatch, builtin_and_mock_packages)
spack.test.test_activations.test_python_ignore_namespace_init_conflict(tmpdir, namespace_extensions, builtin_and_mock_packages, monkeypatch)

Test the view update logic in PythonPackage ignores conflicting instances of __init__ for packages which are in the same namespace.

spack.test.test_activations.test_python_keep_namespace_init(tmpdir, namespace_extensions, builtin_and_mock_packages, monkeypatch)

Test the view update logic in PythonPackage keeps the namespace __init__ file as long as one package in the namespace still exists.

spack.test.test_activations.test_python_namespace_conflict(tmpdir, namespace_extensions, monkeypatch, builtin_and_mock_packages)

Test the view update logic in PythonPackage reports an error when two python extensions with different namespaces have a conflicting __init__ file.

spack.test.url_fetch module

spack.test.url_fetch.checksum_type(request)
spack.test.url_fetch.pkg_factory()
spack.test.url_fetch.test_candidate_urls(pkg_factory, url, urls, version, expected)

Tests that candidate urls include mirrors and that they go through pattern matching and substitution for versions.

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

Fetch an archive and make sure we can checksum it.

spack.test.url_fetch.test_from_list_url(mock_packages, config, spec, url, digest)

Test URLs in the url-list-test package, which means they should have checksums in the package.

spack.test.url_fetch.test_from_list_url_unspecified(mock_packages, config)

Test non-specific URLs from the url-list-test package.

spack.test.url_fetch.test_hash_detection(checksum_type)
spack.test.url_fetch.test_nosource_from_list_url(mock_packages, config)

This test confirms BundlePackages do not have list url.

spack.test.url_fetch.test_unknown_hash(checksum_type)
spack.test.url_fetch.test_url_extra_fetch(tmpdir, mock_archive)

Ensure a fetch after downloading is effectively a no-op.

spack.test.url_fetch.test_url_with_status_bar(tmpdir, mock_archive, monkeypatch, capfd)

Ensure fetch with status bar option succeeds.

spack.test.url_fetch.test_urlfetchstrategy_bad_url(tmpdir)

Ensure fetch with bad URL fails as expected.

spack.test.url_fetch.test_urlfetchstrategy_sans_url()

Ensure constructor with no URL fails.

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_disjoint_set_fluent_methods()
spack.test.variant.test_disjoint_set_initialization()
spack.test.variant.test_disjoint_set_initialization_errors()
spack.test.variant.test_from_node_dict()

spack.test.verification module

Tests for the spack.verify module

spack.test.verification.test_check_chmod_manifest_entry(tmpdir)
spack.test.verification.test_check_prefix_manifest(tmpdir)
spack.test.verification.test_dir_manifest_entry(tmpdir)
spack.test.verification.test_file_manifest_entry(tmpdir)
spack.test.verification.test_link_manifest_entry(tmpdir)
spack.test.verification.test_single_file_verification(tmpdir)

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_develop()
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_isdevelop()
spack.test.versions.test_len()
spack.test.versions.test_list_highest()
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_string_prefix()
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.views module

spack.test.views.test_global_activation(install_mockery, mock_fetch)

This test ensures that views which are maintained inside of an extendee package’s prefix are maintained as expected and are compatible with global activations prior to #7152.

spack.test.views.test_remove_extensions_ordered(install_mockery, mock_fetch, tmpdir)

spack.test.web module

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_get_header()
spack.test.web.test_list_url(tmpdir)
spack.test.web.test_spider(depth, expected_found, expected_not_found, expected_text)
spack.test.web.test_spider_no_response(monkeypatch)

Module contents