-
Notifications
You must be signed in to change notification settings - Fork 22
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
test: fix tests after requiring correct path #34
Conversation
…proto into am/correct-import-path
…proto into am/fix-tests-2
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'm going to mark this PR as R4R.
All tests pass with protoc >=3.19.4, and the SDK uses 3.21.*.
It doesn't pass with older versions like protoc 3.0.2 and 2.6.1. I personally don't think it's worth pursuing more time fixing tests to make old versions happy, since all Cosmos chains should use recent versions of protoc. If that's fine with you, I need an admin to remove the "Required" check on github for the pb-3.0.2
and pb-2.6.1
job
// Replace package name | ||
re := regexp.MustCompile(`\npackage (.*);`) | ||
correctPkgName := strings.Trim(strings.ReplaceAll(folder, "/", "."), ".") | ||
replaceStr := fmt.Sprintf("\npackage $1.%s;", correctPkgName) | ||
content = re.ReplaceAllString(content, replaceStr) |
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.
Non-trivial hack/fix.
protoc-gen-combo
generates, from a single proto file, 3 or 4 other derived proto files in subfolders, with minimal changes that are defined below in this file. It simply copies the original file, and modifies the pasted file using simple string search and replace.
I added this piece of logic here so that the derived proto file has correct package name.
expectedPrefix := strings.ReplaceAll(*f.Package, ".", "/") + "/" | ||
if !strings.HasPrefix(*f.Name, expectedPrefix) { | ||
panic(fmt.Errorf("file name %s does not start with expected %s; please make sure your folder structure matches the proto files fully-qualified names", *f.Name, expectedPrefix)) | ||
if f.Package != nil { |
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.
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.
Can we have a new tag then after this PR?
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'd say let's tag after #37? Around next week. Or we can do 2 consecutive tags too.
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.
Alright 👍🏾 I didn't see #37
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.
ACK!
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.
ack
Fix tests failures introduced in #32.
It's a huge PR. I'll summarize the work done:
cd
s so that the import paths matches the proto files' package names. (mostly done with sed magic + human cleanup after).option go_package = "...";
so that the generated go package name matches other manually coded files in the same output folder.-
to_
because proto package name doesn't allow-
.Allow changes above are "maintenance" updates. There are however 2 non-trivial changes:
protoc-gen-combo
, which is used internally to generate other proto files from a source proto file. test: fix tests after requiring correct path #34 (comment)