From b8bd40e6854d0d6042440b1a8db40276c5476853 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 19 Sep 2015 19:41:31 -0700 Subject: [PATCH] Disable JSON based testing, reduce ls tests to its context only --- buildscripts/checkdeps.sh | 4 ++-- error.go | 4 ++-- ls.go | 1 - ls_test.go | 42 +++++++++++++++++++-------------------- mc_test.go | 2 -- 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/buildscripts/checkdeps.sh b/buildscripts/checkdeps.sh index e798bcd1..e6e7e535 100755 --- a/buildscripts/checkdeps.sh +++ b/buildscripts/checkdeps.sh @@ -21,7 +21,7 @@ _init() { ## Minimum required versions for build dependencies GCC_VERSION="4.0" - CLANG_VERSION="3.5" + CLANG_VERSION="7.0.0" YASM_VERSION="1.2.0" GIT_VERSION="1.0" GO_VERSION="1.5.1" @@ -189,7 +189,7 @@ check_deps() { fi ;; "Darwin") - check_version "$(env gcc --version 2>/dev/null | sed 's/^.* \([0-9.]*\).*$/\1/' | head -1)" "${CLANG_VERSION}" + check_version "$(env gcc --version 2>/dev/null | awk '{print $4}' | head -1)" "${CLANG_VERSION}" if [ $? -ge 2 ]; then MISSING="${MISSING} xcode-cli(${CLANG_VERSION})" fi diff --git a/error.go b/error.go index 87ec6bfc..17da5ed6 100644 --- a/error.go +++ b/error.go @@ -19,6 +19,7 @@ package main import ( "encoding/json" "fmt" + "os" "github.com/minio/mc/pkg/console" "github.com/minio/minio/pkg/probe" @@ -57,7 +58,7 @@ func fatalIf(err *probe.Error, msg string) { console.Fatalln(probe.NewError(err)) } console.Println(string(json)) - console.Fatal("") + os.Exit(1) } if !globalDebugFlag { console.Fatalln(fmt.Sprintf("%s %s", msg, err.ToGoError())) @@ -89,7 +90,6 @@ func errorIf(err *probe.Error, msg string) { console.Fatalln(probe.NewError(err)) } console.Println(string(json)) - console.Error("") return } if !globalDebugFlag { diff --git a/ls.go b/ls.go index cb429214..fda6a02c 100644 --- a/ls.go +++ b/ls.go @@ -80,7 +80,6 @@ func parseContent(c *client.Content) ContentMessage { }() content.Size = c.Size - // Convert OS Type to match console file printing style. content.Name = func() string { switch { diff --git a/ls_test.go b/ls_test.go index 10c7dd2f..6dc9bb26 100644 --- a/ls_test.go +++ b/ls_test.go @@ -23,20 +23,18 @@ import ( "path/filepath" "strconv" - "github.com/minio/mc/pkg/client" "github.com/minio/mc/pkg/console" "github.com/minio/minio/pkg/probe" . "gopkg.in/check.v1" ) -func (s *TestSuite) TestLS(c *C) { +func (s *TestSuite) TestLSContext(c *C) { /// filesystem root, err := ioutil.TempDir(os.TempDir(), "cmd-") c.Assert(err, IsNil) defer os.RemoveAll(root) var perr *probe.Error - for i := 0; i < 10; i++ { objectPath := filepath.Join(root, "object"+strconv.Itoa(i)) data := "hello" @@ -45,16 +43,6 @@ func (s *TestSuite) TestLS(c *C) { c.Assert(perr, IsNil) } - var clnt client.Client - clnt, perr = target2Client(root) - c.Assert(perr, IsNil) - - perr = doList(clnt, false, false) - c.Assert(perr, IsNil) - - perr = doList(clnt, true, false) - c.Assert(perr, IsNil) - for i := 0; i < 10; i++ { objectPath := server.URL + "/bucket/object" + strconv.Itoa(i) data := "hello" @@ -63,18 +51,28 @@ func (s *TestSuite) TestLS(c *C) { c.Assert(perr, IsNil) } - clnt, perr = target2Client(server.URL + "/bucket") - c.Assert(perr, IsNil) + err = app.Run([]string{os.Args[0], "ls", root}) + c.Assert(err, IsNil) + c.Assert(console.IsError, Equals, false) - perr = doList(clnt, false, false) - c.Assert(perr, IsNil) + // reset back + console.IsExited = false - perr = doList(clnt, true, false) - c.Assert(perr, IsNil) -} + err = app.Run([]string{os.Args[0], "ls", root + "..."}) + c.Assert(err, IsNil) + c.Assert(console.IsError, Equals, false) -func (s *TestSuite) TestLSContext(c *C) { - err := app.Run([]string{os.Args[0], "ls", server.URL + "/bucket"}) + // reset back + console.IsExited = false + + err = app.Run([]string{os.Args[0], "ls", server.URL + "/bucket"}) + c.Assert(err, IsNil) + c.Assert(console.IsError, Equals, false) + + // reset back + console.IsExited = false + + err = app.Run([]string{os.Args[0], "ls", server.URL + "/bucket..."}) c.Assert(err, IsNil) c.Assert(console.IsError, Equals, false) diff --git a/mc_test.go b/mc_test.go index a394f6dc..2b28f351 100644 --- a/mc_test.go +++ b/mc_test.go @@ -50,8 +50,6 @@ func (s *TestSuite) SetUpSuite(c *C) { // do not set it elsewhere, leads to data races since this is a global flag globalQuietFlag = true // quiet is set to turn of progress bar - // do not set it elsewhere, leads to data races since this is a global flag - globalJSONFlag = true // json is set to avoid printing colors upon terminals tmpDir, err := ioutil.TempDir(os.TempDir(), "cmd-") c.Assert(err, IsNil)