From 295377b2b4695f30e79f4bd877fd85476a8febb9 Mon Sep 17 00:00:00 2001 From: Zack Galbreath Date: Tue, 27 Apr 2021 14:20:32 -0400 Subject: Don't report configure errors to CDash for successful packages (#23286) Convert configure errors detected by our log scraper into warnings when the package being installed reports that it was successful. --- lib/spack/spack/reporters/cdash.py | 18 ++++++------ lib/spack/spack/test/cmd/install.py | 19 +++++++++++++ .../packages/configure-warning/package.py | 33 ++++++++++++++++++++++ 3 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 var/spack/repos/builtin.mock/packages/configure-warning/package.py diff --git a/lib/spack/spack/reporters/cdash.py b/lib/spack/spack/reporters/cdash.py index 7adee52917..36660fa890 100644 --- a/lib/spack/spack/reporters/cdash.py +++ b/lib/spack/spack/reporters/cdash.py @@ -161,14 +161,21 @@ class CDash(Reporter): report_data[phase]['log'] = \ '\n'.join(report_data[phase]['loglines']) errors, warnings = parse_log_events(report_data[phase]['loglines']) + + # Convert errors to warnings if the package reported success. + if package['result'] == 'success': + warnings = errors + warnings + errors = [] + # Cap the number of errors and warnings at 50 each. errors = errors[:50] warnings = warnings[:50] nerrors = len(errors) - if phase == 'configure' and nerrors > 0: - report_data[phase]['status'] = 1 + if nerrors > 0: self.success = False + if phase == 'configure': + report_data[phase]['status'] = 1 if phase == 'build': # Convert log output from ASCII to Unicode and escape for XML. @@ -189,13 +196,6 @@ class CDash(Reporter): event['source_file']) return event - # Convert errors to warnings if the package reported success. - if package['result'] == 'success': - warnings = errors + warnings - errors = [] - else: - self.success = False - report_data[phase]['errors'] = [] report_data[phase]['warnings'] = [] for error in errors: diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py index 674897b933..73d701c06f 100644 --- a/lib/spack/spack/test/cmd/install.py +++ b/lib/spack/spack/test/cmd/install.py @@ -743,6 +743,25 @@ def test_cdash_auth_token(tmpdir, install_mockery, capfd): assert 'Using CDash auth token from environment' in out +@pytest.mark.disable_clean_stage_check +def test_cdash_configure_warning(tmpdir, mock_fetch, install_mockery, capfd): + # capfd interferes with Spack's capturing of e.g., Build.xml output + with capfd.disabled(): + with tmpdir.as_cwd(): + # Test would fail if install raised an error. + install( + '--log-file=cdash_reports', + '--log-format=cdash', + 'configure-warning') + # Verify Configure.xml exists with expected contents. + 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() + assert 'foo: No such file or directory' in content + + def test_compiler_bootstrap( install_mockery_mutable_config, mock_packages, mock_fetch, mock_archive, mutable_config, monkeypatch): diff --git a/var/spack/repos/builtin.mock/packages/configure-warning/package.py b/var/spack/repos/builtin.mock/packages/configure-warning/package.py new file mode 100644 index 0000000000..4163366d17 --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/configure-warning/package.py @@ -0,0 +1,33 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class ConfigureWarning(AutotoolsPackage): + """This package prints output that looks like an error during configure, but + it actually installs successfully.""" + + homepage = "http://www.example.com" + url = "http://www.example.com/configure-warning-1.0.tar.gz" + + version('1.0', '0123456789abcdef0123456789abcdef') + + parallel = False + + def autoreconf(self, spec, prefix): + pass + + def configure(self, spec, prefix): + print('foo: No such file or directory') + return 0 + + def build(self, spec, prefix): + pass + + def install(self, spec, prefix): + # sanity_check_prefix requires something in the install directory + # Test requires overriding the one provided by `AutotoolsPackage` + mkdirp(prefix.bin) -- cgit v1.2.3-60-g2f50