-
Notifications
You must be signed in to change notification settings - Fork 132
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
generate codegen testcode at buildtime #163
Conversation
This breaks at least the case of generated code being imported through `include!` macro: ``` error: an inner attribute is not permitted in this context --> /home/zeenix/checkout/dbus-rs/target/debug/build/codegen-tests-34abc2ff2e0eca43/out/policykit.rs:3:3 | 3 | #![allow(dead_code)] | ^ | = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. ``` This will become a problem in the following patch, where we use `include!` macro to include the generated code into the tests code.
Let's make use of build script to generate the test code before the tests are run but after dbus-codegen crate has been built. Fixes diwic#162.
Really nice, thanks for cleaning that up! I was wondering if one could use the path attribute |
No worries. :)
I'll have a look at both approaches you mentioned but what is the deal with |
Also, we can have the |
dbus-codegen, when run against some server, that server usually returns many interfaces, including Properties and Introspectable. We generate code for them, but it is seldom used by the program that's including the module. They end up being dead code.
We could, I would consider this the fallback option if neither of my proposed solutions above work. |
Yeah i understand that bit but as I said rustc didn't complain at all about dead code with my first patch only (i-e without my tests architecture changes). The reason is that there is already an
I looked into the The second alternative you mentioned, sounds fine to me and I'll have a look at that, if I didn't convince you above. :) |
Ok so path will not work according to rust-lang/rust#48250 I decided it wasn't such a big deal to add "allow(dead_code)" when you use the module, and maybe we can just call it a feature that the resulting code can be used inside an |
Ok, so after some more code review I realized it was a bit silly that we just generated the asref file without doing anything with it so I added a test for that as well. Apparently the "Generic" part isn't working yet... |
Cool, things you find out when you add tests :) |
Fixes #162