-
Notifications
You must be signed in to change notification settings - Fork 32
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
Experiment with a cttests_macro proc_macro. #416
Conversation
Does this mean that the tests are always run now or ... ? |
Yeah, the additions to There is a few things in this which i should probably investigate further, regarding the globbing/lossy string conversion which might cause an issue if someone uses a non-lossy convertible character in their home directory since the manifest path is absolute. |
Got it. I'm happy with this: do you want to do some of the tidying up you suggested before merge? |
I would like to tidy it up, I don't think the current master branch is affected by it so it likely is introducing a top-level It looks like both rust-lang/glob#78 In theory we can avoid non-utf8 characters by building a relative path, but it is complicated by proc_macros not having a specified working directory. Assuming it is in the workspace somewhere, we should be able to strip the common prefix between the working dir, and A bit hacky, but I think that is the only option short of fixing glob. |
Presumably we haven't made the non-utf8 situation worse in this PR? |
It has or would, currently we only deal with known utf8 paths relative to the working dir. Previously we had known utf8 input, and never need to convert the output so it should be fine currently. |
I did my best to fix it in the obvious issues in that last patch, but i'm not really sure how to go about creating non-utf8 directory to test. I think though it should put us back on par with the current code on the master branch. |
I think this comes under "if the fix doesn't work for some edge cases, we'll deal with it when we find it"! Please squash. |
Squashed. |
bors r+ |
416: Experiment with a cttests_macro proc_macro. r=ltratt a=ratmice Co-authored-by: matt rice <[email protected]>
Build failed: |
Oops, above commit msg should be |
Please squash. |
Sorry. One last change to fix clippy. |
Please squash. |
Squashed -- hopefully for the last time! |
bors r+ |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
This was just a quick experiment with generating tests which parse
cttest/src/*.test
from a proc_macro to generate#[test]
fragments.cttests/build.rs
helper functions to a filesrc/cgen_helper.rs
cttests_macro
crate (doesn't need to live on crates.io, used as a path dependency)#[should_panic]
tests calling thecgen_helper
functions.In #415 I know you said it probably would not be worth the effort, but I was curious if it would actually work.
You had mentioned using the lang_tester crate. But I'm just uncertain of how to go about that given the build.rs involvement and (moderate) dependence on cargo environment variables like
OUT_DIR
within theCTBuilders
.Not really sure if all the additional complexity is worthwhile however at least I learned some proc_macro things.