github.com/MetalBlockchain/metalgo@v1.11.9/tests/colors.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package tests
     5  
     6  import (
     7  	"github.com/onsi/ginkgo/v2/formatter"
     8  
     9  	ginkgo "github.com/onsi/ginkgo/v2"
    10  )
    11  
    12  // Outputs to stdout.
    13  //
    14  // Examples:
    15  //
    16  //   - Out("{{green}}{{bold}}hi there %q{{/}}", "aa")
    17  //   - Out("{{magenta}}{{bold}}hi therea{{/}} {{cyan}}{{underline}}b{{/}}")
    18  //
    19  // See https://github.com/onsi/ginkgo/blob/v2.0.0/formatter/formatter.go#L52-L73
    20  // for an exhaustive list of color options.
    21  func Outf(format string, args ...interface{}) {
    22  	s := formatter.F(format, args...)
    23  	// Use GinkgoWriter to ensure that output from this function is
    24  	// printed sequentially within other test output produced with
    25  	// GinkgoWriter (e.g. `STEP:...`) when tests are run in
    26  	// parallel. ginkgo collects and writes stdout separately from
    27  	// GinkgoWriter during parallel execution and the resulting output
    28  	// can be confusing.
    29  	ginkgo.GinkgoWriter.Print(s)
    30  }