-
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
Rust tests for new compiler #53
base: master
Are you sure you want to change the base?
Conversation
We're working with a reduced spec set; some of the Rust codegen is failing, so those specs have been removed here.
All tests generate and pass, but aren't actually testing anything at the moment.
@CWood1 and @GreyCat - Design question for you guys. Right now, Rust uses lifetimes so it can avoid structs having to copy all the bytes off the stream into owned storage. This causes issues with opaque types ( I'm going to skip the test for now, but there are a couple potential solutions I can think of:
My preference is towards number 3 (since the point of generating code is to deal with APIs that don't look nice, and Rust should be able to figure things out without needing to be explicit about lifetimes when using generated structs), but figured it was worth getting some input. |
Alright, next issue: even using the While I'd normally prefer using a plain reference so that I don't need heap allocation, we'd run into an issue because Rust would be unable to establish ownership; the "child" wouldn't be owned by anyone. Instead, I think what can be done is non-opaque user types that don't recurse (the vast majority of cases) are owned by the parent (thus avoiding allocation), while opaque and recursive classes use the heap-allocated boxes because they're unable to establish that it's safe without. |
Next version is available, and tests basic asserts. There's plenty of functionality left to test, but some of it will need support from the compiler before it can be enabled. The following test cases aren't currently part of the full suite, but should be added later:
|
Companion to kaitai-io/kaitai_struct_compiler#164.
Sets up the the translator and test infrastructure to work better with Rust and the new runtime library. Currently the CI script fails with a parse error in
cargo junit
(@CWood1 may need to look at that), butcargo test
runs just fine.Right now we're not actually asserting anything (because the compiler isn't actually generating anything), but this at least proves that everything compiles. Getting it to work can be done incrementally, this is a foundation.