Exemple #1
0
func getTestCommand() cli.Command {
	return cli.Command{
		Name:      "test",
		ShortName: "test",
		Usage:     "Run Gohan script Test",
		Description: `
Run gohan script yaml code.`,
		Flags: []cli.Flag{
			cli.StringFlag{Name: "config-file,c", Value: defaultConfigFile, Usage: "config file path"},
		},
		Action: func(c *cli.Context) {
			dir := c.Args()[0]
			configFile := c.String("config-file")
			loadConfig(configFile)
			gohanscript.RunTests(dir)
		},
	}
}
Exemple #2
0
package gohanscript_test

import (
	"testing"

	"github.com/cloudwan/gohan/extension/gohanscript"
	//Import gohan script lib
	_ "github.com/cloudwan/gohan/extension/gohanscript/autogen"

	. "github.com/onsi/ginkgo"
)

var _ = Describe("Run Gohan script test", func() {
	Context("When given gohan script test", func() {
		It("All test should be passed", func() {
			_, _, failed := gohanscript.RunTests("./tests")
			if failed != 0 {
				Fail("gohanscript test failed")
			}
		})
	})
})

func BenchmarkFib(b *testing.B) {
	vm := gohanscript.NewVM()
	vm.LoadFile("./examples/fib.yaml")
	for n := 0; n < b.N; n++ {
		vm.Run(map[string]interface{}{})
	}
}
Exemple #3
0
func TestLibFuncs(t *testing.T) {
	_, _, failed := gohanscript.RunTests("./tests")
	if failed != 0 {
		t.Fail()
	}
}