fix travis fail on deprecation example test

Former-commit-id: 3f6bb0f01702ab2c2cd7f348b29ec142af036cb3
This commit is contained in:
Gerasimos (Makis) Maropoulos 2019-06-21 23:17:27 +03:00
parent d0104defa8
commit 1f9ead426e
3 changed files with 26 additions and 18 deletions

View File

@ -21,13 +21,21 @@ func getCaller() (string, int) {
for { for {
frame, more := frames.Next() frame, more := frames.Next()
file := frame.File
if (!strings.Contains(frame.File, "github.com/kataras/iris") || splitAfterPart := "/src/"
strings.Contains(frame.File, "github.com/kataras/iris/_examples") || if (!strings.Contains(file, "github.com/kataras/iris") ||
strings.Contains(frame.File, "github.com/iris-contrib/examples") || strings.Contains(file, "github.com/kataras/iris/_examples") ||
(strings.Contains(frame.File, "github.com/kataras/iris/core/router") && !strings.Contains(frame.File, "deprecated.go"))) && strings.Contains(file, "github.com/iris-contrib/examples") ||
!strings.HasSuffix(frame.Func.Name(), ".getCaller") && !strings.Contains(frame.File, "/go/src/testing") { (strings.Contains(file, "github.com/kataras/iris/core/router") && !strings.Contains(file, "deprecated.go"))) &&
return frame.File, frame.Line !strings.HasSuffix(frame.Func.Name(), ".getCaller") && !strings.Contains(file, "/go/src/testing") {
// remove the $GOPATH.
n := strings.Index(file, splitAfterPart)
if n != -1 {
file = file[n+len(splitAfterPart):]
}
return file, frame.Line
} }
if !more { if !more {

View File

@ -15,7 +15,7 @@ func ExampleParty_StaticWeb() {
fmt.Print(err) fmt.Print(err)
// Output: StaticWeb is DEPRECATED and it will be removed eventually. // Output: StaticWeb is DEPRECATED and it will be removed eventually.
// Source: C:/mygopath/src/github.com/kataras/iris/core/router/deprecated_example_test.go:9 // Source: github.com/kataras/iris/core/router/deprecated_example_test.go:9
// Use .HandleDir("/static", "./assets") instead. // Use .HandleDir("/static", "./assets") instead.
} }
@ -30,7 +30,7 @@ func ExampleParty_StaticHandler() {
fmt.Print(err) fmt.Print(err)
// Output: StaticHandler is DEPRECATED and it will be removed eventually. // Output: StaticHandler is DEPRECATED and it will be removed eventually.
// Source: C:/mygopath/src/github.com/kataras/iris/core/router/deprecated_example_test.go:24 // Source: github.com/kataras/iris/core/router/deprecated_example_test.go:24
// Use iris.FileServer("./assets", iris.DirOptions{ShowList: false, Gzip: true}) instead. // Use iris.FileServer("./assets", iris.DirOptions{ShowList: false, Gzip: true}) instead.
} }
@ -46,7 +46,7 @@ func ExampleParty_StaticEmbedded() {
fmt.Print(err) fmt.Print(err)
// Output: StaticEmbedded is DEPRECATED and it will be removed eventually. // Output: StaticEmbedded is DEPRECATED and it will be removed eventually.
// It is also miss the AssetInfo bindata function, which is required now. // It is also miss the AssetInfo bindata function, which is required now.
// Source: C:/mygopath/src/github.com/kataras/iris/core/router/deprecated_example_test.go:39 // Source: github.com/kataras/iris/core/router/deprecated_example_test.go:39
// Use .HandleDir("/static", "./assets", iris.DirOptions{Asset: Asset, AssetInfo: AssetInfo, AssetNames: AssetNames}) instead. // Use .HandleDir("/static", "./assets", iris.DirOptions{Asset: Asset, AssetInfo: AssetInfo, AssetNames: AssetNames}) instead.
} }
@ -62,6 +62,6 @@ func ExampleParty_StaticEmbeddedGzip() {
fmt.Print(err) fmt.Print(err)
// Output: StaticEmbeddedGzip is DEPRECATED and it will be removed eventually. // Output: StaticEmbeddedGzip is DEPRECATED and it will be removed eventually.
// It is also miss the AssetInfo bindata function, which is required now. // It is also miss the AssetInfo bindata function, which is required now.
// Source: C:/mygopath/src/github.com/kataras/iris/core/router/deprecated_example_test.go:55 // Source: github.com/kataras/iris/core/router/deprecated_example_test.go:55
// Use .HandleDir("/static", "./assets", iris.DirOptions{Gzip: true, Asset: Asset, AssetInfo: AssetInfo, AssetNames: AssetNames}) instead. // Use .HandleDir("/static", "./assets", iris.DirOptions{Gzip: true, Asset: Asset, AssetInfo: AssetInfo, AssetNames: AssetNames}) instead.
} }

View File

@ -100,9 +100,8 @@ type embeddedFileSystem struct {
vdir string vdir string
dirNames map[string]*embeddedDir // embedded tools doesn't give that info, so we initialize it in order to support `ShowList` on embedded files as well. dirNames map[string]*embeddedDir // embedded tools doesn't give that info, so we initialize it in order to support `ShowList` on embedded files as well.
asset func(name string) ([]byte, error) asset func(name string) ([]byte, error)
assetInfo func(name string) (os.FileInfo, error) assetInfo func(name string) (os.FileInfo, error)
assetNames []string
} }
var _ http.FileSystem = (*embeddedFileSystem)(nil) var _ http.FileSystem = (*embeddedFileSystem)(nil)
@ -263,13 +262,14 @@ func FileServer(directory string, opts ...DirOptions) context.Handler {
vdir: vdir, vdir: vdir,
dirNames: dirNames, dirNames: dirNames,
asset: asset, asset: asset,
assetInfo: assetInfo, assetInfo: assetInfo,
assetNames: names,
} }
} else if !DirectoryExists(directory) {
panic("FileServer: system directory: " + directory + " does not exist")
} }
// Let it for now.
// else if !DirectoryExists(directory) {
// panic("FileServer: system directory: " + directory + " does not exist")
// }
plainStatusCode := func(ctx context.Context, statusCode int) { plainStatusCode := func(ctx context.Context, statusCode int) {
if writer, ok := ctx.ResponseWriter().(*context.GzipResponseWriter); ok && writer != nil { if writer, ok := ctx.ResponseWriter().(*context.GzipResponseWriter); ok && writer != nil {