Skip to content

Commit 89bcb96

Browse files
committed
chore: failing tests fixes
1 parent 4190cec commit 89bcb96

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

cli/commands/list/list.go

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ func discoveredToListed(components component.Components, opts *Options) (ListedC
166166
listedComponents := make(ListedComponents, 0, len(components))
167167
errs := []error{}
168168

169+
// Ensure working directory is absolute for reliable path relativity calculations
170+
absWorkingDir := opts.WorkingDir
171+
if !filepath.IsAbs(absWorkingDir) {
172+
var err error
173+
174+
absWorkingDir, err = filepath.Abs(absWorkingDir)
175+
if err != nil {
176+
return nil, errors.New(err)
177+
}
178+
}
179+
169180
for _, c := range components {
170181
if c.External() && !opts.External {
171182
continue
@@ -188,7 +199,19 @@ func discoveredToListed(components component.Components, opts *Options) (ListedC
188199
}
189200
}
190201

191-
relPath, err := filepath.Rel(opts.WorkingDir, c.Path())
202+
// Ensure component path is absolute for reliable relativity calculation
203+
componentPath := c.Path()
204+
if !filepath.IsAbs(componentPath) {
205+
var err error
206+
207+
componentPath, err = filepath.Abs(componentPath)
208+
if err != nil {
209+
errs = append(errs, errors.New(err))
210+
continue
211+
}
212+
}
213+
214+
relPath, err := filepath.Rel(absWorkingDir, componentPath)
192215
if err != nil {
193216
errs = append(errs, errors.New(err))
194217

@@ -210,7 +233,19 @@ func discoveredToListed(components component.Components, opts *Options) (ListedC
210233
listedCfg.Dependencies = make([]*ListedComponent, len(c.Dependencies()))
211234

212235
for i, dep := range c.Dependencies() {
213-
relDepPath, err := filepath.Rel(opts.WorkingDir, dep.Path())
236+
// Ensure dependency path is absolute for reliable relativity calculation
237+
depPath := dep.Path()
238+
if !filepath.IsAbs(depPath) {
239+
var err error
240+
241+
depPath, err = filepath.Abs(depPath)
242+
if err != nil {
243+
errs = append(errs, errors.New(err))
244+
continue
245+
}
246+
}
247+
248+
relDepPath, err := filepath.Rel(absWorkingDir, depPath)
214249
if err != nil {
215250
errs = append(errs, errors.New(err))
216251

internal/discovery/discovery.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,12 @@ func (d *Discovery) skipDirIfIgnorable(l log.Logger, path string) error {
745745
for _, pattern := range d.compiledExcludePatterns {
746746
if pattern.Compiled.Match(canonicalDir) {
747747
l.Debugf("Directory %s excluded by glob %s", canonicalDir, pattern.Original)
748+
749+
// Report the exclusion if we have a report instance
750+
if d.report != nil {
751+
d.reportUnitExclusion(l, canonicalDir, report.ReasonExcludeDir)
752+
}
753+
748754
return filepath.SkipDir
749755
}
750756
}

0 commit comments

Comments
 (0)