本文整理匯總了Golang中github.com/getgauge/gauge/env.LoadEnv函數的典型用法代碼示例。如果您正苦於以下問題:Golang LoadEnv函數的具體用法?Golang LoadEnv怎麽用?Golang LoadEnv使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了LoadEnv函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ExecuteSpecs
func ExecuteSpecs(inParallel bool, args []string) {
env.LoadEnv(false)
conceptsDictionary, conceptParseResult := parser.CreateConceptsDictionary(false)
parser.HandleParseResult(conceptParseResult)
specsToExecute, specsSkipped := filter.GetSpecsToExecute(conceptsDictionary, args)
if len(specsToExecute) == 0 {
printExecutionStatus(nil, 0)
}
parallelInfo := ¶llelInfo{inParallel: inParallel, numberOfStreams: NumberOfExecutionStreams}
if !parallelInfo.isValid() {
os.Exit(1)
}
manifest, err := manifest.ProjectManifest()
if err != nil {
execLogger.CriticalError(err)
}
runner := startApi()
validateSpecs(manifest, specsToExecute, runner, conceptsDictionary)
pluginHandler := plugin.StartPlugins(manifest)
execution := newExecution(manifest, specsToExecute, runner, pluginHandler, parallelInfo, execLogger.Current())
result := execution.start()
execution.finish()
exitCode := printExecutionStatus(result, specsSkipped)
os.Exit(exitCode)
}
示例2: executeSpecs
func executeSpecs(inParallel bool) {
env.LoadEnv(*currentEnv, false)
conceptsDictionary, conceptParseResult := createConceptsDictionary(false)
handleParseResult(conceptParseResult)
specsToExecute, specsSkipped := getSpecsToExecute(conceptsDictionary)
if len(specsToExecute) == 0 {
printExecutionStatus(nil, 0)
}
parallelInfo := ¶llelInfo{inParallel: inParallel, numberOfStreams: *numberOfExecutionStreams}
if !parallelInfo.isValid() {
os.Exit(1)
}
manifest, err := getProjectManifest()
if err != nil {
handleCriticalError(err)
}
err, apiHandler := startAPIService(0)
if err != nil {
apiHandler.runner.kill(getCurrentLogger())
handleCriticalError(errors.New(fmt.Sprintf("Failed to start gauge API. %s\n", err.Error())))
}
if apiHandler.runner == nil {
handleCriticalError(errors.New("Failed to start a runner\n"))
}
validateSpecs(manifest, specsToExecute, apiHandler.runner, conceptsDictionary)
pluginHandler := startPlugins(manifest)
execution := newExecution(manifest, specsToExecute, apiHandler.runner, pluginHandler, parallelInfo, getCurrentLogger())
result := execution.start()
execution.finish()
exitCode := printExecutionStatus(result, specsSkipped)
os.Exit(exitCode)
}
示例3: ExecuteSpecs
func ExecuteSpecs(inParallel bool, args []string) int {
if checkUpdatesDuringExecution && config.CheckUpdates() {
i := &install.UpdateFacade{}
i.BufferUpdateDetails()
defer i.PrintUpdateBuffer()
}
env.LoadEnv(false)
specsToExecute, conceptsDictionary := parseSpecs(args)
manifest, err := manifest.ProjectManifest()
if err != nil {
logger.Fatal(err.Error())
}
runner := startApi()
errMap := validateSpecs(manifest, specsToExecute, runner, conceptsDictionary)
pluginHandler := plugin.StartPlugins(manifest)
parallelInfo := ¶llelInfo{inParallel: inParallel, numberOfStreams: NumberOfExecutionStreams}
if !parallelInfo.isValid() {
os.Exit(1)
}
execution := newExecution(&executionInfo{manifest, specsToExecute, runner, pluginHandler, parallelInfo, reporter.Current(), errMap})
result := execution.start()
execution.finish()
exitCode := printExecutionStatus(result, errMap)
return exitCode
}
示例4: main
func main() {
flag.Parse()
project_init.SetWorkingDir(*workingDir)
initPackageFlags()
validGaugeProject := true
err := config.SetProjectRoot(flag.Args())
if err != nil {
validGaugeProject = false
}
env.LoadEnv(true)
logger.Initialize(*verbosity, *logLevel, *simpleConsoleOutput)
if *gaugeVersion {
version.PrintVersion()
} else if *daemonize {
if validGaugeProject {
api.RunInBackground(*apiPort)
} else {
logger.Log.Error(err.Error())
}
} else if *specFilesToFormat != "" {
if validGaugeProject {
formatter.FormatSpecFilesIn(*specFilesToFormat)
} else {
logger.Log.Error(err.Error())
}
} else if *initialize != "" {
project_init.InitializeProject(*initialize)
} else if *installZip != "" && *installPlugin != "" {
install.InstallPluginZip(*installZip, *installPlugin)
} else if *installPlugin != "" {
install.DownloadAndInstallPlugin(*installPlugin, *installVersion)
} else if *uninstallPlugin != "" {
install.UninstallPlugin(*uninstallPlugin)
} else if *installAll {
install.InstallAllPlugins()
} else if *update != "" {
install.UpdatePlugin(*update)
} else if *addPlugin != "" {
install.AddPluginToProject(*addPlugin, *pluginArgs)
} else if *refactorSteps != "" {
if validGaugeProject {
startChan := api.StartAPI()
refactor.RefactorSteps(*refactorSteps, newStepName(), startChan)
} else {
logger.Log.Error(err.Error())
}
} else {
if len(flag.Args()) == 0 {
printUsage()
} else if validGaugeProject {
if *distribute != -1 {
*doNotRandomize = true
}
execution.ExecuteSpecs(*parallel, flag.Args())
} else {
logger.Log.Error("Could not set project root: %s", err.Error())
os.Exit(1)
}
}
}
示例5: 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)
}
}
示例6: startRunner
func (agent *rephraseRefactorer) startRunner() (*gaugeApiMessageHandler, error) {
env.LoadEnv(*currentEnv, false)
err, apiHandler := startAPIService(0)
if err != nil {
return nil, errors.New(fmt.Sprintf("Failed to connect to test runner: %s", err))
}
return apiHandler, nil
}
示例7: ParseAndValidateSpecs
func ParseAndValidateSpecs(args []string) {
env.LoadEnv(false)
specsToExecute, conceptsDictionary := parseSpecs(args)
manifest, err := manifest.ProjectManifest()
if err != nil {
logger.Fatal(err.Error())
}
runner := startApi()
errMap := validateSpecs(manifest, specsToExecute, runner, conceptsDictionary)
runner.Kill()
if len(errMap.stepErrs) > 0 {
os.Exit(1)
}
logger.Info("No error found.")
os.Exit(0)
}
示例8: main
func main() {
flag.Parse()
setWorkingDir(*workingDir)
validGaugeProject := true
err := config.SetProjectRoot(flag.Args())
if err != nil {
validGaugeProject = false
}
env.LoadEnv(*currentEnv, true)
logger.Initialize(*verbosity, *logLevel)
if *gaugeVersion {
printVersion()
} else if *daemonize && validGaugeProject {
runInBackground()
} else if *specFilesToFormat != "" && validGaugeProject {
formatSpecFilesIn(*specFilesToFormat)
} else if *initialize != "" {
initializeProject(*initialize)
} else if *installZip != "" && *install != "" {
installPluginZip(*installZip, *install)
} else if *install != "" {
downloadAndInstallPlugin(*install, *installVersion)
} else if *installAll {
installAllPlugins()
} else if *update != "" {
updatePlugin(*update)
} else if *addPlugin != "" {
addPluginToProject(*addPlugin)
} else if *refactor != "" && validGaugeProject {
refactorSteps(*refactor, newStepName())
} else {
if len(flag.Args()) == 0 {
printUsage()
} else if validGaugeProject {
if *distribute != -1 {
*doNotRandomize = true
}
executeSpecs(*parallel)
} else {
logger.Log.Error("Could not set project root: %s", err.Error())
os.Exit(1)
}
}
}
示例9: RunInBackground
func RunInBackground(apiPort string) {
var port int
var err error
if apiPort != "" {
port, err = strconv.Atoi(apiPort)
os.Setenv(common.ApiPortEnvVariableName, apiPort)
if err != nil {
execLogger.CriticalError(errors.New(fmt.Sprintf("Failed to parse the port number :", apiPort, "\n", err.Error())))
}
} else {
env.LoadEnv(false)
port, err = conn.GetPortFromEnvironmentVariable(common.ApiPortEnvVariableName)
if err != nil {
execLogger.CriticalError(errors.New(fmt.Sprintf("Failed to start API Service. %s \n", err.Error())))
}
}
var wg sync.WaitGroup
runAPIServiceIndefinitely(port, &wg)
wg.Wait()
}
示例10: ExecuteSpecs
func ExecuteSpecs(inParallel bool, args []string) {
env.LoadEnv(false)
specsToExecute, conceptsDictionary := parseSpecs(args)
manifest, err := manifest.ProjectManifest()
if err != nil {
logger.Log.Critical(err.Error())
}
runner := startApi()
errMap := validateSpecs(manifest, specsToExecute, runner, conceptsDictionary)
pluginHandler := plugin.StartPlugins(manifest)
parallelInfo := ¶llelInfo{inParallel: inParallel, numberOfStreams: NumberOfExecutionStreams}
if !parallelInfo.isValid() {
os.Exit(1)
}
execution := newExecution(&executionInfo{manifest, specsToExecute, runner, pluginHandler, parallelInfo, &logger.Log, errMap})
result := execution.start()
execution.finish()
exitCode := printExecutionStatus(result, errMap)
os.Exit(exitCode)
}
示例11: RunInBackground
func RunInBackground(apiPort string) {
var port int
var err error
if apiPort != "" {
port, err = strconv.Atoi(apiPort)
if err != nil {
logger.Fatal(fmt.Sprintf("Invalid port number: %s", apiPort))
}
os.Setenv(common.APIPortEnvVariableName, apiPort)
} else {
env.LoadEnv(false)
port, err = conn.GetPortFromEnvironmentVariable(common.APIPortEnvVariableName)
if err != nil {
logger.Fatal(fmt.Sprintf("Failed to start API Service. %s \n", err.Error()))
}
}
var wg sync.WaitGroup
runAPIServiceIndefinitely(port, &wg)
wg.Wait()
}
示例12: ExecuteSpecs
func ExecuteSpecs(inParallel bool, args []string) {
env.LoadEnv(false)
specsToExecute, conceptsDictionary := parseSpecs(args)
manifest, err := manifest.ProjectManifest()
if err != nil {
logger.Log.Critical(err.Error())
}
runner := startApi()
errMap := validateSpecs(manifest, specsToExecute, runner, conceptsDictionary)
pluginHandler := plugin.StartPlugins(manifest)
parallelInfo := ¶llelInfo{inParallel: inParallel, numberOfStreams: NumberOfExecutionStreams}
if !parallelInfo.isValid() {
os.Exit(1)
}
execution := newExecution(&executionInfo{manifest, specsToExecute, runner, pluginHandler, parallelInfo, &logger.Log, errMap})
result := execution.start()
// TODO: Remove this logger line below when plugins call tell the difference between their status messages and user-generated sysouts
logger.Log.Debug("\n")
execution.finish()
exitCode := printExecutionStatus(result, errMap)
os.Exit(exitCode)
}
示例13: StartAPI
func StartAPI() *runner.StartChannels {
env.LoadEnv(false)
startChan := &runner.StartChannels{RunnerChan: make(chan *runner.TestRunner), ErrorChan: make(chan error), KillChan: make(chan bool)}
go StartAPIService(0, startChan)
return startChan
}
示例14: main
func main() {
flag.Parse()
util.SetWorkingDir(*workingDir)
initPackageFlags()
validGaugeProject := true
err := config.SetProjectRoot(flag.Args())
if err != nil {
validGaugeProject = false
}
env.LoadEnv(*currentEnv)
logger.Initialize(*logLevel)
if *gaugeVersion && *machineReadable {
printJSONVersion()
} else if *machineReadable {
fmt.Printf("flag '--machine-readable' can only be used with '--version' or '-v'\n\n")
fmt.Printf("Usage:\n\n")
flag.PrintDefaults()
os.Exit(1)
} else if *gaugeVersion {
printVersion()
} else if *initialize != "" {
projectInit.InitializeProject(*initialize)
} else if *installZip != "" && *installPlugin != "" {
install.HandleInstallResult(install.InstallPluginFromZipFile(*installZip, *installPlugin), *installPlugin, true)
} else if *installPlugin != "" {
install.HandleInstallResult(install.InstallPlugin(*installPlugin, *pluginVersion), *installPlugin, true)
} else if *uninstallPlugin != "" {
install.UninstallPlugin(*uninstallPlugin, *pluginVersion)
} else if *installAll {
install.InstallAllPlugins()
} else if *update != "" {
install.HandleUpdateResult(install.InstallPlugin(*update, *pluginVersion), *update, true)
} 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 {
var specDirs = []string{common.SpecsDirectoryName}
if len(flag.Args()) > 0 {
specDirs = flag.Args()
}
if *refactorSteps != "" {
refactorInit(flag.Args())
} else if *daemonize {
api.RunInBackground(*apiPort, specDirs)
} else if *specFilesToFormat != "" {
formatter.FormatSpecFilesIn(*specFilesToFormat)
} else if *validate {
validation.Validate(flag.Args())
} else {
exitCode := execution.ExecuteSpecs(specDirs)
os.Exit(exitCode)
}
} else {
logger.Fatalf(err.Error())
}
}
示例15: main
func main() {
flag.Parse()
projectInit.SetWorkingDir(*workingDir)
initPackageFlags()
validGaugeProject := true
err := config.SetProjectRoot(flag.Args())
if err != nil {
validGaugeProject = false
}
env.LoadEnv(true)
logger.Initialize(*verbosity, *logLevel)
if *gaugeVersion {
version.PrintVersion()
} else if *daemonize {
if validGaugeProject {
api.RunInBackground(*apiPort)
} else {
logger.Error(err.Error())
}
} else if *specFilesToFormat != "" {
if validGaugeProject {
formatter.FormatSpecFilesIn(*specFilesToFormat)
} else {
logger.Error(err.Error())
}
} 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 *refactorSteps != "" {
if validGaugeProject {
startChan := api.StartAPI()
refactor.RefactorSteps(*refactorSteps, newStepName(), startChan)
} else {
logger.Error(err.Error())
}
} else if *check {
if validGaugeProject {
execution.CheckSpecs(flag.Args())
} else {
logger.Error(err.Error())
}
} else {
if len(flag.Args()) == 0 {
printUsage()
}
if validGaugeProject {
exitCode := execution.ExecuteSpecs(*parallel, flag.Args())
os.Exit(exitCode)
} else {
logger.Error(err.Error())
}
}
}