You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2026/10/12 10:49:44 UTC
(mynewt-newt) 08/09: newt/cli: Report test build failures separately
This is an automated email from the ASF dual-hosted git repository.
sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit ed827599b4f59bffa79f42beedc79655150b4db0
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Fri Oct 9 15:29:44 2026 +0200
newt/cli: Report test build failures separately
Unit tests that failed to build were reported as failed tests,
making it hard to tell compilation errors from test failures.
Build and execute tests in separate steps and list packages that
failed to build in their own "Build failures" summary line.
Assisted-by: Claude:claude-opus-5-5
---
newt/builder/selftest.go | 5 +++++
newt/cli/build_cmds.go | 24 +++++++++++++++++-------
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/newt/builder/selftest.go b/newt/builder/selftest.go
index 9b3c222f..97b03651 100644
--- a/newt/builder/selftest.go
+++ b/newt/builder/selftest.go
@@ -84,6 +84,11 @@ func (t *TargetBuilder) SelfTestExecute() error {
return err
}
+ return t.SelfTestRun()
+}
+
+// SelfTestRun executes a test previously built with SelfTestCreateExe().
+func (t *TargetBuilder) SelfTestRun() error {
testRpkg, err := t.getTestRpkg()
if err != nil {
return err
diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go
index f52c4bc8..f1a531cb 100644
--- a/newt/cli/build_cmds.go
+++ b/newt/cli/build_cmds.go
@@ -337,6 +337,7 @@ func testRunCmd(cmd *cobra.Command, args []string, exclude string, executeShell
passedPkgs := []*pkg.LocalPackage{}
failedPkgs := []*pkg.LocalPackage{}
+ buildFailedPkgs := []*pkg.LocalPackage{}
for _, pack := range packs {
// Reset the global state for the next test.
if err := ResetGlobalState(); err != nil {
@@ -356,21 +357,30 @@ func testRunCmd(cmd *cobra.Command, args []string, exclude string, executeShell
util.StatusMessage(util.VERBOSITY_DEFAULT, "Testing package %s\n",
pack.FullName())
- err = b.SelfTestExecute()
- if err == nil {
- passedPkgs = append(passedPkgs, pack)
- } else {
+ if err := b.SelfTestCreateExe(); err != nil {
+ util.StatusMessage(util.VERBOSITY_QUIET,
+ "Build failure (%s):\n%s", pack.Name(), err.Error())
+ buildFailedPkgs = append(buildFailedPkgs, pack)
+ continue
+ }
+
+ if err := b.SelfTestRun(); err != nil {
util.StatusMessage(util.VERBOSITY_QUIET, "%s", err.Error())
failedPkgs = append(failedPkgs, pack)
+ continue
}
+
+ passedPkgs = append(passedPkgs, pack)
}
passStr := fmt.Sprintf("Passed tests: [%s]", PackageNameList(passedPkgs))
failStr := fmt.Sprintf("Failed tests: [%s]", PackageNameList(failedPkgs))
+ buildFailStr := fmt.Sprintf("Build failures: [%s]",
+ PackageNameList(buildFailedPkgs))
- if len(failedPkgs) > 0 {
- NewtUsage(nil, util.FmtNewtError("Test failure(s):\n%s\n%s", passStr,
- failStr))
+ if len(failedPkgs) > 0 || len(buildFailedPkgs) > 0 {
+ NewtUsage(nil, util.FmtNewtError("Test failure(s):\n%s\n%s\n%s",
+ passStr, failStr, buildFailStr))
} else {
util.StatusMessage(util.VERBOSITY_DEFAULT, "%s\n", passStr)
util.StatusMessage(util.VERBOSITY_DEFAULT, "All tests passed\n")