-
Notifications
You must be signed in to change notification settings - Fork 110
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
rustc-generated test harness broken #111
Comments
If anyone has any ideas on how to fix this and allow One option that comes to mind is to drop support for a Another option is to create a |
Does |
Regarding the async main: There one option I see (#104) to support both synchronuous and asynchronuous main functions in |
|
Two observations:
I have no idea how to fix this.
which could be fixed. My question is: what would |
If you remove the dependency on the |
No, in both cases the
I see two:
Looking again, I think that is a better approach. At the time I suggested implementing
This sounds like a feature flag controlling what type
This is only the case if you use upstream Rust's |
What is your use case here exactly (maybe give a reference to an example repo)? We actually have unit tests in
I think writing synchronuous code in an async main function is completely acceptable. The "async" can be completely ignored here.
May be a
I have to admit I'm a bit biased towards the async approach: I failed to write more complex applications (like controlling a water pump via ble and the temperature sensor) using the callback approach without cheating (i.e. creating two instances of the same GPIO pin). I think libtock-rs should offer a usable API - if it's synchronuous, I'm okay with it but currently I see no way how to make callbacks nice and see much more potential in the async approach. |
The repo is google/tock-on-titan. We have 2 test apps (libraries compiled using
Yes, I updated to the latest
This isn't a big deal, but it is additional cognitive overhead. In particular, developers new to Rust and/or Rust's async support may be tripped up by it. On its own, I would expect this to be okay, but the test breakage is a blocker for us.
|
I just stumbled over |
Unfortunately, that only reexports main rather than renames it, so I still get the compile error. |
I've been trying to revive #104, but am running into some issues. Namely:
I haven't looked into how Tokio's macro handles these problems. If it has a solution, then please point me to it. Otherwise, I think we should use another approach to support async main functions. I'm out of time to work on this today. It may be possible to generate the wrapping |
…n boards with no LED capsule. This breaks the existing support for `async` `main()` functions. Instead, an `async_main!()` macro is provided to generate a synchronous `main()` that wraps the provided `async` `main()` function (which, unfortunately, must not be called `main()`). This solves tock#111 and tock#113. I would prefer to be more consistent with Tokio and use a procedural macro attribute (as was originally done in tock#104), but I found that has some major drawbacks: 1. If main() does not parse, the error message does not point to the correct code. 2. It adds a requirement to update `syn` every time the toolchain is updated. These drawbacks are elaborated upon in tock#111.
…n boards with no LED capsule. This breaks the existing support for `async` `main()` functions. Instead, an `async_main!()` macro is provided to generate a synchronous `main()` that wraps the provided `async` `main()` function (which, unfortunately, must not be called `main()`). I would prefer to be more consistent with Tokio and use a procedural macro attribute (as was originally done in tock#104), but I found that has some major drawbacks: 1. If main() does not parse, the error message does not point to the correct code. 2. It adds a requirement to update `syn` every time the toolchain is updated. These drawbacks are elaborated upon in tock#111. This solves tock#111 and tock#113.
I tried this initially but I did choose to not use that approach because it is basically impossible to write unit tests for macro_rules macros. |
I had a look at these tests and I find that (from my perspective) this use case is rather non-canonical.
In my opinion this test runner worked by chance (and best great effort from your side, of course) but this is not a use case which I would necessarily support. |
This must be a solvable problem. I just didn't know of this problem and so didn't think it through. If it becomes consensus that async main is to be discarded I can invest some time here and fix this in #104.
I don't see the connection to elf2tab, actually. Afair it uses just stable rust. If syn matches the rust toolchain of tock which matches the toolchain of libtock-rs there should be no problem. I think a well-tested procedural macro should create appropriate code regardless of the version syn. Actually I see no reason why a non-matching syn version would cause any trouble if it is well-tested. |
There is a continuum between "unit test" and "system test"; Rust's test framework works perfectly fine for this.
We currently run them by hand. Yes, this is hard to get into a CI. We intend to automate this eventually. For local development, the need for physical hardware isn't a problem. Our development machines have the necessary hardware attached.
This use case is very valuable to us. |
Sorry, mis-clicked a moment ago.
We need the Rust test framework to work; I have not found a way to fix it without requiring at least a minimal change to applications using |
Let just emphasize that I appreciate your effort for automatic testing - I personally have a passion for this subject.
I'm thinking in terms of requirements here: Thinking of your code as of downstream to libtock-rs and tock I'm asking myself whether I want to have a test framework which runs on the target framework as a hard requirement to the library - I think the answer is yes. But I think using the rust test harness for the target architecture should not be a hard requirement - I'd prefer a solution like the PoC https://github.com/torfmaster/libtock-tests as a test runner for our integration tests in libtock-rs here. There the automation is already built-in (and could even be extended to run in qemu once the support for riscv is ready, for example). My reason for not wanting a running test harness on the target architecture is not that I necessarily want main to be async ( I would be okay with that) but rather that I want to want avoid building a library around downstream consumers test library requirements - they may have more implications for example future lang_items have to be formed in a certain way just to be compatible with the test framework.
I appreciate this a lot - I'd like to have real tests (running for each PR) for libtock-rs as well as they would have saved us from many regressions we had in the past.
I believe for system/integration tests the framework is right for the test runner but not for the test subject. Just imagine integration tests for a web server using a database. I think the same applies here. In summary: I would like to build a framework for automatic testing - I currently see more potential in beeing automated and stable in the approach of having simple test binaries running on the target (i.e. qemu or real hardware) and a test runner doing the flashing, evaluation, and finally reporting to CI (Jenkings, travis). |
I'd like to distinguish short-term changes versus long-term planning here. In the short term, we cannot update to Longer term, I am fine with switching to another test framework as long as doing so does not negatively impact our developer productivity.
Please clarify what you mean by "test subject" here -- I don't understand your point. |
Solved by #115 |
In PR #103, the Termination implementation for () was removed, which results in the following errors for binaries compiled using
cargo test
:Unfortunately, this is not a trivial fix, as re-adding the Termination implementation for () gives:
The text was updated successfully, but these errors were encountered: