本文整理匯總了Golang中github.com/getgauge/gauge/logger.Fatalf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Fatalf函數的具體用法?Golang Fatalf怎麽用?Golang Fatalf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Fatalf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UninstallPlugin
// UninstallPlugin uninstall the given plugin of the given version
// If version is not specified, it uninstalls all the versions of given plugin
func UninstallPlugin(pluginName string, version string) {
pluginsHome, err := common.GetPrimaryPluginsInstallDir()
if err != nil {
logger.Fatalf("Failed to uninstall plugin %s. %s", pluginName, err.Error())
}
if !common.DirExists(filepath.Join(pluginsHome, pluginName, version)) {
logger.Errorf("Plugin %s not found.", strings.TrimSpace(pluginName+" "+version))
os.Exit(0)
}
var failed bool
pluginsDir := filepath.Join(pluginsHome, pluginName)
filepath.Walk(pluginsDir, func(dir string, info os.FileInfo, err error) error {
if err == nil && info.IsDir() && dir != pluginsDir && strings.HasPrefix(filepath.Base(dir), version) {
if err := uninstallVersionOfPlugin(dir, pluginName, filepath.Base(dir)); err != nil {
logger.Errorf("Failed to uninstall plugin %s %s. %s", pluginName, version, err.Error())
failed = true
}
}
return nil
})
if failed {
os.Exit(1)
}
if version == "" {
if err := os.RemoveAll(pluginsDir); err != nil {
logger.Fatalf("Failed to remove directory %s. %s", pluginsDir, err.Error())
}
}
}
示例2: InitializeProject
// InitializeProject initializes a Gauge project with specified template
func InitializeProject(templateName string) {
wd, err := os.Getwd()
if err != nil {
logger.Fatalf("Failed to find working directory. %s", err.Error())
}
config.ProjectRoot = wd
exists, _ := common.UrlExists(getTemplateURL(templateName))
if exists {
err = initializeTemplate(templateName)
} else {
err = createProjectTemplate(templateName)
}
if err != nil {
logger.Fatalf("Failed to initialize project. %s", err.Error())
}
logger.Info("Successfully initialized the project. Run specifications with \"gauge specs/\"\n")
language := getTemplateLangauge(templateName)
if !install.IsCompatiblePluginInstalled(language, true) {
logger.Info("Compatible langauge plugin %s is not installed. Installing plugin...", language)
install.HandleInstallResult(install.InstallPlugin(language, ""), language, true)
}
}
示例3: ListTemplates
// ListTemplates lists all the Gauge templates available in GaugeTemplatesURL
func ListTemplates() {
templatesURL := config.GaugeTemplatesUrl()
_, err := common.UrlExists(templatesURL)
if err != nil {
logger.Fatalf("Gauge templates URL is not reachable: %s", err.Error())
}
tempDir := common.GetTempDir()
defer util.Remove(tempDir)
templatesPage, err := util.Download(templatesURL, tempDir, "", true)
if err != nil {
util.Remove(tempDir)
logger.Fatalf("Error occurred while downloading templates list: %s", err.Error())
}
templatePageContents, err := common.ReadFileContents(templatesPage)
if err != nil {
util.Remove(tempDir)
logger.Fatalf("Failed to read contents of file %s: %s", templatesPage, err.Error())
}
templates := getTemplateNames(templatePageContents)
for _, template := range templates {
logger.Info(template)
}
logger.Info("\nRun `gauge --init <template_name>` to create a new Gauge project.")
}
示例4: validateFlags
func validateFlags() {
if !InParallel {
return
}
if NumberOfExecutionStreams < 1 {
logger.Fatalf("Invalid input(%s) to --n flag.", strconv.Itoa(NumberOfExecutionStreams))
}
if !isValidStrategy(Strategy) {
logger.Fatalf("Invalid input(%s) to --strategy flag.", Strategy)
}
}
示例5: LoadEnv
// LoadEnv first loads the default env properties and then the user specified env properties.
// This way user specified env variable can overwrite default if required
func LoadEnv(envName string) {
currentEnv = envName
err := loadDefaultProperties()
if err != nil {
logger.Fatalf("Failed to load the default property. %s", err.Error())
}
err = loadEnvDir(currentEnv)
if err != nil {
logger.Fatalf("Failed to load env. %s", err.Error())
}
}
示例6: InstallAllPlugins
func InstallAllPlugins() {
manifest, err := manifest.ProjectManifest()
if err != nil {
logger.Fatalf(err.Error())
}
installPluginsFromManifest(manifest)
}
示例7: GetConceptFiles
// GetConceptFiles returns the list of concept files present in the PROJECTROOT/base_dir_of_path
func GetConceptFiles(path string) []string {
absPath, err := filepath.Abs(path)
if err != nil {
logger.Fatalf("Error getting absolute path. %v", err)
}
projRoot := config.ProjectRoot
if projRoot == "" {
logger.Fatalf("Failed to get project root. %v", err)
}
projRoot += string(filepath.Separator)
path = strings.TrimPrefix(absPath, projRoot)
path = strings.Split(path, string(filepath.Separator))[0]
return FindConceptFilesIn(path)
}
示例8: RunInBackground
// RunInBackground runs Gauge in daemonized mode on the given apiPort
func RunInBackground(apiPort string, specDirs []string) {
var port int
var err error
if apiPort != "" {
port, err = strconv.Atoi(apiPort)
if err != nil {
logger.Fatalf(fmt.Sprintf("Invalid port number: %s", apiPort))
}
os.Setenv(common.APIPortEnvVariableName, apiPort)
} else {
port, err = conn.GetPortFromEnvironmentVariable(common.APIPortEnvVariableName)
if err != nil {
logger.Fatalf(fmt.Sprintf("Failed to start API Service. %s \n", err.Error()))
}
}
runAPIServiceIndefinitely(port, specDirs)
}
示例9: validateTagExpression
func validateTagExpression(tagExpression string) {
filter := &ScenarioFilterBasedOnTags{tagExpression: tagExpression}
filter.replaceSpecialChar()
_, err := filter.formatAndEvaluateExpression(make(map[string]bool, 0), func(a map[string]bool, b string) bool { return true })
if err != nil {
logger.Fatalf(err.Error())
}
}
示例10: startAPI
//TODO : duplicate in execute.go. Need to fix runner init.
func startAPI() *runner.TestRunner {
sc := api.StartAPI()
select {
case runner := <-sc.RunnerChan:
return runner
case err := <-sc.ErrorChan:
logger.Fatalf("Failed to start gauge API: %s", err.Error())
}
return nil
}
示例11: refactorInit
func refactorInit(args []string) {
if len(args) < 1 {
logger.Fatalf("Flag needs at least two arguments: --refactor\nUsage : gauge --refactor <old step> <new step> [[spec directories]]")
}
var specDirs = []string{common.SpecsDirectoryName}
if len(args) > 1 {
specDirs = args[1:]
}
startChan := api.StartAPI()
refactor.RefactorSteps(*refactorSteps, args[0], startChan, specDirs)
}
示例12: InitializeProject
// InitializeProject initializes a Gauge project with specified template
func InitializeProject(templateName string) {
wd, err := os.Getwd()
if err != nil {
logger.Fatalf("Failed to find working directory. %s", err.Error())
}
config.ProjectRoot = wd
exists, _ := common.UrlExists(getTemplateURL(templateName))
if exists {
err = initializeTemplate(templateName)
} else {
err = createProjectTemplate(templateName)
}
if err != nil {
logger.Fatalf("Failed to initialize. %s", err.Error())
}
logger.Info("\nSuccessfully initialized the project. Run specifications with \"gauge specs/\"")
}
示例13: runAPIServiceIndefinitely
func runAPIServiceIndefinitely(port int, wg *sync.WaitGroup) {
wg.Add(1)
startChan := &runner.StartChannels{RunnerChan: make(chan *runner.TestRunner), ErrorChan: make(chan error), KillChan: make(chan bool)}
go StartAPIService(port, startChan)
select {
case runner := <-startChan.RunnerChan:
runner.Kill()
case err := <-startChan.ErrorChan:
logger.Fatalf(err.Error())
}
}
示例14: startAPI
func startAPI() *runner.TestRunner {
startChan := &runner.StartChannels{RunnerChan: make(chan *runner.TestRunner), ErrorChan: make(chan error), KillChan: make(chan bool)}
go api.StartAPIService(0, startChan)
select {
case runner := <-startChan.RunnerChan:
return runner
case err := <-startChan.ErrorChan:
logger.Fatalf("Failed to start gauge API: %s", err.Error())
}
return nil
}
示例15: InstallPluginZip
func InstallPluginZip(zipFile string, pluginName string) {
tempDir := common.GetTempDir()
unzippedPluginDir, err := common.UnzipArchive(zipFile, tempDir)
defer common.Remove(tempDir)
if err != nil {
common.Remove(tempDir)
logger.Fatalf("Failed to install plugin. %s\n", err.Error())
}
logger.Info("Plugin unzipped to => %s\n", unzippedPluginDir)
hasPluginJSON := common.FileExists(filepath.Join(unzippedPluginDir, pluginJSON))
if hasPluginJSON {
err = installPluginFromDir(unzippedPluginDir)
} else {
err = installRunnerFromDir(unzippedPluginDir, pluginName)
}
if err != nil {
common.Remove(tempDir)
logger.Fatalf("Failed to install plugin. %s\n", err.Error())
}
logger.Info("Successfully installed plugin from file.")
}