ginkgo icon indicating copy to clipboard operation
ginkgo copied to clipboard

Disabling colors breaks test suite

Open siretart opened this issue 1 year ago • 4 comments

$ export GINKGO_NO_COLOR=true
$ make test
[...]
 FAIL: TestFormatter (0.00s)
 FAIL: TestCLIInternalSuite (0.02s)
 FAIL: TestTestingtproxy (0.01s)
 FAIL: TestReporters (0.09s)

I don't think my original implementation in #1464 had this issue though...

siretart avatar Nov 02 '24 12:11 siretart

hey - yeah the intent wasn't to support running the ginkgo test suite with the environment variable on. but i can dig into fixing it.

remind me again why you can't just use ginkgo -no-color?

onsi avatar Nov 02 '24 13:11 onsi

In Debian, we purposefully disable go111 modules to avoid downloading sources from the Internet. Instead, all dependencies come from the Debian archive. To do this at scale, we have helpers that set the appropriate environment variables and carefully construct the build trees. For better or worse, these helpers have the testing part of the Debian package build hardcoded with go test, and this is not easy to replace.

siretart avatar Nov 02 '24 17:11 siretart

@onsi Hey, can create multi suit in same path? I try write 2 suit in same file, run failed.

I want to diff case in diff suit, if right op? bucket_test.go

package test_test

import (
        "fmt"
        "net/http"
        "testing"

        . "github.com/onsi/ginkgo/v2"
        . "github.com/onsi/gomega"
)

func TestBucket(t *testing.T) {
        RegisterFailHandler(Fail)
        RunSpecs(t, "Bucket Suite")
}

var _ = Describe("Bucket", func() {
        Context("HeadBucket", func() {
                It("normal request, http statu 200", func() {
                        url := "https://example.com"
                        resp, err := http.Head(url)
                        if err != nil {
                                fmt.Println("Error:", err)
                                return
                        }
                        defer resp.Body.Close()
                })
        })

        Context("GetBucket", func() {
                It("should authenticate an admin user with valid token", func() {
                })
        })
})

func TestObject(t *testing.T) {
        RegisterFailHandler(Fail)
        RunSpecs(t, "Object Suite")
}

var _ = Describe("Object", func() {
        Context("HeadBucket", func() {
                It("normal request, http statu 200", func() {
                        url := "https://example.com"
                        resp, err := http.Head(url)
                        if err != nil {
                                fmt.Println("Error:", err)
                                return
                        }
                        defer resp.Body.Close()
                })
        })

        Context("GetBucket", func() {
                It("should authenticate an admin user with valid token", func() {
                })
        })
})
Rerunning Suite
  It looks like you are calling RunSpecs more than once. Ginkgo does not support
  rerunning suites.  If you want to rerun a suite try ginkgo --repeat=N or
  ginkgo --until-it-fails

  Learn more at:
  http://onsi.github.io/ginkgo/#repeating-spec-runs-and-managing-flaky-specs


Ginkgo ran 1 suite in 2.666139542s

zhaohuxing avatar Nov 05 '24 09:11 zhaohuxing

hey @zhaohuxing this looks like it should be a new, different issue. can you open one if you'd like to discuss it further?

For now: you don't need separate TestX or to call RunSpecs more than once. You simply need to define all the Ginkgo specs (and you can split them across multiple files in the same package) and Ginkgo will collect them all and run them all.

onsi avatar Nov 05 '24 12:11 onsi