-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search test data directory path dynamically #2005
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2005 +/- ##
==========================================
- Coverage 75.45% 75.40% -0.05%
==========================================
Files 100 100
Lines 8968 8983 +15
==========================================
+ Hits 6767 6774 +7
- Misses 1601 1604 +3
- Partials 600 605 +5 ☔ View full report in Codecov by Sentry. |
0de1a56
to
0a52825
Compare
0a52825
to
120ac22
Compare
clients/feeder/feeder.go
Outdated
func findTargetDirectory(targetRelPath string) (string, error) { | ||
wd, err := os.Getwd() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
for root := wd; ; root = filepath.Dir(root) { | ||
if _, err := os.Stat(filepath.Join(root, targetRelPath)); err == nil { | ||
return filepath.Join(root, targetRelPath), nil | ||
} else if !os.IsNotExist(err) { | ||
return "", err | ||
} else if newRoot := filepath.Dir(root); newRoot == root { | ||
return "", os.ErrNotExist | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the function can be simplified as follows:
func findTargetDirectory(targetRelPath string) (string, error) { | |
wd, err := os.Getwd() | |
if err != nil { | |
return "", err | |
} | |
for root := wd; ; root = filepath.Dir(root) { | |
if _, err := os.Stat(filepath.Join(root, targetRelPath)); err == nil { | |
return filepath.Join(root, targetRelPath), nil | |
} else if !os.IsNotExist(err) { | |
return "", err | |
} else if newRoot := filepath.Dir(root); newRoot == root { | |
return "", os.ErrNotExist | |
} | |
} | |
} | |
func findTargetDirectory(targetRelPath string) (string, error) { | |
root, err := os.Getwd() | |
if err != nil { | |
return "", err | |
} | |
for { | |
targetPath := filepath.Join(root, targetRelPath) | |
if _, err := os.Stat(targetPath); err == nil { | |
return targetPath, nil | |
} else if !os.IsNotExist(err) { | |
return "", err | |
} | |
newRoot := filepath.Dir(root) | |
if newRoot == root { | |
return "", os.ErrNotExist | |
} | |
root = newRoot | |
} | |
} |
120ac22
to
2fd1c2e
Compare
Description
This PR modifies the implementation of finding the target test data directory. The issue with the existing implementation is that if a user changes the repository's name from juno to whatever, the tests will fail. Also, any tests that rely on NewTestClient in
cmd/juno
will fail because the base directory extracted will be../juno/cmd/juno
instead of../juno
.