summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorScott Wittenburg <scott.wittenburg@kitware.com>2019-04-06 16:30:35 -0600
committerTodd Gamblin <tgamblin@llnl.gov>2019-04-06 15:30:34 -0700
commit361661780416f333f1aab2d3aad71b4ca2ea2151 (patch)
treefccc1588533fc073bd3e3d981dbc1da83cde16b3 /lib
parent90c7c74334eaa6818b9c66b1808c80c255fd7f0e (diff)
downloadspack-361661780416f333f1aab2d3aad71b4ca2ea2151.tar.gz
spack-361661780416f333f1aab2d3aad71b4ca2ea2151.tar.bz2
spack-361661780416f333f1aab2d3aad71b4ca2ea2151.tar.xz
spack-361661780416f333f1aab2d3aad71b4ca2ea2151.zip
Allow spack install to take either cdash stamp or track (#11106)
When providing a track, the cdash reporter will format the stamp itself, as it has always done, and register the build during the package installation process. When providing a stamp, it should first be formatted as cdash expects, and then cdash will be sure to report results to same build id which was registered manually elsewhere.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/install.py11
-rw-r--r--lib/spack/spack/reporters/cdash.py9
-rw-r--r--lib/spack/spack/test/cmd/install.py28
3 files changed, 44 insertions, 4 deletions
diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py
index 5524324094..1570309a58 100644
--- a/lib/spack/spack/cmd/install.py
+++ b/lib/spack/spack/cmd/install.py
@@ -153,12 +153,21 @@ Defaults to spec of the package to install."""
help="""The site name that will be reported to CDash.
Defaults to current system hostname."""
)
- subparser.add_argument(
+ cdash_subgroup = subparser.add_mutually_exclusive_group()
+ cdash_subgroup.add_argument(
'--cdash-track',
default='Experimental',
help="""Results will be reported to this group on CDash.
Defaults to Experimental."""
)
+ cdash_subgroup.add_argument(
+ '--cdash-buildstamp',
+ default=None,
+ help="""Instead of letting the CDash reporter prepare the
+buildstamp which, when combined with build name, site and project,
+uniquely identifies the build, provide this argument to identify
+the build yourself. Format: %%Y%%m%%d-%%H%%M-[cdash-track]"""
+ )
arguments.add_common_arguments(subparser, ['yes_to_all'])
diff --git a/lib/spack/spack/reporters/cdash.py b/lib/spack/spack/reporters/cdash.py
index 328863dfed..d9c7c9d697 100644
--- a/lib/spack/spack/reporters/cdash.py
+++ b/lib/spack/spack/reporters/cdash.py
@@ -72,9 +72,12 @@ class CDash(Reporter):
self.site = args.cdash_site or socket.gethostname()
self.osname = platform.system()
self.endtime = int(time.time())
- buildstamp_format = "%Y%m%d-%H%M-{0}".format(args.cdash_track)
- self.buildstamp = time.strftime(buildstamp_format,
- time.localtime(self.endtime))
+ if args.cdash_buildstamp:
+ self.buildstamp = args.cdash_buildstamp
+ else:
+ buildstamp_format = "%Y%m%d-%H%M-{0}".format(args.cdash_track)
+ self.buildstamp = time.strftime(buildstamp_format,
+ time.localtime(self.endtime))
self.buildId = None
self.revision = ''
git = which('git')
diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py
index 1645cd4b0e..29172538bc 100644
--- a/lib/spack/spack/test/cmd/install.py
+++ b/lib/spack/spack/test/cmd/install.py
@@ -8,6 +8,7 @@ import os
import filecmp
import re
from six.moves import builtins
+import time
import pytest
@@ -506,6 +507,33 @@ def test_cdash_upload_extra_params(tmpdir, mock_fetch, install_mockery, capfd):
@pytest.mark.disable_clean_stage_check
+def test_cdash_buildstamp_param(tmpdir, mock_fetch, install_mockery, capfd):
+ # capfd interferes with Spack's capturing
+ with capfd.disabled():
+ with tmpdir.as_cwd():
+ cdash_track = 'some_mocked_track'
+ buildstamp_format = "%Y%m%d-%H%M-{0}".format(cdash_track)
+ buildstamp = time.strftime(buildstamp_format,
+ time.localtime(int(time.time())))
+ with pytest.raises((HTTPError, URLError)):
+ install(
+ '--log-file=cdash_reports',
+ '--cdash-build=my_custom_build',
+ '--cdash-site=my_custom_site',
+ '--cdash-buildstamp={0}'.format(buildstamp),
+ '--cdash-upload-url=http://localhost/fakeurl/submit.php?project=Spack',
+ 'a')
+ report_dir = tmpdir.join('cdash_reports')
+ assert report_dir in tmpdir.listdir()
+ report_file = report_dir.join('Build.xml')
+ assert report_file in report_dir.listdir()
+ content = report_file.open().read()
+ assert 'Site BuildName="my_custom_build"' in content
+ assert 'Name="my_custom_site"' in content
+ assert buildstamp 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):