Exemple #1
0
See 'go help test'

`,
	Run: func(ctx *gb.Context, args []string) error {
		t0 := time.Now()
		ctx.Force = F
		ctx.SkipInstall = FF
		defer func() {
			gb.Debugf("test duration: %v %v", time.Since(t0), ctx.Statistics.String())
		}()
		pkgs, err := cmd.ResolvePackagesWithTests(ctx, args...)
		if err != nil {
			return err
		}
		if err := cmd.Test(cmd.TestFlags(tfs), pkgs...); err != nil {
			return err
		}
		return ctx.Destroy()
	},
	AddFlags: addTestFlags,
	FlagParse: func(flags *flag.FlagSet, args []string) error {
		var err error
		args, tfs, err = cmd.TestFlagsExtraParse(args[2:])
		if err != nil {
			fmt.Fprintf(os.Stderr, "gb test: %s\n", err)
			fmt.Fprintf(os.Stderr, `run "go help test" or "go help testflag" for more information`+"\n")
			os.Exit(2)
		}
		return flags.Parse(args)
	},
Exemple #2
0
Fichier : test.go Projet : Luit/gb
'gb test' recompiles each package along with any files with names matching
the file pattern "*_test.go".

See 'go help test'

`,
	Run: func(ctx *gb.Context, args []string) error {
		ctx.Force = F
		ctx.SkipInstall = FF
		pkgs, err := cmd.ResolvePackagesWithTests(ctx, args...)
		if err != nil {
			return err
		}

		test, err := cmd.TestPackages(cmd.TestFlags(tfs), pkgs...)
		if err != nil {
			return err
		}

		if dotfile != "" {
			f, err := os.Create(dotfile)
			if err != nil {
				return err
			}
			defer f.Close()
			printActions(f, test)
		}

		return gb.ExecuteConcurrent(test, P)
	},