From 512f8d14d28ab4fe0667905b899efed1f785c755 Mon Sep 17 00:00:00 2001 From: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> Date: Tue, 25 Oct 2022 12:32:55 -0700 Subject: feature: Add -x|--explicit option to 'spack test run' (#32910) --- lib/spack/spack/cmd/test.py | 18 ++++++++++++++++-- lib/spack/spack/test/ci.py | 8 ++++---- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'lib') 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 @@ environment variables: 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 @@ environment variables: 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 @@ environment variables: # 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 -- cgit v1.2.3-60-g2f50