From 82041ac5a30ec551fd45b8db3ae8ee4366d3a1aa Mon Sep 17 00:00:00 2001 From: Zack Galbreath Date: Fri, 10 Feb 2023 13:01:05 -0500 Subject: Restore our ability to submit build/test results to CDash from GitLab CI (#35328) * Restore our ability to submit build/test results to CDash from GitLab CI * Don't use CDash upload URL as report filename --- lib/spack/spack/cmd/ci.py | 3 +-- lib/spack/spack/cmd/test.py | 24 ++++++++++++------------ lib/spack/spack/test/cmd/test.py | 23 +++++++++++++++++++++++ 3 files changed, 36 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/cmd/ci.py b/lib/spack/spack/cmd/ci.py index 1b695284b8..aadc47fc2c 100644 --- a/lib/spack/spack/cmd/ci.py +++ b/lib/spack/spack/cmd/ci.py @@ -530,10 +530,9 @@ def ci_rebuild(args): if not verify_binaries: install_args.append("--no-check-signature") - cdash_args = [] if cdash_handler: # Add additional arguments to `spack install` for CDash reporting. - cdash_args.extend(cdash_handler.args()) + install_args.extend(cdash_handler.args()) slash_hash = "/{}".format(job_spec.dag_hash()) deps_install_args = install_args diff --git a/lib/spack/spack/cmd/test.py b/lib/spack/spack/cmd/test.py index f3248f4eb5..bac2f30f81 100644 --- a/lib/spack/spack/cmd/test.py +++ b/lib/spack/spack/cmd/test.py @@ -227,22 +227,22 @@ def test_run(args): ) +def report_filename(args, test_suite): + if args.log_file: + if os.path.isabs(args.log_file): + return args.log_file + else: + log_dir = os.getcwd() + return os.path.join(log_dir, args.log_file) + else: + return os.path.join(os.getcwd(), "test-%s" % test_suite.name) + + def create_reporter(args, specs_to_test, test_suite): if args.log_format is None: return None - filename = args.cdash_upload_url - if not filename: - if args.log_file: - if os.path.isabs(args.log_file): - log_file = args.log_file - else: - log_dir = os.getcwd() - log_file = os.path.join(log_dir, args.log_file) - else: - log_file = os.path.join(os.getcwd(), "test-%s" % test_suite.name) - filename = log_file - + filename = report_filename(args, test_suite) context_manager = spack.report.test_context_manager( reporter=args.reporter(), filename=filename, diff --git a/lib/spack/spack/test/cmd/test.py b/lib/spack/spack/test/cmd/test.py index 14cf5c3c6b..b76d0494df 100644 --- a/lib/spack/spack/test/cmd/test.py +++ b/lib/spack/spack/test/cmd/test.py @@ -319,3 +319,26 @@ def test_test_results_status(mock_packages, mock_test_stage, status, expected): else: assert status in results assert expected in results + + +@pytest.mark.regression("35337") +def test_report_filename_for_cdash(install_mockery_mutable_config, mock_fetch): + """Test that the temporary file used to write Testing.xml for CDash is not the upload URL""" + name = "trivial" + spec = spack.spec.Spec("trivial-smoke-test").concretized() + suite = spack.install_test.TestSuite([spec], name) + suite.ensure_stage() + + parser = argparse.ArgumentParser() + spack.cmd.test.setup_parser(parser) + args = parser.parse_args( + [ + "run", + "--cdash-upload-url=https://blahblah/submit.php?project=debugging", + "trivial-smoke-test", + ] + ) + + spack.cmd.common.arguments.sanitize_reporter_options(args) + filename = spack.cmd.test.report_filename(args, suite) + assert filename != "https://blahblah/submit.php?project=debugging" -- cgit v1.2.3-60-g2f50