mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 10:44:28 +00:00
Fixed remaining test
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
"ARITY":[5,6,7,8],
|
||||
"BLOCK_NESTING":[9, 10, 12, 13],
|
||||
"CYCLO":[30, 35, 45, 60],
|
||||
"TOO_MANY_IVARS": [20, 25, 40, 45],
|
||||
"TOO_MANY_IVARS": [28, 30, 40, 45],
|
||||
"TOO_MANY_FUNCTIONS": [20, 30, 40, 50],
|
||||
"TOTAL_COMPLEXITY": [150, 250, 400, 500],
|
||||
"LOC": [100, 175, 250, 320],
|
||||
|
||||
@@ -146,6 +146,9 @@ func Build(c *model.CommandConfig, paths *model.RevelContainer) (_ *App, err err
|
||||
|
||||
for {
|
||||
appVersion := getAppVersion(paths)
|
||||
if appVersion == "" {
|
||||
appVersion = "noVersionProvided"
|
||||
}
|
||||
|
||||
buildTime := time.Now().UTC().Format(time.RFC3339)
|
||||
versionLinkerFlags := fmt.Sprintf("-X %s/app.AppVersion=%s -X %s/app.BuildTime=%s",
|
||||
@@ -165,7 +168,12 @@ func Build(c *model.CommandConfig, paths *model.RevelContainer) (_ *App, err err
|
||||
}
|
||||
flags = append(flags, c.BuildFlags...)
|
||||
if !contains(flags, "-ldflags") {
|
||||
flags = append(flags, "-ldflags", versionLinkerFlags)
|
||||
ldflags := "-ldflags= " + versionLinkerFlags
|
||||
// Add in build flags
|
||||
for i := range c.BuildFlags {
|
||||
ldflags += "-X '" + c.BuildFlags[i] + "'"
|
||||
}
|
||||
flags = append(flags, ldflags)
|
||||
}
|
||||
if !contains(flags, "-tags") {
|
||||
flags = append(flags, "-tags", buildTags)
|
||||
|
||||
@@ -2,6 +2,7 @@ package command
|
||||
type (
|
||||
Version struct {
|
||||
ImportCommand
|
||||
Update bool `short:"u" long:"Update the framework and modules" required:"false"`
|
||||
Update bool `short:"u" long:"update" description:"Update the framework and modules" required:"false"`
|
||||
UpdateVersion string `long:"update-version" description:"Specify the version the revel and app will be switched to" required:"false"`
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3,7 +3,6 @@ package model
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/revel/cmd"
|
||||
// "github.com/revel/cmd/logger"
|
||||
"github.com/revel/cmd/utils"
|
||||
"go/ast"
|
||||
"go/build"
|
||||
@@ -47,21 +46,14 @@ type (
|
||||
AppName string // The application name
|
||||
HistoricBuildMode bool `long:"historic-build-mode" description:"If set the code is scanned using the original parsers, not the go.1.11+"` // True if debug is active
|
||||
Vendored bool // True if the application is vendored
|
||||
PackageResolver func(pkgName string) error // a packge resolver for the config
|
||||
PackageResolver func(pkgName string) error // a package resolver for the config
|
||||
BuildFlags []string `short:"X" long:"build-flags" description:"These flags will be used when building the application. May be specified multiple times, only applicable for Build, Run, Package, Test commands"`
|
||||
|
||||
New command.New `command:"new"` // The new command
|
||||
// The build command
|
||||
New command.New `command:"new"`
|
||||
Build command.Build `command:"build"`
|
||||
// The run command
|
||||
Run command.Run `command:"run"`
|
||||
// The package command
|
||||
Package command.Package `command:"package"`
|
||||
// The clean command
|
||||
Clean command.Clean `command:"clean"`
|
||||
// The test command
|
||||
Test command.Test `command:"test"`
|
||||
// The version command
|
||||
Version command.Version `command:"version"`
|
||||
}
|
||||
)
|
||||
@@ -112,7 +104,7 @@ func (c *CommandConfig) UpdateImportPath() error {
|
||||
if strings.HasPrefix(currentPath, path) && len(currentPath) > len(path) + 1 {
|
||||
importPath = currentPath[len(path) + 1:]
|
||||
// Remove the source from the path if it is there
|
||||
if len(importPath) > 4 && strings.ToLower(importPath[0:4]) == "src/" {
|
||||
if len(importPath) > 4 && (strings.ToLower(importPath[0:4]) == "src/" || strings.ToLower(importPath[0:4]) == "src\\") {
|
||||
importPath = importPath[4:]
|
||||
} else if importPath == "src" {
|
||||
if c.Index != VERSION {
|
||||
|
||||
@@ -22,12 +22,12 @@ func TestClean(t *testing.T) {
|
||||
main.Commands[model.NEW].RunWith(c)
|
||||
c.Index = model.TEST
|
||||
main.Commands[model.TEST].RunWith(c)
|
||||
a.True(utils.Exists(filepath.Join(gopath, "src", "clean-test", "app", "tmp", "main.go")),
|
||||
"Missing main from path "+filepath.Join(gopath, "src", "clean-test", "app", "tmp", "main.go"))
|
||||
a.True(utils.Exists(filepath.Join(gopath, "clean-test", "app", "tmp", "main.go")),
|
||||
"Missing main from path "+filepath.Join(gopath, "clean-test", "app", "tmp", "main.go"))
|
||||
c.Clean.ImportPath = c.ImportPath
|
||||
a.Nil(main.Commands[model.CLEAN].RunWith(c), "Failed to run clean-test")
|
||||
a.False(utils.Exists(filepath.Join(gopath, "src", "clean-test", "app", "tmp", "main.go")),
|
||||
"Did not remove main from path "+filepath.Join(gopath, "src", "clean-test", "app", "tmp", "main.go"))
|
||||
a.False(utils.Exists(filepath.Join(gopath, "clean-test", "app", "tmp", "main.go")),
|
||||
"Did not remove main from path "+filepath.Join(gopath, "clean-test", "app", "tmp", "main.go"))
|
||||
})
|
||||
if !t.Failed() {
|
||||
if err := os.RemoveAll(gopath); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user