Skip to content
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

msgfmt.py: Test validity of generated file #131853

Closed
StanFromIreland opened this issue Mar 28, 2025 · 2 comments
Closed

msgfmt.py: Test validity of generated file #131853

StanFromIreland opened this issue Mar 28, 2025 · 2 comments
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@StanFromIreland
Copy link
Contributor

StanFromIreland commented Mar 28, 2025

Feature or enhancement

Proposal:

Test the header of the binary .mo file is generated correctly and is as expected for example the start of a msgfmt.py generated file:

de12 0495 0000 0000 0900 0000 1c00 0000
6400 0000 0000 0000 0000 0000 0000 0000

de12 0495 - magic number
0000 0000 - version
0900 0000 - # of entries
1c00 0000 - start of key index
6400 0000 - size of value table
0000 0000 - size of hash table
0000 0000 - offset of hash table

We currently do not test the structure of the .mo though it is partially covered as I presume the translation tests may fail but that depends on gettext.

Testing the last four will result in errors with a msgfmt.c generated general.mo as msgfmt.c generates a hash table (this will change soon I hope as we will too #131725 :-) so I think we should just test the first 3 for now and test the rest later.

I will send a pr

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

@StanFromIreland StanFromIreland added the type-feature A feature request or enhancement label Mar 28, 2025
@picnixz picnixz added the tests Tests in the Lib/test dir label Mar 28, 2025
@StanFromIreland

This comment has been minimized.

@tomasr8
Copy link
Member

tomasr8 commented Mar 28, 2025

We already have some binary MO files checked in as part of the snapshot tests, but an explicit test for the header would be nice 👍

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Mar 29, 2025
Use a generated .mo file instead of a checked in one.
serhiy-storchaka added a commit that referenced this issue Mar 29, 2025
Use a generated .mo file instead of a checked in one.
@tomasr8 tomasr8 closed this as completed Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement
Projects
Status: Done
Development

No branches or pull requests

3 participants