From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.13815.1681834288521645276 for ; Tue, 18 Apr 2023 09:11:28 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@linux.microsoft.com header.s=default header.b=PXtmTP8Y; spf=pass (domain: linux.microsoft.com, ip: 13.77.154.182, mailfrom: mikuback@linux.microsoft.com) Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id 270F221C1E40; Tue, 18 Apr 2023 09:11:27 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 270F221C1E40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1681834288; bh=fP5ZG/9DdddmGpkyW//Rk/szP1uNLmD7lSqh9WFxvTA=; h=From:To:Cc:Subject:Date:From; b=PXtmTP8YXz8TXkq2qjSXW6zkFen2+AQ1dhYtpafdKL45wrazKeYSXMHZW0Zt77lnB ZcIhzEejlLaWuk8T9o9EnhDzKMe6Irr0LXqauf5ENCbzAA5oqaLvhbrhumqlx727iI P831vFWGL/j8Q9TEyzKWON4f7BQk4tqwyX25GDdA= From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Rebecca Cran , Liming Gao , Bob Feng , Yuwei Chen , Michael D Kinney , Sean Brogan Subject: [PATCH v1 1/1] BaseTools/Plugin: Clarify code coverage failure message Date: Tue, 18 Apr 2023 12:11:04 -0400 Message-Id: <20230418161104.595-1-mikuback@linux.microsoft.com> X-Mailer: git-send-email 2.40.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Kubacki HostBasedUnitTestRunner.py is a build plugin responsible for locating and executing host-based unit tests. Recently, commit 6bb00aa introduced support for the plugin to generate code coverage reports via lcov and OpenCppCoverage. The plugin has discovered unit tests by searching for executables with "Test" in the name for a while. However, the test coverage change makes assumptions about test presence when crafting the OpenCppCoverage command that ultimately fails with an ambiguous error message if no host-based unit tests are discovered (see "ERROR"). ``` SECTION - Run Host based Unit Tests SUBSECTION - Testing for architecture: X64 ERROR - UnitTest Coverage: Failed to generate cobertura format xml in single package. PROGRESS - --->Test Success: Host Unit Test Compiler Plugin NOOPT ``` This change preempts that message with a check in the plugin to determine if any host-based tests were discovered. If not, a message is printed with more guidance about how the developer should proceed to either (1) fix their tests so code coverage is generated as expected or (2) prevent the error message. New message: ``` SECTION - Run Host based Unit Tests SUBSECTION - Testing for architecture: X64 WARNING - UnitTest Coverage: No unit tests discovered. Test coverage will not be generated. Prevent this message by: 1. Adding host-based unit tests to this package 2. Ensuring tests have the word "Test" in their name 3. Disabling HostUnitTestCompilerPlugin in the package CI YAML file PROGRESS - --->Test Success: Host Unit Test Compiler Plugin NOOPT ``` Cc: Rebecca Cran Cc: Liming Gao Cc: Bob Feng Cc: Yuwei Chen Cc: Michael D Kinney Cc: Sean Brogan Signed-off-by: Michael Kubacki --- BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py | 13= +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRu= nner.py b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunne= r.py index 0e013c5f1a7f..a384b556294c 100644 --- a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py +++ b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py @@ -16,6 +16,7 @@ import edk2toollib.windows.locate_tools as locate_tools from edk2toolext.environment import shell_environment from edk2toollib.utility_functions import RunCmd from edk2toollib.utility_functions import GetHostInfo +from textwrap import dedent =20 =20 class HostBasedUnitTestRunner(IUefiBuildPlugin): @@ -84,6 +85,18 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin): else: raise NotImplementedError("Unsupported Operating System"= ) =20 + if not testList: + logging.warning(dedent(""" + UnitTest Coverage: + No unit tests discovered. Test coverage will not b= e generated. + + Prevent this message by: + 1. Adding host-based unit tests to this package + 2. Ensuring tests have the word "Test" in their na= me + 3. Disabling HostUnitTestCompilerPlugin in the pac= kage CI YAML file + """).strip()) + return 0 + for test in testList: # Configure output name if test uses cmocka. shell_env.set_shell_var( --=20 2.40.0.windows.1