This repository was archived by the owner on Sep 9, 2020. It is now read-only.
File tree 6 files changed +34
-13
lines changed
6 files changed +34
-13
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ func (c *Ctx) LoadProject() (*Project, error) {
105
105
return nil , err
106
106
}
107
107
108
- err = checkCfgFilenames (root )
108
+ err = checkGopkgFilenames (root )
109
109
if err != nil {
110
110
return nil , err
111
111
}
Original file line number Diff line number Diff line change @@ -264,14 +264,20 @@ func TestLoadProjectNoSrcDir(t *testing.T) {
264
264
}
265
265
}
266
266
267
- func TestLoadProjectCfgFileCase (t * testing.T ) {
267
+ func TestLoadProjectGopkgFilenames (t * testing.T ) {
268
+ // We are trying to skip this test on file systems which are case-sensiive. We could
269
+ // have used `fs.IsCaseSensitiveFilesystem` for this check. However, the code we are
270
+ // testing also relies on `fs.IsCaseSensitiveFilesystem`. So a bug in
271
+ // `fs.IsCaseSensitiveFilesystem` could prevent this test from being run. This is the
272
+ // only scenario where we prefer the OS heuristic over doing the actual work of
273
+ // validating filesystem case sensitivity via `fs.IsCaseSensitiveFilesystem`.
268
274
if runtime .GOOS != "windows" && runtime .GOOS != "darwin" {
269
275
t .Skip ("skip this test on non-Windows, non-macOS" )
270
276
}
271
277
272
278
// Here we test that a manifest filename with incorrect case throws an error. Similar
273
279
// error will also be thrown for the lock file as well which has been tested in
274
- // `project_test.go#TestCheckCfgFilenames `. So not repeating here.
280
+ // `project_test.go#TestCheckGopkgFilenames `. So not repeating here.
275
281
276
282
h := test .NewHelper (t )
277
283
defer h .Cleanup ()
Original file line number Diff line number Diff line change @@ -272,7 +272,7 @@ var errPathNotDir = errors.New("given path is not a directory")
272
272
// `os.Stat` and return a map with key and value as filenames which exist in the folder.
273
273
//
274
274
// Otherwise, it reads the contents of the directory and returns a map which has the
275
- // given file name as the key and actual filename as the value if it was found.
275
+ // given file name as the key and actual filename as the value( if it was found) .
276
276
func ReadActualFilenames (dirPath string , names []string ) (map [string ]string , error ) {
277
277
actualFilenames := make (map [string ]string , len (names ))
278
278
if len (names ) == 0 {
Original file line number Diff line number Diff line change @@ -265,6 +265,12 @@ func TestIsCaseSensitiveFilesystem(t *testing.T) {
265
265
}
266
266
267
267
func TestReadActualFilenames (t * testing.T ) {
268
+ // We are trying to skip this test on file systems which are case-sensiive. We could
269
+ // have used `fs.IsCaseSensitiveFilesystem` for this check. However, the code we are
270
+ // testing also relies on `fs.IsCaseSensitiveFilesystem`. So a bug in
271
+ // `fs.IsCaseSensitiveFilesystem` could prevent this test from being run. This is the
272
+ // only scenario where we prefer the OS heuristic over doing the actual work of
273
+ // validating filesystem case sensitivity via `fs.IsCaseSensitiveFilesystem`.
268
274
if runtime .GOOS != "windows" && runtime .GOOS != "darwin" {
269
275
t .Skip ("skip this test on non-Windows, non-macOS" )
270
276
}
@@ -332,7 +338,8 @@ func TestReadActualFilenames(t *testing.T) {
332
338
t .Fatalf ("unexpected error: %+v" , err )
333
339
}
334
340
if ! reflect .DeepEqual (c .want , got ) {
335
- t .Fatalf ("returned value does not match expected: \n \t (GOT) %v\n \t (WNT) %v" , got , c .want )
341
+ t .Fatalf ("returned value does not match expected: \n \t (GOT) %v\n \t (WNT) %v" ,
342
+ got , c .want )
336
343
}
337
344
}
338
345
}
Original file line number Diff line number Diff line change @@ -42,17 +42,19 @@ func findProjectRoot(from string) (string, error) {
42
42
}
43
43
}
44
44
45
- // checkCfgFilenames validates filename case for the manifest and lock files.
45
+ // checkGopkgFilenames validates filename case for the manifest and lock files.
46
46
//
47
- // This is relevant on case-insensitive file systems like Windows and macOS.
47
+ // This is relevant on case-insensitive file systems like the defaults in Windows and
48
+ // macOS.
48
49
//
49
50
// If manifest file is not found, it returns an error indicating the project could not be
50
51
// found. If it is found but the case does not match, an error is returned. If a lock
51
52
// file is not found, no error is returned as lock file is optional. If it is found but
52
53
// the case does not match, an error is returned.
53
- func checkCfgFilenames (projectRoot string ) error {
54
- // ReadActualFilenames is actually costly. Since this check is not relevant to
55
- // case-sensitive filesystems like ext4(linux), try for an early return.
54
+ func checkGopkgFilenames (projectRoot string ) error {
55
+ // ReadActualFilenames is actually costly. Since the check to validate filename case
56
+ // for Gopkg filenames is not relevant to case-sensitive filesystems like
57
+ // ext4(linux), try for an early return.
56
58
caseSensitive , err := fs .IsCaseSensitiveFilesystem (projectRoot )
57
59
if err != nil {
58
60
return errors .Wrap (err , "could not check validity of configuration filenames" )
Original file line number Diff line number Diff line change @@ -63,7 +63,13 @@ func TestFindRoot(t *testing.T) {
63
63
}
64
64
}
65
65
66
- func TestCheckCfgFilenames (t * testing.T ) {
66
+ func TestCheckGopkgFilenames (t * testing.T ) {
67
+ // We are trying to skip this test on file systems which are case-sensiive. We could
68
+ // have used `fs.IsCaseSensitiveFilesystem` for this check. However, the code we are
69
+ // testing also relies on `fs.IsCaseSensitiveFilesystem`. So a bug in
70
+ // `fs.IsCaseSensitiveFilesystem` could prevent this test from being run. This is the
71
+ // only scenario where we prefer the OS heuristic over doing the actual work of
72
+ // validating filesystem case sensitivity via `fs.IsCaseSensitiveFilesystem`.
67
73
if runtime .GOOS != "windows" && runtime .GOOS != "darwin" {
68
74
t .Skip ("skip this test on non-Windows, non-macOS" )
69
75
}
@@ -111,11 +117,11 @@ func TestCheckCfgFilenames(t *testing.T) {
111
117
tmpPath := h .Path ("." )
112
118
113
119
// Create any files that are needed for the test before invoking
114
- // `checkCfgFilenames `.
120
+ // `checkGopkgFilenames `.
115
121
for _ , file := range c .createFiles {
116
122
h .TempFile (file , "" )
117
123
}
118
- err := checkCfgFilenames (tmpPath )
124
+ err := checkGopkgFilenames (tmpPath )
119
125
120
126
if c .wantErr {
121
127
if err == nil {
You can’t perform that action at this time.
0 commit comments