Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 3586bf4

Browse files
committed
Add test for import path case-sense handling in SM
1 parent e6f3b62 commit 3586bf4

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

internal/gps/manager_test.go

+46
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,52 @@ func TestGetSources(t *testing.T) {
397397
clean()
398398
}
399399

400+
func TestFSCaseSensitivityConvergesSources(t *testing.T) {
401+
if testing.Short() {
402+
t.Skip("Skipping slow test in short mode")
403+
}
404+
405+
sm, clean := mkNaiveSM(t)
406+
defer clean()
407+
408+
pi1 := mkPI("github.com/sdboyer/deptest").normalize()
409+
sm.SyncSourceFor(pi1)
410+
sg1, err := sm.srcCoord.getSourceGatewayFor(context.Background(), pi1)
411+
if err != nil {
412+
t.Fatal(err)
413+
}
414+
415+
pi2 := mkPI("github.com/Sdboyer/deptest").normalize()
416+
sm.SyncSourceFor(pi2)
417+
sg2, err := sm.srcCoord.getSourceGatewayFor(context.Background(), pi2)
418+
if err != nil {
419+
t.Fatal(err)
420+
}
421+
422+
path1 := sg1.src.(*gitSource).repo.LocalPath()
423+
t.Log("path1:", path1)
424+
stat1, err := os.Stat(path1)
425+
if err != nil {
426+
t.Fatal(err)
427+
}
428+
path2 := sg2.src.(*gitSource).repo.LocalPath()
429+
t.Log("path2:", path2)
430+
stat2, err := os.Stat(path2)
431+
if err != nil {
432+
t.Fatal(err)
433+
}
434+
435+
same, count := os.SameFile(stat1, stat2), len(sm.srcCoord.srcs)
436+
if same && count != 1 {
437+
t.Log("are same, count", count)
438+
t.Fatal("on case-insensitive filesystem, case-varying sources should have been folded together but were not")
439+
}
440+
if !same && count != 2 {
441+
t.Log("not same, count", count)
442+
t.Fatal("on case-sensitive filesystem, case-varying sources should not have been folded together, but were")
443+
}
444+
}
445+
400446
// Regression test for #32
401447
func TestGetInfoListVersionsOrdering(t *testing.T) {
402448
// This test is quite slow, skip it on -short

0 commit comments

Comments
 (0)