@@ -4,13 +4,15 @@ import (
4
4
"encoding/json"
5
5
"os"
6
6
"path/filepath"
7
+ "runtime"
8
+ "strings"
7
9
"testing"
8
10
)
9
11
10
12
func globDockerfiles (dir string ) ([]string , error ) {
11
13
files := make ([]string , 0 )
12
14
err := filepath .Walk (dir , func (path string , f os.FileInfo , err error ) error {
13
- if filepath .Base (path ) == "Dockerfile" {
15
+ if strings . HasPrefix ( filepath .Base (path ), "Dockerfile." ) {
14
16
files = append (files , path )
15
17
}
16
18
return nil
@@ -21,8 +23,14 @@ func globDockerfiles(dir string) ([]string, error) {
21
23
22
24
// TestParseAllDockerfiles checks there are no panics when processing all Dockerfiles we have
23
25
func TestParseAllDockerfiles (t * testing.T ) {
24
- projectRoot := "../../"
26
+ _ , currentFilePath , _ , ok := runtime .Caller (0 )
27
+ if ! ok {
28
+ t .Fatal ("failed to get caller information" )
29
+ }
30
+
31
+ projectRoot := filepath .Join (filepath .Dir (currentFilePath ), "../../" )
25
32
dockerfiles := noErr2 (globDockerfiles (projectRoot ))
33
+ t .Logf ("found %d Dockerfiles in %s" , len (dockerfiles ), projectRoot )
26
34
27
35
if len (dockerfiles ) < 6 {
28
36
t .Fatalf ("not enough Dockerfiles found, got %+v" , dockerfiles )
0 commit comments