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