You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/03/15 01:26:38 UTC

[02/50] [abbrv] incubator-mynewt-newt git commit: Clarify test result status message.

Clarify test result status message.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/21aa9174
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/21aa9174
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/21aa9174

Branch: refs/heads/master
Commit: 21aa917424b3563d14686ba71dc74ea09dee8464
Parents: b5850ea
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Mar 11 13:25:02 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Mar 11 13:29:06 2016 -0800

----------------------------------------------------------------------
 newt/cli/build_cmds.go | 25 +++++++++++++------------
 newt/cli/util.go       | 13 +++++++++++++
 2 files changed, 26 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/21aa9174/newt/cli/build_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go
index 492c505..307a094 100644
--- a/newt/cli/build_cmds.go
+++ b/newt/cli/build_cmds.go
@@ -20,7 +20,7 @@
 package cli
 
 import (
-	"bytes"
+	"fmt"
 	"os"
 
 	"github.com/spf13/cobra"
@@ -145,6 +145,7 @@ func testRunCmd(cmd *cobra.Command, args []string) {
 		}
 	}
 
+	passedPkgs := []*pkg.LocalPackage{}
 	failedPkgs := []*pkg.LocalPackage{}
 	for _, pack := range packs {
 		// Reset the global project for the next test.
@@ -171,23 +172,23 @@ func testRunCmd(cmd *cobra.Command, args []string) {
 		if err == nil {
 			err = b.Test(pack)
 		}
-		if err != nil {
+		if err == nil {
+			passedPkgs = append(passedPkgs, pack)
+		} else {
 			failedPkgs = append(failedPkgs, pack)
 		}
 	}
 
+	passStr := fmt.Sprintf("Passed tests: [%s]", PackageNameList(passedPkgs))
+	failStr := fmt.Sprintf("Failed tests: [%s]", PackageNameList(failedPkgs))
+
 	if len(failedPkgs) > 0 {
-		var buffer bytes.Buffer
-		for i, pack := range failedPkgs {
-			if i != 0 {
-				buffer.WriteString(" ")
-			}
-			buffer.WriteString(pack.Name())
-		}
-		NewtUsage(nil, util.NewNewtError("Tests failed for: ["+buffer.String()+
-			"]"))
+		NewtUsage(nil, util.FmtNewtError("Test failure(s):\n%s\n%s", passStr,
+			failStr))
+	} else {
+		util.StatusMessage(util.VERBOSITY_DEFAULT, "%s\n", passStr)
+		util.StatusMessage(util.VERBOSITY_DEFAULT, "All tests passed\n")
 	}
-	util.StatusMessage(util.VERBOSITY_DEFAULT, "All tests passed\n")
 }
 
 func downloadRunCmd(cmd *cobra.Command, args []string) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/21aa9174/newt/cli/util.go
----------------------------------------------------------------------
diff --git a/newt/cli/util.go b/newt/cli/util.go
index 68df043..fba262a 100644
--- a/newt/cli/util.go
+++ b/newt/cli/util.go
@@ -20,6 +20,7 @@
 package cli
 
 import (
+	"bytes"
 	"fmt"
 	"log"
 	"os"
@@ -167,3 +168,15 @@ func ResolvePackage(name string) (*pkg.LocalPackage, error) {
 
 	return pack.(*pkg.LocalPackage), nil
 }
+
+func PackageNameList(pkgs []*pkg.LocalPackage) string {
+	var buffer bytes.Buffer
+	for i, pack := range pkgs {
+		if i != 0 {
+			buffer.WriteString(" ")
+		}
+		buffer.WriteString(pack.Name())
+	}
+
+	return buffer.String()
+}