main.mx raw

   1  // FailNow ends the run: Moxie has no recover, so a fatal test cannot unwind
   2  // just its own body. This fixture must exit non-zero and say why.
   3  package main
   4  
   5  import "testing"
   6  
   7  func TestFatalEndsTheRun(t *testing.T) {
   8  	t.Fatal("fatal worked")
   9  	println("unreachable after Fatal")
  10  }
  11  
  12  func TestNeverRuns(t *testing.T) {
  13  	println("should-not-print")
  14  }
  15  
  16  func main() {
  17  	// Termination: a batch program must still be stoppable, so the entry
  18  	// handles the channel the runtime closes on SIGINT/SIGTERM.
  19  	select {
  20  	case <-shutdown:
  21  		return
  22  	default:
  23  	}
  24  
  25  	testing.Main([]testing.InternalTest{
  26  		{Name: "TestFatalEndsTheRun", F: TestFatalEndsTheRun},
  27  		{Name: "TestNeverRuns", F: TestNeverRuns},
  28  	})
  29  }
  30