mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccoll...@apache.org
Subject [2/2] incubator-mynewt-newt git commit: newt - Allow unit tests to be cleaned.
Date Thu, 08 Dec 2016 22:51:37 GMT
newt - Allow unit tests to be cleaned.


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/1d80b049
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/1d80b049
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/1d80b049

Branch: refs/heads/develop
Commit: 1d80b049c5bc1dd65828929b838194d843363971
Parents: 482873d
Author: Christopher Collins <ccollins@apache.org>
Authored: Thu Dec 8 16:51:00 2016 -0600
Committer: Christopher Collins <ccollins@apache.org>
Committed: Thu Dec 8 16:51:00 2016 -0600

----------------------------------------------------------------------
 newt/cli/build_cmds.go | 10 +++++-----
 newt/cli/util.go       | 33 ++++++++++++++++++---------------
 2 files changed, 23 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/1d80b049/newt/cli/build_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go
index 032e1a1..eb0a55e 100644
--- a/newt/cli/build_cmds.go
+++ b/newt/cli/build_cmds.go
@@ -182,9 +182,9 @@ func cleanRunCmd(cmd *cobra.Command, args []string) {
 		if arg == TARGET_KEYWORD_ALL {
 			cleanAll = true
 		} else {
-			t := ResolveTarget(arg)
-			if t == nil {
-				NewtUsage(cmd, util.NewNewtError("invalid target name: "+arg))
+			t, err := ResolveTargetOrUnittest(arg)
+			if err != nil {
+				NewtUsage(cmd, err)
 			}
 			targets = append(targets, t)
 		}
@@ -260,7 +260,7 @@ func testRunCmd(cmd *cobra.Command, args []string) {
 			NewtUsage(nil, err)
 		}
 
-		t, err := ResolveUnittestTarget(pack.Name())
+		t, err := ResolveUnittest(pack.Name())
 		if err != nil {
 			NewtUsage(nil, err)
 		}
@@ -381,7 +381,7 @@ func AddBuildCommands(cmd *cobra.Command) {
 
 	cmd.AddCommand(cleanCmd)
 	AddTabCompleteFn(cleanCmd, func() []string {
-		return append(targetList(), "all")
+		return append(append(targetList(), unittestList()...), "all")
 	})
 
 	testCmd := &cobra.Command{

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/1d80b049/newt/cli/util.go
----------------------------------------------------------------------
diff --git a/newt/cli/util.go b/newt/cli/util.go
index 9b5bfe6..6c736de 100644
--- a/newt/cli/util.go
+++ b/newt/cli/util.go
@@ -214,7 +214,7 @@ func InitProject() *project.Project {
 	return p
 }
 
-func ResolveUnittestTarget(pkgName string) (*target.Target, error) {
+func ResolveUnittest(pkgName string) (*target.Target, error) {
 	// Each unit test package gets its own target.  This target is a copy
 	// of the base unit test package, just with an appropriate name.  The
 	// reason each test needs a unique target is: syscfg and sysinit are
@@ -245,19 +245,11 @@ func ResolveUnittestTarget(pkgName string) (*target.Target, error) {
 	return t, nil
 }
 
-func TargetBuilderForTargetOrUnittest(pkgName string) (
-	*builder.TargetBuilder, error) {
-
+func ResolveTargetOrUnittest(pkgName string) (*target.Target, error) {
 	// Argument can specify either a target or a unittest package.  Determine
 	// which type the package is and construct a target builder appropriately.
-	t, err := resolveExistingTargetArg(pkgName)
-	if err == nil {
-		b, err := builder.NewTargetBuilder(t)
-		if err != nil {
-			return nil, err
-		}
-
-		return b, nil
+	if t, err := resolveExistingTargetArg(pkgName); err == nil {
+		return t, nil
 	}
 
 	// Package wasn't a target.  Try for a unittest.
@@ -275,14 +267,25 @@ func TargetBuilderForTargetOrUnittest(pkgName string) (
 			pkg.PackageTypeNames[pack.Type()])
 	}
 
-	t, err = ResolveUnittestTarget(pack.Name())
+	t, err := ResolveUnittest(pack.Name())
 	if err != nil {
 		return nil, err
 	}
 
-	b, err := builder.NewTargetTester(t, pack)
+	return t, nil
+}
+
+func TargetBuilderForTargetOrUnittest(pkgName string) (
+	*builder.TargetBuilder, error) {
+
+	t, err := ResolveTargetOrUnittest(pkgName)
 	if err != nil {
 		return nil, err
 	}
-	return b, nil
+
+	if t.Package().Type() == pkg.PACKAGE_TYPE_TARGET {
+		return builder.NewTargetBuilder(t)
+	} else {
+		return builder.NewTargetTester(t, t.Package())
+	}
 }


Mime
View raw message