Skip to content

Commit c3470b9

Browse files
authored
fix(user-executors): ensure unique lib paths in user executor files retrieval (#867)
1 parent f257f5e commit c3470b9

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

venom.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,30 @@ func (v *Venom) GetExecutorRunner(ctx context.Context, ts TestStep, h H) (contex
187187

188188
func (v *Venom) getUserExecutorFilesPath(ctx context.Context, vars map[string]string) []string {
189189
var libpaths []string
190+
// ensure libpaths is unique
191+
seen := make(map[string]struct{})
192+
190193
if v.LibDir != "" {
191-
p := strings.Split(v.LibDir, string(os.PathListSeparator))
192-
libpaths = append(libpaths, p...)
194+
for _, lp := range strings.Split(v.LibDir, string(os.PathListSeparator)) {
195+
abs := strings.TrimSpace(lp)
196+
if abs == "" {
197+
continue
198+
}
199+
absPath, err := filepath.Abs(abs)
200+
if err == nil {
201+
seen[absPath] = struct{}{}
202+
libpaths = append(libpaths, absPath)
203+
}
204+
}
193205
}
194-
libpaths = append(libpaths, path.Join(vars["venom.testsuite.workdir"], "lib"))
195206

207+
relLib := path.Join(vars["venom.testsuite.workdir"], "lib")
208+
if absRelLib, err := filepath.Abs(relLib); err == nil {
209+
if _, exists := seen[absRelLib]; !exists {
210+
libpaths = append(libpaths, absRelLib)
211+
seen[absRelLib] = struct{}{}
212+
}
213+
}
196214
//use a map to avoid duplicates
197215
filepaths := make(map[string]bool)
198216

0 commit comments

Comments
 (0)