Skip to content

Commit

Permalink
fix examples & add ci for running examples (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
BugenZhao authored Nov 22, 2024
1 parent d76a821 commit 8124357
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/check-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ jobs:
run: cargo clippy --all-targets --all-features
- name: Run tests
run: cargo test
- name: Run examples
run: |
for example in $(ls examples/ | sed 's/\.rs$//'); do
cargo run --example $example
done
semver:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions examples/detach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async fn main() {
tokio::spawn(root.instrument(work(rx)));

sleep(Duration::from_millis(100)).await;
let tree = registry.get(&()).unwrap().to_string();
let tree = registry.get(()).unwrap().to_string();

// work [106.290ms]
// select [106.093ms]
Expand All @@ -62,7 +62,7 @@ async fn main() {
println!("{tree}");

sleep(Duration::from_secs(1)).await;
let tree = registry.get(&()).unwrap().to_string();
let tree = registry.get(()).unwrap().to_string();

// work [1.112s]
// rx [606.944ms]
Expand All @@ -72,7 +72,7 @@ async fn main() {

tx.send(()).unwrap();
sleep(Duration::from_secs(1)).await;
let tree = registry.get(&()).unwrap().to_string();
let tree = registry.get(()).unwrap().to_string();

// work [2.117s]
// fut [2.117s]
Expand Down
2 changes: 1 addition & 1 deletion examples/verbose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async fn work(verbose: bool) -> String {
tokio::spawn(root.instrument(foo()));

sleep(Duration::from_secs(1)).await;
registry.get(&()).unwrap().to_string()
registry.get(()).unwrap().to_string()
}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.74
1.82
4 changes: 2 additions & 2 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ impl Registry {
///
/// 1. If the current task is registered with a registry, returns the registry.
/// 2. If the global registry is initialized with
/// [`init_global_registry`](crate::global::init_global_registry), returns the global
/// registry.
/// [`init_global_registry`](crate::global::init_global_registry), returns the global
/// registry.
/// 3. Otherwise, returns `None`.
pub fn try_current() -> Option<Self> {
crate::root::current_registry()
Expand Down
2 changes: 0 additions & 2 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,5 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![cfg(test)]

mod functionality;
mod spawn;

0 comments on commit 8124357

Please sign in to comment.