github.com/onsi/ginkgo@v1.16.6-0.20211118180735-4e1925ba4c95/integration/_fixtures/flags_fixture/flags_test.go (about)

     1  package flags_test
     2  
     3  import (
     4  	"flag"
     5  	"fmt"
     6  	remapped "math"
     7  	_ "math/cmplx"
     8  	"time"
     9  
    10  	. "github.com/onsi/ginkgo"
    11  	. "github.com/onsi/ginkgo/integration/_fixtures/flags_fixture"
    12  	. "github.com/onsi/gomega"
    13  )
    14  
    15  var customFlag string
    16  
    17  func init() {
    18  	flag.StringVar(&customFlag, "customFlag", "default", "custom flag!")
    19  }
    20  
    21  var _ = Describe("Testing various flags", func() {
    22  	FDescribe("the focused set", func() {
    23  		It("should honor -cover", func() {
    24  			Ω(Tested()).Should(Equal("tested"))
    25  		})
    26  
    27  		It("should allow gcflags", func() {
    28  			fmt.Printf("NaN returns %T\n", remapped.NaN())
    29  		})
    30  
    31  		PIt("should honor -failOnPending and -noisyPendings")
    32  
    33  		Describe("smores", func() {
    34  			It("should honor -skip: marshmallow", func() {
    35  				println("marshmallow")
    36  			})
    37  
    38  			It("should honor -focus: chocolate", func() {
    39  				println("chocolate")
    40  			})
    41  		})
    42  
    43  		It("should detect races", func() {
    44  			var a string
    45  			c := make(chan interface{}, 0)
    46  			go func() {
    47  				a = "now you don't"
    48  				close(c)
    49  			}()
    50  			a = "now you see me"
    51  			println(a)
    52  			Eventually(c).Should(BeClosed())
    53  		})
    54  
    55  		It("should randomize A", func() {
    56  			println("RANDOM_A")
    57  		})
    58  
    59  		It("should randomize B", func() {
    60  			println("RANDOM_B")
    61  		})
    62  
    63  		It("should randomize C", func() {
    64  			println("RANDOM_C")
    65  		})
    66  
    67  		It("should honor -slow-spec-threshold", func() {
    68  			time.Sleep(100 * time.Millisecond)
    69  		})
    70  
    71  		It("should pass in additional arguments after '--' directly to the test process", func() {
    72  			fmt.Printf("CUSTOM_FLAG: %s", customFlag)
    73  		})
    74  	})
    75  
    76  	Describe("more smores", func() {
    77  		It("should not run these unless -focus is set", func() {
    78  			println("smores")
    79  		})
    80  	})
    81  
    82  	Describe("a failing test", func() {
    83  		It("should fail", func() {
    84  			Ω(true).Should(Equal(false))
    85  		})
    86  	})
    87  
    88  	Describe("a flaky test", func() {
    89  		runs := 0
    90  		It("should only pass the second time it's run", func() {
    91  			runs++
    92  			Ω(runs).Should(BeNumerically("==", 2))
    93  		})
    94  	})
    95  })