github.com/mattdotmatt/gauge@v0.3.2-0.20160421115137-425a4cdccb62/execution/result/result.go (about) 1 // Copyright 2015 ThoughtWorks, Inc. 2 3 // This file is part of Gauge. 4 5 // Gauge is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 10 // Gauge is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 15 // You should have received a copy of the GNU General Public License 16 // along with Gauge. If not, see <http://www.gnu.org/licenses/>. 17 18 package result 19 20 import "github.com/getgauge/gauge/gauge_messages" 21 22 // Result represents execution result 23 type Result interface { 24 getPreHook() **(gauge_messages.ProtoHookFailure) 25 getPostHook() **(gauge_messages.ProtoHookFailure) 26 SetFailure() 27 } 28 29 // ExecTimeTracker is an interface for tracking execution time 30 type ExecTimeTracker interface { 31 AddExecTime(int64) 32 } 33 34 func GetProtoHookFailure(executionResult *gauge_messages.ProtoExecutionResult) *(gauge_messages.ProtoHookFailure) { 35 return &gauge_messages.ProtoHookFailure{StackTrace: executionResult.StackTrace, ErrorMessage: executionResult.ErrorMessage, ScreenShot: executionResult.ScreenShot} 36 } 37 38 func AddPreHook(result Result, executionResult *gauge_messages.ProtoExecutionResult) { 39 if executionResult.GetFailed() { 40 *(result.getPreHook()) = GetProtoHookFailure(executionResult) 41 result.SetFailure() 42 } 43 } 44 45 func AddPostHook(result Result, executionResult *gauge_messages.ProtoExecutionResult) { 46 if executionResult.GetFailed() { 47 *(result.getPostHook()) = GetProtoHookFailure(executionResult) 48 result.SetFailure() 49 } 50 }