Skip to content

Commit cfa98ed

Browse files
committed
terminal: clear substitute path rules cache when config is used
Fixes #3565
1 parent 938cb6e commit cfa98ed

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

pkg/terminal/command_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,3 +1488,26 @@ func TestListPackages(t *testing.T) {
14881488
}
14891489
})
14901490
}
1491+
1492+
func TestSubstitutePathAndList(t *testing.T) {
1493+
// checks that substitute path rules do not remain cached after a -clear.
1494+
// See issue #3565.
1495+
withTestTerminal("math", t, func(term *FakeTerminal) {
1496+
term.MustExec("break main.main")
1497+
term.MustExec("continue")
1498+
fixturesDir, _ := filepath.Abs(test.FindFixturesDir())
1499+
term.MustExec("config substitute-path " + fixturesDir + " /blah")
1500+
out, _ := term.Exec("list")
1501+
t.Logf("list output %s", out)
1502+
if !strings.Contains(out, "/blah/math.go") {
1503+
t.Fatalf("bad output")
1504+
}
1505+
term.MustExec("config substitute-path -clear")
1506+
term.MustExec("config substitute-path " + fixturesDir + " /blah2")
1507+
out, _ = term.Exec("list")
1508+
t.Logf("list output %s", out)
1509+
if !strings.Contains(out, "/blah2/math.go") {
1510+
t.Fatalf("bad output")
1511+
}
1512+
})
1513+
}

pkg/terminal/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
)
1212

1313
func configureCmd(t *Term, ctx callContext, args string) error {
14+
t.substitutePathRulesCache = nil
1415
switch args {
1516
case "-list":
1617
return configureList(t)

0 commit comments

Comments
 (0)