Example #1
0
func list(g *gt.GopathTest, c *Context, name, expected string) {
	list, err := c.Status()
	if err != nil {
		g.Fatal(err)
	}
	output := &bytes.Buffer{}
	for _, item := range list {
		output.WriteString(statusItemString(item))
		output.WriteRune('\n')
	}
	if strings.TrimSpace(output.String()) != strings.TrimSpace(expected) {
		g.Fatalf("(%s) Got\n%s", name, output.String())
	}
}
Example #2
0
func tree(g *gt.GopathTest, c *Context, name, expected string) {
	tree := make([]string, 0, 6)
	filepath.Walk(g.Current(), func(path string, info os.FileInfo, err error) error {
		if info.IsDir() {
			return nil
		}
		tree = append(tree, strings.TrimPrefix(path, g.Current()))
		return nil
	})
	sort.Strings(tree)

	output := &bytes.Buffer{}
	for _, item := range tree {
		output.WriteString(item)
		output.WriteRune('\n')
	}
	if strings.TrimSpace(output.String()) != strings.TrimSpace(expected) {
		g.Fatalf("(%s) Got\n%s", name, output.String())
	}
}
Example #3
0
func Vendor(g *gt.GopathTest, name, argLine, expectedOutput string) {
	os.Setenv("GO15VENDOREXPERIMENT", "0")
	output := &bytes.Buffer{}
	args := append([]string{"testing"}, strings.Split(argLine, " ")...)
	printHelp, err := run(output, args)
	if err != nil {
		g.Fatalf("(%s) Error: %v", name, err)
	}
	if printHelp == true {
		g.Fatalf("(%s) Printed help", name)
	}
	if output.String() != expectedOutput {
		g.Fatalf("(%s) Got\n%s", name, output.String())
	}
}