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

codegen: rework ABI tests to use a single C program for each test #1050

Merged
merged 2 commits into from
Feb 7, 2021

Conversation

pbor
Copy link
Contributor

@pbor pbor commented Feb 6, 2021

This is a first step in the plan outlined in #1047

Instead of compiling a C program for each layout and one for each
constant to check, generate a single layout.c and a single
constant.c which output all the values, one per line.
On the rust side, it is easier to compile and run the C program
just once and then parse its output one line at a time to compare
with the corresponding rust record.

Note also that C programs are now taken by the system's header
files (eg atk.h) rather than from -DATK_FOO=1 passed by the
test itself. I think this is actually the right thing to check
since that is the real value we want to compare with.
However this also means that the test will fail when run on
a system older than the one used to generate the gir files, since
some constants may not present in the headers.

@pbor
Copy link
Contributor Author

pbor commented Feb 6, 2021

A successful run after a regen can be seen here: https://github.com/pbor/gtk-rs/runs/1845572278?check_suite_focus=true

@sdroege
Copy link
Member

sdroege commented Feb 6, 2021

Can you put a WIP PR of gtk-rs up with the changes this would do?

@sdroege
Copy link
Member

sdroege commented Feb 6, 2021

Note also that C programs are now taken by the system's header
files (eg atk.h) rather than from -DATK_FOO=1 passed by the
test itself. I think this is actually the right thing to check
since that is the real value we want to compare with.
However this also means that the test will fail when run on
a system older than the one used to generate the gir files, since
some constants may not present in the headers.

This was also the case before as mentioned on IRC, but AFAIU you unconfused yourself since then? :)

src/codegen/sys/tests.rs Outdated Show resolved Hide resolved
src/codegen/sys/tests.rs Outdated Show resolved Hide resolved
src/codegen/sys/tests.rs Outdated Show resolved Hide resolved
@sdroege
Copy link
Member

sdroege commented Feb 6, 2021

Looks OK otherwise, even simpler and cleaner than before in gir and the generated code will be so much faster.

@pbor pbor force-pushed the c_abi branch 2 times, most recently from 4adcbf8 to b4d02c2 Compare February 6, 2021 20:37
@pbor pbor mentioned this pull request Feb 6, 2021
@pbor
Copy link
Contributor Author

pbor commented Feb 6, 2021

Can you put a WIP PR of gtk-rs up with the changes this would do?

gtk-rs/gtk3-rs#293

Copy link
Member

@sdroege sdroege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me apart from gtk-rs/gtk3-rs#293 (comment)

@GuillaumeGomez ?

Instead of compiling a C program for each layout and one for each
constant to check, generate a single layout.c and a single
constant.c which output all the values, one per line.
On the rust side, it is easier to compile and run the C program
just once and then parse its output one line at a time to compare
with the corresponding rust record.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants