Exemple #1
0
func RunBenchmark(path string, b *testing.B) {
	logger := golog.NewLogger("tritium")
	logger.AddProcessor("info", golog.NewConsoleProcessor(golog.LOG_INFO, true))

	spec, err := spec.LoadSpec(path, pkg)

	if err != nil {
		panic(fmt.Sprintf("Error loading test spec at (%v) :\n%v\n", path, err.Error()))
	}
	debugger := &dummy.DummyDebugger{}
	eng := whale.NewEngine(debugger)

	b.StartTimer()
	d, _ := time.ParseDuration("1m")

	for i := 0; i < b.N; i++ {
		eng.Run(spec.Script, nil, spec.Input, spec.Vars, time.Now().Add(d), "test", "test", "test", false)
	}
}
Exemple #2
0
func RunTest(path string) (result *spec.Result) {
	result = spec.NewResult()

	logger := golog.NewLogger("tritium")
	logger.AddProcessor("info", golog.NewConsoleProcessor(golog.LOG_INFO, true))

	/*** TODO(SJ) : Reintegrate w new log system. We need to catch errors when running tests
	defer func() {
		if x := recover(); x != nil {
			err, ok := x.(error)
			if ok {
				logger.Error(path + " === " + err.Error() + "\n\n" + string(debug.Stack()))
			} else {
				logger.Error(path + " === " + x.(string) + "\n\n" + string(debug.Stack()))
			}
		}
		for _, rec := range logWriter.Logs {
			error := log4go.FormatLogRecord("[%D %T] [%L] (%S) %M", rec)
			result.Error(path, error)
		}
	}()
	*/

	spec, err := spec.LoadSpec(path, pkg)

	if err != nil {
		result.Error(path, fmt.Sprintf("Error loading test spec:\n%v\n", err.Error()))
		return
	}
	debugger := &dummy.DummyDebugger{}
	eng := whale.NewEngine(debugger)
	d, _ := time.ParseDuration("1m")
	result.Merge(spec.Compare(eng.Run(spec.Script, nil, spec.Input, spec.Vars, time.Now().Add(d), "test", "test", "test", false)))

	return
}