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/10/04 03:46:51 UTC

incubator-mynewt-newt git commit: newt - Fix "clean unittest"

Repository: incubator-mynewt-newt
Updated Branches:
  refs/heads/develop c1479e9ba -> 21f833c96


newt - Fix "clean unittest"

Prior to this fix, this command was failing with the following error:

    Error: Target does not specify an app package (target.app)


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

Branch: refs/heads/develop
Commit: 21f833c9616e9b372c1cedd560f3f13dfa5bcc25
Parents: c1479e9
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Oct 3 20:46:13 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Oct 3 20:46:13 2016 -0700

----------------------------------------------------------------------
 newt/cli/build_cmds.go | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/21f833c9/newt/cli/build_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/build_cmds.go b/newt/cli/build_cmds.go
index 7c7fb9d..01cec7f 100644
--- a/newt/cli/build_cmds.go
+++ b/newt/cli/build_cmds.go
@@ -148,6 +148,16 @@ func buildRunCmd(cmd *cobra.Command, args []string) {
 	}
 }
 
+func cleanDir(path string) {
+	util.StatusMessage(util.VERBOSITY_VERBOSE,
+		"Cleaning directory %s\n", path)
+
+	err := os.RemoveAll(path)
+	if err != nil {
+		NewtUsage(nil, util.NewNewtError(err.Error()))
+	}
+}
+
 func cleanRunCmd(cmd *cobra.Command, args []string) {
 	if len(args) < 1 {
 		NewtUsage(cmd, util.NewNewtError("Must specify target"))
@@ -172,23 +182,10 @@ func cleanRunCmd(cmd *cobra.Command, args []string) {
 	}
 
 	if cleanAll {
-		path := builder.BinRoot()
-		util.StatusMessage(util.VERBOSITY_VERBOSE,
-			"Cleaning directory %s\n", path)
-
-		err := os.RemoveAll(path)
-		if err != nil {
-			NewtUsage(cmd, err)
-		}
+		cleanDir(builder.BinRoot())
 	} else {
 		for _, t := range targets {
-			b, err := builder.NewTargetBuilder(t, nil)
-			if err != nil {
-				NewtUsage(nil, err)
-			}
-			if err := b.Clean(); err != nil {
-				NewtUsage(cmd, err)
-			}
+			cleanDir(builder.TargetBinDir(t))
 		}
 	}
 }