本文整理匯總了Golang中github.com/getgauge/gauge/logger.Error函數的典型用法代碼示例。如果您正苦於以下問題:Golang Error函數的具體用法?Golang Error怎麽用?Golang Error使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Error函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
flag.Parse()
projectInit.SetWorkingDir(*workingDir)
initPackageFlags()
validGaugeProject := true
err := config.SetProjectRoot(flag.Args())
if err != nil {
validGaugeProject = false
}
env.LoadEnv(*currentEnv)
logger.Initialize(*logLevel)
if *gaugeVersion {
printVersion()
} else if *initialize != "" {
projectInit.InitializeProject(*initialize)
} else if *installZip != "" && *installPlugin != "" {
install.InstallPluginZip(*installZip, *installPlugin)
} else if *installPlugin != "" {
install.DownloadAndInstallPlugin(*installPlugin, *pluginVersion, "Successfully installed plugin => %s")
} else if *uninstallPlugin != "" {
install.UninstallPlugin(*uninstallPlugin, *pluginVersion)
} else if *installAll {
install.InstallAllPlugins()
} else if *update != "" {
install.DownloadAndInstallPlugin(*update, *pluginVersion, "Successfully updated plugin => %s")
} else if *updateAll {
install.UpdatePlugins()
} else if *checkUpdates {
install.PrintUpdateInfoWithDetails()
} else if *addPlugin != "" {
install.AddPluginToProject(*addPlugin, *pluginArgs)
} else if *listTemplates {
projectInit.ListTemplates()
} else if flag.NFlag() == 0 && len(flag.Args()) == 0 {
printUsage()
os.Exit(0)
} else if validGaugeProject {
if *refactorSteps != "" {
startChan := api.StartAPI()
if len(flag.Args()) != 1 {
logger.Error("flag needs two arguments: --refactor\n.Usage : gauge --refactor {old step} {new step}")
os.Exit(1)
}
refactor.RefactorSteps(*refactorSteps, flag.Args()[0], startChan)
} else if *daemonize {
api.RunInBackground(*apiPort)
} else if *specFilesToFormat != "" {
formatter.FormatSpecFilesIn(*specFilesToFormat)
} else if *validate {
execution.Validate(flag.Args())
} else {
exitCode := execution.ExecuteSpecs(flag.Args())
os.Exit(exitCode)
}
} else {
logger.Error(err.Error())
os.Exit(1)
}
}
示例2: printValidationFailures
func printValidationFailures(validationErrors validationErrors) {
logger.Error("Validation failed. The following steps have errors")
for _, stepValidationErrors := range validationErrors {
for _, stepValidationError := range stepValidationErrors {
s := stepValidationError.step
logger.Error("%s:%d: %s. %s", stepValidationError.fileName, s.LineNo, stepValidationError.message, s.LineText)
}
}
}
示例3: isValid
func (self *parallelInfo) isValid() bool {
if self.numberOfStreams < 1 {
logger.Error("Invalid input(%s) to --n flag.", strconv.Itoa(self.numberOfStreams))
return false
}
currentStrategy := strings.ToLower(Strategy)
if currentStrategy != LAZY && currentStrategy != EAGER {
logger.Error("Invalid input(%s) to --strategy flag.", Strategy)
return false
}
return true
}
示例4: addPluginToTheProject
func addPluginToTheProject(pluginName string, pluginArgs map[string]string, manifest *manifest.Manifest) error {
if !plugin.IsPluginInstalled(pluginName, pluginArgs["version"]) {
logger.Info("Plugin %s %s is not installed. Downloading the plugin.... \n", pluginName, pluginArgs["version"])
result := InstallPlugin(pluginName, pluginArgs["version"])
if !result.Success {
logger.Error(result.getMessage())
}
}
pd, err := plugin.GetPluginDescriptor(pluginName, pluginArgs["version"])
if err != nil {
return err
}
if plugin.IsPluginAdded(manifest, pd) {
logger.Info("Plugin " + pd.Name + " is already added.")
return nil
}
action := setupScope
if err := plugin.SetEnvForPlugin(action, pd, manifest, pluginArgs); err != nil {
return err
}
if _, err := plugin.StartPlugin(pd, action, true); err != nil {
return err
}
manifest.Plugins = append(manifest.Plugins, pd.Id)
return manifest.Save()
}
示例5: printExecutionStatus
func printExecutionStatus(suiteResult *result.SuiteResult, errMap *validationErrMaps) int {
nSkippedScenarios := len(errMap.scenarioErrs)
nSkippedSpecs := len(errMap.specErrs)
nExecutedSpecs := len(suiteResult.SpecResults) - nSkippedSpecs
nFailedSpecs := suiteResult.SpecsFailedCount
nPassedSpecs := nExecutedSpecs - nFailedSpecs
nExecutedScenarios := 0
nFailedScenarios := 0
nPassedScenarios := 0
for _, specResult := range suiteResult.SpecResults {
nExecutedScenarios += specResult.ScenarioCount
nFailedScenarios += specResult.ScenarioFailedCount
}
nExecutedScenarios -= nSkippedScenarios
nPassedScenarios = nExecutedScenarios - nFailedScenarios
logger.Info("Specifications:\t%d executed\t%d passed\t%d failed\t%d skipped", nExecutedSpecs, nPassedSpecs, nFailedSpecs, nSkippedSpecs)
logger.Info("Scenarios:\t%d executed\t%d passed\t%d failed\t%d skipped", nExecutedScenarios, nPassedScenarios, nFailedScenarios, nSkippedScenarios)
logger.Info("\nTotal time taken: %s", time.Millisecond*time.Duration(suiteResult.ExecutionTime))
for _, unhandledErr := range suiteResult.UnhandledErrors {
logger.Error(unhandledErr.Error())
}
exitCode := 0
if suiteResult.IsFailed || (nSkippedSpecs+nSkippedScenarios) > 0 {
exitCode = 1
}
return exitCode
}
示例6: DownloadAndInstallPlugin
func DownloadAndInstallPlugin(plugin, version, messageFormat string) {
err := downloadAndInstall(plugin, version, fmt.Sprintf(messageFormat, plugin))
if err != nil {
logger.Error(err.Error())
os.Exit(1)
}
os.Exit(0)
}
示例7: killPlugin
func (handler *Handler) killPlugin(pluginId string) {
plugin := handler.pluginsMap[pluginId]
logger.Debug("Killing Plugin %s %s\n", plugin.descriptor.Name, plugin.descriptor.Version)
err := plugin.pluginCmd.Process.Kill()
if err != nil {
logger.Error("Failed to kill plugin %s %s. %s\n", plugin.descriptor.Name, plugin.descriptor.Version, err.Error())
}
handler.removePlugin(pluginId)
}
示例8: NotifyPlugins
func (handler *Handler) NotifyPlugins(message *gauge_messages.Message) {
for id, plugin := range handler.pluginsMap {
err := plugin.sendMessage(message)
if err != nil {
logger.Error("Unable to connect to plugin %s %s. %s\n", plugin.descriptor.Name, plugin.descriptor.Version, err.Error())
handler.killPlugin(id)
}
}
}
示例9: UpdatePlugins
func UpdatePlugins() {
var failedPlugin []string
for _, pluginInfo := range plugin.GetPluginsInfo() {
logger.Info("Updating plugin '%s'", pluginInfo.Name)
err := downloadAndInstall(pluginInfo.Name, "", fmt.Sprintf("Successfully updated plugin => %s", pluginInfo.Name))
if err != nil {
logger.Error(err.Error())
failedPlugin = append(failedPlugin, pluginInfo.Name)
}
fmt.Println()
}
if len(failedPlugin) > 0 {
logger.Error("Failed to update '%s' plugins.", strings.Join(failedPlugin, ", "))
os.Exit(1)
}
logger.Info("Successfully updated all the plugins.")
os.Exit(0)
}
示例10: getDataTableRows
func getDataTableRows(rowCount int) indexRange {
if TableRows == "" {
return indexRange{start: 0, end: rowCount - 1}
}
indexes, err := getDataTableRowsRange(TableRows, rowCount)
if err != nil {
logger.Error("Table rows validation failed. %s\n", err.Error())
}
return indexes
}
示例11: executeAndGetStatus
func executeAndGetStatus(runner *runner.TestRunner, message *gauge_messages.Message) *gauge_messages.ProtoExecutionResult {
response, err := conn.GetResponseForGaugeMessage(message, runner.Connection)
if err != nil {
return &gauge_messages.ProtoExecutionResult{Failed: proto.Bool(true), ErrorMessage: proto.String(err.Error())}
}
if response.GetMessageType() == gauge_messages.Message_ExecutionStatusResponse {
executionResult := response.GetExecutionStatusResponse().GetExecutionResult()
if executionResult == nil {
errMsg := "ProtoExecutionResult obtained is nil"
logger.Error(errMsg)
return errorResult(errMsg)
}
return executionResult
}
errMsg := fmt.Sprintf("Expected ExecutionStatusResponse. Obtained: %s", response.GetMessageType())
logger.Error(errMsg)
return errorResult(errMsg)
}
示例12: createSkippedSpecResult
func (e *specExecutor) createSkippedSpecResult(err error) *result.SpecResult {
logger.Error(err.Error())
validationError := newValidationError(&gauge.Step{LineNo: e.specification.Heading.LineNo, LineText: e.specification.Heading.Value},
err.Error(), e.specification.FileName, nil)
for _, scenario := range e.specification.Scenarios {
e.errMap.scenarioErrs[scenario] = []*stepValidationError{validationError}
}
e.errMap.specErrs[e.specification] = []*stepValidationError{validationError}
return e.getSkippedSpecResult()
}
示例13: startSpecsExecution
func (e *parallelSpecExecution) startSpecsExecution(specCollection *filter.SpecCollection, suiteResults chan *result.SuiteResult, reporter reporter.Reporter) {
testRunner, err := runner.StartRunnerAndMakeConnection(e.manifest, reporter, make(chan bool))
if err != nil {
logger.Error("Failed: " + err.Error())
logger.Debug("Skipping %s specifications", strconv.Itoa(len(specCollection.Specs)))
suiteResults <- &result.SuiteResult{UnhandledErrors: []error{streamExecError{specsSkipped: specCollection.SpecNames(), message: fmt.Sprintf("Failed to start runner. %s", err.Error())}}}
return
}
e.startSpecsExecutionWithRunner(specCollection, suiteResults, testRunner, reporter)
}
示例14: startStream
func (e *parallelExecution) startStream(specStore *specStore, reporter reporter.Reporter, suiteResultChannel chan *result.SuiteResult) {
defer e.wg.Done()
testRunner, err := runner.StartRunnerAndMakeConnection(e.manifest, reporter, make(chan bool))
if err != nil {
logger.Error("Failed to start runner. Reason: %s", err.Error())
suiteResultChannel <- &result.SuiteResult{UnhandledErrors: []error{fmt.Errorf("Failed to start runner. %s", err.Error())}}
return
}
e.startSpecsExecutionWithRunner(specStore, suiteResultChannel, testRunner, reporter)
}
示例15: startStream
func (e *parallelSpecExecution) startStream(specs *specList, reporter reporter.Reporter, suiteResultChannel chan *result.SuiteResult) {
defer e.wg.Done()
testRunner, err := runner.StartRunnerAndMakeConnection(e.manifest, reporter, make(chan bool))
if err != nil {
logger.Error("Failed to start runner. Reason: %s", err.Error())
suiteResultChannel <- &result.SuiteResult{UnhandledErrors: []error{fmt.Errorf("Failed to start runner. %s", err.Error())}}
return
}
simpleExecution := newSimpleExecution(&executionInfo{e.manifest, make([]*parser.Specification, 0), testRunner, e.pluginHandler, nil, reporter, e.errMaps})
result := simpleExecution.executeStream(specs)
suiteResultChannel <- result
testRunner.Kill()
}