From 75487dca4437eb80ae0d9b81a2972cea6584af06 Mon Sep 17 00:00:00 2001 From: Scott Wittenburg Date: Thu, 14 Feb 2019 16:43:53 -0700 Subject: CDash: allow installing from spec.yaml (#10565) If the -f argument to install is used (rather than providing package specs on the command line), CDash throws an exception due to missing the installation command (the packages targeted for install). This fixes that behavior so CDash reporting succeeds in either case. --- lib/spack/spack/reporters/cdash.py | 10 +++++++++- lib/spack/spack/test/cmd/install.py | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/reporters/cdash.py b/lib/spack/spack/reporters/cdash.py index 6f6905fcca..328863dfed 100644 --- a/lib/spack/spack/reporters/cdash.py +++ b/lib/spack/spack/reporters/cdash.py @@ -59,7 +59,15 @@ class CDash(Reporter): Reporter.__init__(self, args) self.template_dir = os.path.join('reports', 'cdash') self.cdash_upload_url = args.cdash_upload_url - self.install_command = ' '.join(args.package) + if args.package: + packages = args.package + else: + packages = [] + for file in args.specfiles: + with open(file, 'r') as f: + s = spack.spec.Spec.from_yaml(f) + packages.append(s.format()) + self.install_command = ' '.join(packages) self.buildname = args.cdash_build or self.install_command self.site = args.cdash_site or socket.gethostname() self.osname = platform.system() diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py index 2b45fa25d7..98aa735960 100644 --- a/lib/spack/spack/test/cmd/install.py +++ b/lib/spack/spack/test/cmd/install.py @@ -503,6 +503,45 @@ def test_cdash_upload_extra_params(tmpdir, mock_fetch, install_mockery, capfd): assert '-my_custom_track' in content +@pytest.mark.disable_clean_stage_check +def test_cdash_install_from_spec_yaml(tmpdir, mock_fetch, install_mockery, + capfd, mock_packages, mock_archive, + config): + # capfd interferes with Spack's capturing + with capfd.disabled(): + with tmpdir.as_cwd(): + + spec_yaml_path = str(tmpdir.join('spec.yaml')) + + pkg_spec = Spec('a') + pkg_spec.concretize() + + with open(spec_yaml_path, 'w') as fd: + fd.write(pkg_spec.to_yaml(all_deps=True)) + + install( + '--log-format=cdash', + '--log-file=cdash_reports', + '--cdash-build=my_custom_build', + '--cdash-site=my_custom_site', + '--cdash-track=my_custom_track', + '-f', spec_yaml_path) + + report_dir = tmpdir.join('cdash_reports') + assert report_dir in tmpdir.listdir() + report_file = report_dir.join('Configure.xml') + assert report_file in report_dir.listdir() + content = report_file.open().read() + import re + install_command_regex = re.compile( + r'(.+)', + re.MULTILINE | re.DOTALL) + m = install_command_regex.search(content) + assert m + install_command = m.group(1) + assert 'a@' in install_command + + @pytest.mark.disable_clean_stage_check def test_build_error_output(tmpdir, mock_fetch, install_mockery, capfd): with capfd.disabled(): -- cgit v1.2.3-60-g2f50