diff --git a/lib/spack/spack/cmd/test.py b/lib/spack/spack/cmd/test.py index fcd72a123e..4da35c8a35 100644 --- a/lib/spack/spack/cmd/test.py +++ b/lib/spack/spack/cmd/test.py @@ -54,6 +54,12 @@ def setup_parser(subparser): run_parser.add_argument( "--externals", action="store_true", help="Test packages that are externally installed." ) + run_parser.add_argument( + "-x", + "--explicit", + action="store_true", + help="Only test packages that are explicitly installed.", + ) run_parser.add_argument( "--keep-stage", action="store_true", help="Keep testing directory for debugging" ) @@ -188,6 +194,9 @@ def test_run(args): if args.fail_fast: spack.config.set("config:fail_fast", True, scope="command_line") + explicit = args.explicit or any + explicit_str = "explicitly " if args.explicit else "" + # Get specs to test env = ev.active_environment() hashes = env.all_hashes() if env else None @@ -195,9 +204,13 @@ def test_run(args): specs = spack.cmd.parse_specs(args.specs) if args.specs else [None] specs_to_test = [] for spec in specs: - matching = spack.store.db.query_local(spec, hashes=hashes) + matching = spack.store.db.query_local( + spec, + hashes=hashes, + explicit=explicit, + ) if spec and not matching: - tty.warn("No installed packages match spec %s" % spec) + tty.warn("No {0}installed packages match spec {1}".format(explicit_str, spec)) """ TODO: Need to write out a log message and/or CDASH Testing output that package not installed IF continue to process @@ -208,6 +221,7 @@ def test_run(args): # to ensure report package as skipped (e.g., for CI) specs_to_test.append(spec) """ + specs_to_test.extend(matching) # test_stage_dir diff --git a/lib/spack/spack/test/ci.py b/lib/spack/spack/test/ci.py index b2c83ca2a9..06f212d92a 100644 --- a/lib/spack/spack/test/ci.py +++ b/lib/spack/spack/test/ci.py @@ -467,7 +467,7 @@ def test_affected_specs_on_first_concretization(mutable_mock_env_path, config): @pytest.mark.skipif( - sys.platform == "win32", reason="Reliance on bash script ot supported on Windows" + sys.platform == "win32", reason="Reliance on bash script not supported on Windows" ) def test_ci_process_command(tmpdir): repro_dir = tmpdir.join("repro_dir").strpath @@ -479,7 +479,7 @@ def test_ci_process_command(tmpdir): @pytest.mark.skipif( - sys.platform == "win32", reason="Reliance on bash script ot supported on Windows" + sys.platform == "win32", reason="Reliance on bash script not supported on Windows" ) def test_ci_process_command_fail(tmpdir, monkeypatch): import subprocess @@ -526,7 +526,7 @@ def test_ci_run_standalone_tests_missing_requirements( @pytest.mark.skipif( - sys.platform == "win32", reason="Reliance on bash script ot supported on Windows" + sys.platform == "win32", reason="Reliance on bash script not supported on Windows" ) def test_ci_run_standalone_tests_not_installed_junit( tmpdir, working_env, config, mock_packages, mock_test_stage, capfd @@ -547,7 +547,7 @@ def test_ci_run_standalone_tests_not_installed_junit( @pytest.mark.skipif( - sys.platform == "win32", reason="Reliance on bash script ot supported on Windows" + sys.platform == "win32", reason="Reliance on bash script not supported on Windows" ) def test_ci_run_standalone_tests_not_installed_cdash( tmpdir, working_env, config, mock_packages, mock_test_stage, capfd diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash index dac7f67f99..48e4c86b42 100755 --- a/share/spack/spack-completion.bash +++ b/share/spack/spack-completion.bash @@ -1738,7 +1738,7 @@ _spack_test() { _spack_test_run() { if $list_options then - SPACK_COMPREPLY="-h --help --alias --fail-fast --fail-first --externals --keep-stage --log-format --log-file --cdash-upload-url --cdash-build --cdash-site --cdash-track --cdash-buildstamp --help-cdash --clean --dirty" + SPACK_COMPREPLY="-h --help --alias --fail-fast --fail-first --externals -x --explicit --keep-stage --log-format --log-file --cdash-upload-url --cdash-build --cdash-site --cdash-track --cdash-buildstamp --help-cdash --clean --dirty" else _installed_packages fi