本文整理汇总了Golang中github.com/jingweno/gotask/tasking.T.Fatal方法的典型用法代码示例。如果您正苦于以下问题:Golang T.Fatal方法的具体用法?Golang T.Fatal怎么用?Golang T.Fatal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jingweno/gotask/tasking.T
的用法示例。
在下文中一共展示了T.Fatal方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TaskTestPostgres
// NAME
// check data generated from ModSQL into a Postgre database
//
// DESCRIPTION
//
// To create the database:
//
// sudo -u postgres createuser USER --no-superuser --no-createrole --no-createdb
// sudo -u postgres createdb modsql_test --owner USER
//
// Note: substitute "USER" by your user name.
//
// To remove it:
//
// sudo -u postgres dropdb modsql_test
func TaskTestPostgres(t *tasking.T) {
db, err := sql.Open("postgres", fmt.Sprintf("user=%s dbname=%s host=%s sslmode=disable",
username, dbname, host.postgres))
if err != nil {
t.Fatal(err)
}
if err = modsql.Load(db, filepath.Join("data", "sql", "postgres_init.sql")); err != nil {
t.Error(err)
} else {
if err = modsql.Load(db, filepath.Join("data", "sql", "postgres_test.sql")); err != nil {
t.Error(err)
}
testInsert(t, db, modsql.Postgres)
if err = modsql.Load(db, filepath.Join("data", "sql", "postgres_drop.sql")); err != nil {
t.Error(err)
}
}
db.Close()
if !t.Failed() {
t.Log("--- PASS")
}
}
示例2: TaskTestMySQL
// NAME
// test-mysql - check data generated from ModSQL into a MySQL database
//
// DESCRIPTION
//
// To create the database:
//
// mysql -p
// mysql> create database modsql_test;
// mysql> GRANT ALL PRIVILEGES ON modsql_test.* to [email protected];
//
// Note: substitute "USER" by your user name.
//
// To remove it:
//
// mysql> drop database modsql_test;
func TaskTestMySQL(t *tasking.T) {
// Format used in "github.com/serbaut/go-mysql"
//db, err := sql.Open("mysql", fmt.Sprintf("mysql://%[email protected](unix)/%s?socket=%s",
//username, dbname, host.mysql))
db, err := sql.Open("mysql", fmt.Sprintf("%[email protected](%s)/%s?parseTime=true",
username, host.mysql, dbname))
if err != nil {
t.Fatal(err)
}
if err = modsql.Load(db, filepath.Join("data", "sql", "mysql_init.sql")); err != nil {
t.Error(err)
} else {
if err = modsql.Load(db, filepath.Join("data", "sql", "mysql_test.sql")); err != nil {
t.Error(err)
}
testInsert(t, db, modsql.MySQL)
if err = modsql.Load(db, filepath.Join("data", "sql", "mysql_drop.sql")); err != nil {
t.Error(err)
}
}
db.Close()
if !t.Failed() {
t.Log("--- PASS")
}
}
示例3: TaskTestSQLite
// NAME
// test-sqlite - check data generated from ModSQL into a SQLite database
func TaskTestSQLite(t *tasking.T) {
filename := dbname + ".db"
defer func() {
if err := os.Remove(filename); err != nil {
t.Error(err)
}
}()
db, err := sql.Open("sqlite3", filename)
if err != nil {
t.Fatal(err)
}
if err = modsql.Load(db, filepath.Join("data", "sql", "sqlite_init.sql")); err != nil {
t.Error(err)
} else {
if err = modsql.Load(db, filepath.Join("data", "sql", "sqlite_test.sql")); err != nil {
t.Error(err)
}
testInsert(t, db, modsql.SQLite)
if err = modsql.Load(db, filepath.Join("data", "sql", "sqlite_drop.sql")); err != nil {
t.Error(err)
}
}
db.Close()
if !t.Failed() {
t.Log("--- PASS")
}
}
示例4: init
func init() {
var t *tasking.T
u, err := user.Current()
if err != nil {
t.Fatal(err)
}
username = u.Username
}
示例5: TaskSpecgen
// NAME
// specgen - generates Go code from the UPnP specification files.
//
// DESCRIPTION
// The specification is available for download from:
//
// OPTIONS
// -s, --spec_filename=<upnpresources.zip>
// Path to the specification file, available from http://upnp.org/resources/upnpresources.zip
// -o, --out_dir=<output directory>
// Path to the output directory. This is is where the DCP source files will be placed. Should normally correspond to the directory for github.com/huin/goupnp/dcps
// --nogofmt
// Disable passing the output through gofmt. Do this if debugging code output problems and needing to see the generated code prior to being passed through gofmt.
func TaskSpecgen(t *tasking.T) {
specFilename := t.Flags.String("spec-filename")
if specFilename == "" {
specFilename = t.Flags.String("s")
}
if specFilename == "" {
t.Fatal("--spec_filename is required")
}
outDir := t.Flags.String("out-dir")
if outDir == "" {
outDir = t.Flags.String("o")
}
if outDir == "" {
log.Fatal("--out_dir is required")
}
useGofmt := !t.Flags.Bool("nogofmt")
specArchive, err := openZipfile(specFilename)
if err != nil {
t.Fatalf("Error opening spec file: %v", err)
}
defer specArchive.Close()
dcpCol := newDcpsCollection()
for _, f := range globFiles("standardizeddcps/*/*.zip", specArchive.Reader) {
dirName := strings.TrimPrefix(f.Name, "standardizeddcps/")
slashIndex := strings.Index(dirName, "/")
if slashIndex == -1 {
// Should not happen.
t.Logf("Could not find / in %q", dirName)
return
}
dirName = dirName[:slashIndex]
dcp := dcpCol.dcpForDir(dirName)
if dcp == nil {
t.Logf("No alias defined for directory %q: skipping %s\n", dirName, f.Name)
continue
} else {
t.Logf("Alias found for directory %q: processing %s\n", dirName, f.Name)
}
dcp.processZipFile(f)
}
for _, dcp := range dcpCol.dcpByAlias {
if err := dcp.writePackage(outDir, useGofmt); err != nil {
log.Printf("Error writing package %q: %v", dcp.Metadata.Name, err)
}
}
}
示例6: TaskPackage
// NAME
// package - cross compile gh and package it
//
// DESCRIPTION
// Cross compile gh and package it into PWD/target
func TaskPackage(t *tasking.T) {
gopath, err := ioutil.TempDir("", "gh-build")
os.Setenv("GOPATH", gopath)
t.Logf("GOPATH=%s\n", gopath)
path := fmt.Sprintf("%s%c%s", filepath.Join(gopath, "bin"), os.PathListSeparator, os.Getenv("PATH"))
os.Setenv("PATH", path)
t.Logf("PATH=%s\n", path)
t.Logf("Packaging for %s...\n", runtime.GOOS)
t.Log("Installing dependencies...")
TaskInstallDeps(t)
pwd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
ghPath := filepath.Join(gopath, "src", "github.com", "jingweno", "gh")
t.Logf("Copying source from %s to %s\n", pwd, ghPath)
err = copyDir(pwd, ghPath)
if err != nil {
t.Fatal(err)
}
err = os.Chdir(ghPath)
if err != nil {
t.Fatal(err)
}
t.Log("Cross-compiling...")
godepPath := filepath.Join(ghPath, "Godeps", "_workspace")
gopath = fmt.Sprintf("%s%c%s", gopath, os.PathListSeparator, godepPath)
os.Setenv("GOPATH", gopath)
TaskCrossCompile(t)
source := filepath.Join(ghPath, "target")
target := filepath.Join(pwd, "target")
t.Logf("Copying build artifacts from %s to %s...\n", source, target)
err = mkdirAll(target)
if err != nil {
t.Fatal(err)
}
err = copyBuildArtifacts(source, target)
if err != nil {
t.Fatal(err)
}
}
示例7: TaskClean
// NAME
// clean - Clean deployment leftovers and wizard configs
//
// DESCRIPTION
// Runs `rice clean` to remove leftovers from resource embedding,
// purges wizard configs if any left in project dir.
//
// OPTIONS
// --all, -a
// Remove platform specific output dir
func TaskClean(t *tasking.T) {
for _, name := range []string{wizardManifest, wizardIcon, docFile} {
if err := os.Remove(name); err != nil && !os.IsNotExist(err) {
t.Fatalf("clean: %v", err)
}
}
if err := exec.Command("rice", "clean").Run(); err != nil {
t.Fatalf("clean: rice: %v", err)
}
if t.Flags.Bool("all") {
path := fmt.Sprintf("%s/%s", outDir, runtime.GOOS)
if len(path) < 2 {
t.Fatal("can't happen")
}
if err := os.RemoveAll(path); err != nil {
t.Fatal(err)
}
}
}
示例8: TaskInit
// NAME
// generate files for 'model_task.go'
func TaskInit(t *tasking.T) {
newTestdata := false
src := "model_task.go"
srcInfo, err := os.Stat(src)
if err != nil {
t.Fatal(err)
}
dstInfo, err := os.Stat(filepath.Join("model", "sqlmodel.go"))
if err != nil {
newTestdata = true
}
if err := os.Chdir("test"); err != nil {
t.Fatal(err)
}
if newTestdata || srcInfo.ModTime().After(dstInfo.ModTime()) {
taskBuildModel(t)
}
}
示例9: TaskGenerateObjects
// NAME
// generate-objects - Generate net/artproto/gen_objects.go
//
// DESCRIPTION
// Generates trivial setter methods and constants for the object types
// defined in net/artproto/objects.
//
// OPTIONS
// --nogofmt
// do not process the generated code through gofmt
func TaskGenerateObjects(t *tasking.T) {
var w io.WriteCloser
w, err := os.Create(filepath.Join("net", "artproto", "gen_objects.go"))
if err != nil {
t.Fatal(err)
}
if !t.Flags.Bool("nogofmt") {
if gofmt, err := codegen.NewGofmtWriteCloser(w); err != nil {
w.Close()
t.Fatal(err)
} else {
w = gofmt
}
}
defer w.Close()
cw := &CodeWriter{W: w}
cw.Printf(`// GENERATED CODE - DO NOT EDIT.
// This code is generated with the following command:
//
// gotask generate-objects
`)
cw.Printf("package artproto\n")
for _, typeID := range artproto.ObjTypeIDs {
if err := generateForObject(cw, typeID); err != nil {
t.Fatal(err)
}
}
if cw.Err != nil {
t.Fatal(cw.Err)
}
}
示例10: TaskDeploy
// NAME
// deploy - Run platform-specific deployment routine
//
// DESCRIPTION
// Embeds resources, compiles binary, copies related libs and plugins, etc...
// Distribution-ready application package will be the result of this task.
// Supported platforms are: darwin, linux, windows.
//
// OPTIONS
// --verbose, -v
// Enable some logging
// --dmg
// Create an installable dmg (darwin only)
func TaskDeploy(t *tasking.T) {
deploy, ok := deployers[runtime.GOOS]
if !ok {
t.Fatal("deploy: platform unsupported:", runtime.GOOS)
}
verbose = t.Flags.Bool("verbose")
// prepare output path
path := fmt.Sprintf("%s/%s", outDir, runtime.GOOS)
if err := os.RemoveAll(path); err != nil {
t.Fatal(err)
}
if err := os.MkdirAll(path, 0755); err != nil {
t.Fatal(err)
}
// gather info
pkgInfo, err := getPkgInfo()
if err != nil {
t.Fatal(err)
}
qtInfo, err := getQtInfo()
if err != nil {
t.Fatal(err)
}
// read deploy profile
buf, err := ioutil.ReadFile(deployProfileSrc)
if err != nil {
t.Fatal(err)
}
var profile deployProfile
err = yaml.Unmarshal(buf, &profile)
if err != nil {
t.Fatalf("deploy: profile: %v\n", err)
} else if verbose {
t.Log("deploy: profile loaded")
}
cfg := config{
PkgInfo: pkgInfo,
QtInfo: qtInfo,
Path: path,
Profile: profile,
}
if t.Flags.Bool("verbose") {
t.Log("deploy: package name:", pkgInfo.Name)
t.Logf("deploy: qt base: %s (%s)\n", qtInfo.BasePath, qtInfo.Version)
}
// embed resources
if verbose {
t.Log("deploy: embedding resources")
}
if err := exec.Command("rice", "embed-go").Run(); err != nil {
t.Fatalf("deploy: rice: %v", err)
}
// run deployment
if err := deploy(&cfg, t); err != nil {
if err := os.RemoveAll(path); err != nil {
t.Fatal(err)
}
t.Fatal(err)
}
// clean leftovers
if err := exec.Command("rice", "clean").Run(); err != nil {
t.Fatalf("clean: rice: %v", err)
}
}
示例11: TaskBottle
// NAME
// bottle - build homebrew bottle for gh
//
// DESCRIPTION
// Build homebrew bottle for gh into PWD/target.
func TaskBottle(t *tasking.T) {
pwd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
target := filepath.Join(pwd, "target")
err = mkdirAll(target)
if err != nil {
t.Fatal(err)
}
err = t.Exec("brew", "list", "gh")
if err == nil {
err := t.Exec("brew", "uninstall", "gh")
if err != nil {
t.Fatal(err)
}
}
err = t.Exec("brew", "install", "--build-from-source", "--build-bottle", "gh")
if err != nil {
t.Fatal(err)
}
err = os.Chdir(target)
if err != nil {
t.Fatal(err)
}
err = t.Exec("brew", "bottle", "gh")
if err != nil {
t.Fatal(err)
}
}