comprehensive-rust icon indicating copy to clipboard operation
comprehensive-rust copied to clipboard

Add async examples that can't run in playground as cargo crates

Open djmitche opened this issue 2 years ago • 3 comments

From https://github.com/google/comprehensive-rust/pull/496/#discussion_r1166652299

djmitche avatar Apr 14 '23 14:04 djmitche

Specifically, this comment

I would suggest adding the large async examples to the repository as full Cargo projects (similar to how the Android chapter handles things).

That makes it trivial for an instructor to find known-good versions of the code, and we also get coverage from cargo build when you add those projects to the workspace for the repository.

However, I don't see this example.

⸩ git ls-files | grep Cargo.toml
Cargo.toml
mdbook-exerciser/Cargo.toml
src/bare-metal/alloc-example/Cargo.toml
src/bare-metal/aps/examples/Cargo.toml
src/bare-metal/microcontrollers/examples/Cargo.toml
src/bare-metal/useful-crates/allocator-example/Cargo.toml
src/bare-metal/useful-crates/zerocopy-example/Cargo.toml
src/exercises/Cargo.toml
src/exercises/bare-metal/compass/Cargo.toml
src/exercises/bare-metal/rtc/Cargo.toml
src/exercises/concurrency/elevator/Cargo.toml

and in fact only some of those crates are referenced in the top-level workspace.

@qwandor the Git history suggests that this relates to the work that you did around exercises? Any chance you could elaborate how that works (or is supposed to work) in the README or a linked file?

djmitche avatar May 08 '23 19:05 djmitche

Right now, we have src/exercises/Cargo.toml, which in turn references a few Rust files. It brings in dependencies such as reqwest, scraper, and thiserror. This gives us some coverage via cargo build and cargo test.

You could directly extend this to include the dependencies for async examples — or you could create a different project if needed (I would aim for simplicity and just extend the current file).

For the Android day, we have fully functioning Android.bp files in the repository. They reference all the examples and ensures that we can build it when needed. I would like to build it in CI, but I haven't set that up yet.

mgeisler avatar May 09 '23 08:05 mgeisler

We should also take a look at mdbook-keeper (#175), which I believe is a testing tool which would allow us to include snippets with dependencies.

mgeisler avatar May 10 '23 20:05 mgeisler