Skip to content

Commit b0484c9

Browse files
authored
Merge pull request #188 from revel/hotfix-1
Fixed issues with test cases and launching app using the run mode
2 parents 6ecc0a7 + c7f4307 commit b0484c9

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: go
22

33
go:
4-
- "1.12.x"
54
- "1.13.x"
65
- "1.14.x"
76
- "tip"

harness/app.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ func (cmd AppCmd) Start(c *model.CommandConfig) error {
9393
}
9494

9595
// Run the app server inline. Never returns.
96-
func (cmd AppCmd) Run() {
96+
func (cmd AppCmd) Run(c *model.CommandConfig) {
97+
utils.CmdInit(cmd.Cmd, !c.Vendored, c.AppPath)
9798
utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args)
9899
if err := cmd.Cmd.Run(); err != nil {
99100
utils.Logger.Fatal("Error running:", "error", err)

harness/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func newCompileError(paths *model.RevelContainer, output []byte) *utils.SourceEr
458458
return compileError
459459
}
460460

461-
// RevelMainTemplate template for app/tmp/main.go
461+
// RevelMainTemplate template for app/tmp/run/run.go
462462
const RevelRunTemplate = `// GENERATED CODE - DO NOT EDIT
463463
// This file is the run file for Revel.
464464
// It registers all the controllers and provides details for the Revel server engine to

model/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Version struct {
2121
var frameworkCompatibleRangeList = [][]string{
2222
{"0.0.0", "0.20.0"}, // minimum Revel version to use with this version of the tool
2323
{"0.19.99", "0.30.0"}, // Compatible with Framework V 0.19.99 - 0.30.0
24-
{"1.0.0", "1.1.0"}, // Compatible with Framework V 1.0 - 1.1
24+
{"1.0.0", "1.9.0"}, // Compatible with Framework V 1.0 - 1.9
2525
}
2626

2727
// Parses a version like v1.2.3a or 1.2

parser2/source_processor.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"go/ast"
1313
"go/token"
1414
"go/scanner"
15-
1615
)
1716

1817
type (
@@ -111,9 +110,8 @@ func (s *SourceProcessor) addPackages() (err error) {
111110
s.packageList, err = packages.Load(config, allPackages...)
112111
s.log.Info("Loaded modules ", "len results", len(s.packageList), "error", err)
113112

114-
115113
// Now process the files in the aap source folder s.revelContainer.ImportPath + "/...",
116-
err = utils.Walk(s.revelContainer.AppPath, s.processPath)
114+
err = utils.Walk(s.revelContainer.BasePath, s.processPath)
117115
s.log.Info("Loaded apps and modules ", "len results", len(s.packageList), "error", err)
118116
return
119117
}
@@ -136,8 +134,10 @@ func (s *SourceProcessor) processPath(path string, info os.FileInfo, err error)
136134
pkgImportPath := s.revelContainer.ImportPath
137135
appPath := s.revelContainer.BasePath
138136
if appPath != path {
139-
pkgImportPath = s.revelContainer.ImportPath + "/" + filepath.ToSlash(path[len(appPath)+1:])
137+
pkgImportPath = s.revelContainer.ImportPath + "/" + filepath.ToSlash(path[len(appPath) + 1:])
140138
}
139+
s.log.Info("Processing source package folder", "package", pkgImportPath, "path", path)
140+
141141
// Parse files within the path.
142142
var pkgMap map[string]*ast.Package
143143
fset := token.NewFileSet()
@@ -173,14 +173,15 @@ func (s *SourceProcessor) processPath(path string, info os.FileInfo, err error)
173173
ast.Print(nil, err)
174174
s.log.Fatal("Failed to parse dir", "error", err)
175175
}
176+
176177
// Skip "main" packages.
177178
delete(pkgMap, "main")
178179

179180
// Ignore packages that end with _test
180181
// These cannot be included in source code that is not generated specifically as a test
181182
for i := range pkgMap {
182183
if len(i) > 6 {
183-
if string(i[len(i)-5:]) == "_test" {
184+
if string(i[len(i) - 5:]) == "_test" {
184185
delete(pkgMap, i)
185186
}
186187
}
@@ -194,7 +195,7 @@ func (s *SourceProcessor) processPath(path string, info os.FileInfo, err error)
194195
// There should be only one package in this directory.
195196
if len(pkgMap) > 1 {
196197
for i := range pkgMap {
197-
println("Found package ", i)
198+
println("Found duplicate packages in single directory ", i)
198199
}
199200
utils.Logger.Fatal("Most unexpected! Multiple packages in a single directory:", "packages", pkgMap)
200201
}
@@ -205,10 +206,10 @@ func (s *SourceProcessor) processPath(path string, info os.FileInfo, err error)
205206
p.Fset = fset
206207
for _, pkg := range pkgMap {
207208
p.Name = pkg.Name
208-
s.log.Info("Found package","pkg.Name", pkg.Name,"p.Name", p.PkgPath)
209-
for filename,astFile := range pkg.Files {
210-
p.Syntax = append(p.Syntax,astFile)
211-
p.GoFiles = append(p.GoFiles,filename)
209+
s.log.Info("Found package", "pkg.Name", pkg.Name, "p.Name", p.PkgPath)
210+
for filename, astFile := range pkg.Files {
211+
p.Syntax = append(p.Syntax, astFile)
212+
p.GoFiles = append(p.GoFiles, filename)
212213
}
213214
}
214215
s.packageList = append(s.packageList, p)

revel/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,6 @@ func runApp(c *model.CommandConfig) (err error) {
162162
if c.HistoricMode {
163163
runMode = revel_path.RunMode
164164
}
165-
app.Cmd(runMode).Run()
165+
app.Cmd(runMode).Run(c)
166166
return
167167
}

0 commit comments

Comments
 (0)