...

Source file src/gotest.tools/v3/icmd/internal/stub/main.go

Documentation: gotest.tools/v3/icmd/internal/stub

     1  // Package main produces a test-binary used in tests.
     2  package main
     3  
     4  import (
     5  	"flag"
     6  	"fmt"
     7  	"os"
     8  	"time"
     9  )
    10  
    11  func main() {
    12  	sleep := flag.Duration("sleep", 0, "Sleep")
    13  	warn := flag.Bool("warn", false, "Warn")
    14  	fail := flag.Int("fail", 0, "Fail with code")
    15  	flag.Parse()
    16  
    17  	if *sleep != 0 {
    18  		time.Sleep(*sleep)
    19  	}
    20  
    21  	fmt.Println("this is stdout")
    22  	if *warn {
    23  		fmt.Fprintln(os.Stderr, "this is stderr")
    24  	}
    25  
    26  	os.Exit(*fail)
    27  }
    28  

View as plain text