run

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2017 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "run",
	Short: "Run Tests",
	PreRun: func(cmd *cobra.Command, args []string) {

		if len(args) == 0 {
			path = append(path, ".")
		} else {
			path = args[0:]
		}

		venom.RegisterExecutor(exec.Name, exec.New())
		venom.RegisterExecutor(http.Name, http.New())
		venom.RegisterExecutor(imap.Name, imap.New())
		venom.RegisterExecutor(readfile.Name, readfile.New())
		venom.RegisterExecutor(smtp.Name, smtp.New())
		venom.RegisterExecutor(ssh.Name, ssh.New())
		venom.RegisterExecutor(web.Name, web.New())
		venom.RegisterExecutor(ovhapi.Name, ovhapi.New())

		venom.RegisterTestCaseContext(defaultctx.Name, defaultctx.New())
		venom.RegisterTestCaseContext(webctx.Name, webctx.New())
	},
	Run: func(cmd *cobra.Command, args []string) {
		if parallel < 0 {
			parallel = 1
		}

		mapvars := make(map[string]string)

		if withEnv {
			variables = append(variables, os.Environ()...)
		}

		for _, a := range variables {
			t := strings.SplitN(a, "=", 2)
			if len(t) < 2 {
				continue
			}
			mapvars[t[0]] = strings.Join(t[1:], "")
		}

		if varFile != "" {
			varFileMap := make(map[string]string)
			bytes, err := ioutil.ReadFile(varFile)
			if err != nil {
				log.Fatal(err)
			}
			switch filepath.Ext(varFile) {
			case ".json":
				err = json.Unmarshal(bytes, &varFileMap)
			case ".yaml":
				err = yaml.Unmarshal(bytes, &varFileMap)
			default:
				log.Fatal("unsupported varFile format")
			}
			if err != nil {
				log.Fatal(err)
			}

			for key, value := range varFileMap {
				mapvars[key] = value
			}
		}

		start := time.Now()
		tests, err := venom.Process(path, mapvars, exclude, parallel, logLevel, detailsLevel, os.Stdout)
		if err != nil {
			log.Fatal(err)
		}

		elapsed := time.Since(start)
		if err := venom.OutputResult(format, resume, resumeFailures, outputDir, *tests, elapsed, detailsLevel); err != nil {
			fmt.Fprintf(os.Stderr, err.Error())
			os.Exit(1)
		}
	},
}

Cmd run

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL