onsi / ginkgo

A Modern Testing Framework for Go
http://onsi.github.io/ginkgo/
MIT License
8.38k stars 660 forks source link

Disabling colors breaks test suite #1469

Open siretart opened 2 weeks ago

siretart commented 2 weeks ago
$ 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...

onsi commented 2 weeks ago

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?

siretart commented 2 weeks ago

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.

zhaohuxing commented 2 weeks ago

@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
onsi commented 2 weeks ago

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.