func runTestsInternal(t *testing.T) {
	for _, suite := range registeredSuites {
		if t.Failed() && *fStopEarly {
			break
		}
		fmt.Printf("[----------] Running tests from %s\n", suite.Name)
		if suite.SetUp != nil {
			suite.SetUp()
		}
		for _, tf := range filterTestFunctions(suite) {
			fmt.Printf("[ RUN      ] %s.%s\n", suite.Name, tf.Name)
			startTime := time.Now()
			failures := runTestFunction(tf)
			runDuration := time.Since(startTime)
			for _, record := range failures {
				t.Fail()
				fmt.Printf(
					"%s:%d:\n%s\n\n",
					record.FileName,
					record.LineNumber,
					record.Error)
			}
			bannerMessage := "[       OK ]"
			if len(failures) != 0 {
				bannerMessage = "[  FAILED  ]"
			}
			var timeMessage string
			if runDuration >= 25*time.Millisecond {
				timeMessage = fmt.Sprintf(" (%s)", runDuration.String())
			}
			fmt.Printf(
				"%s %s.%s%s\n",
				bannerMessage,
				suite.Name,
				tf.Name,
				timeMessage)
			if t.Failed() && *fStopEarly {
				break
			}
		}
		if suite.TearDown != nil {
			suite.TearDown()
		}
		fmt.Printf("[----------] Finished with tests from %s\n", suite.Name)
	}
}
runTestsInternal does the real work of RunTests, which simply wraps it in a
sync.Once.
package ogletest
import (
	"bytes"
	"flag"
	"fmt"
	"path"
	"regexp"
	"runtime"
	"sync"
	"testing"
	"time"
	"github.com/smartystreets/assertions/internal/reqtrace"
)
var fTestFilter = flag.String(
	"ogletest.run",
	"",
	"Regexp for matching tests to run.")
var fStopEarly = flag.Bool(
	"ogletest.stop_early",
	false,
	"If true, stop after the first failure.")
var runTestsOnce sync.Once
func isAbortError(x interface{}) bool {
	_, ok := x.(abortError)
	return ok
}
func runTestFunction(tf TestFunction) (failures []FailureRecord) {
	currentlyRunningTest = newTestInfo()
	defer func() {
		currentlyRunningTest = nil
	}()
	ti := currentlyRunningTest
	var reportOutcome reqtrace.ReportFunc
	ti.Ctx, reportOutcome = reqtrace.Trace(ti.Ctx, tf.Name)
	setUpPanicked := false
	if tf.SetUp != nil {
		setUpPanicked = runWithProtection(func() { tf.SetUp(ti) })
	}
	if !setUpPanicked {
		runWithProtection(tf.Run)
	}
	if tf.TearDown != nil {
		runWithProtection(tf.TearDown)
	}
	ti.MockController.Finish()
	if len(ti.failureRecords) == 0 {
		reportOutcome(nil)
	} else {
		reportOutcome(fmt.Errorf("%v failure records", len(ti.failureRecords)))
	}
	return ti.failureRecords
}
func RunTests(t *testing.T) {
	runTestsOnce.Do(func() { runTestsInternal(t) })
}