mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
test: add tests for time in wasm32-unknown-unknown (#7510)
This commit is contained in:
parent
8efd04e382
commit
f07233f742
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
@ -1009,9 +1009,18 @@ jobs:
|
||||
working-directory: tokio
|
||||
|
||||
wasm32-unknown-unknown:
|
||||
name: test tokio for wasm32-unknown-unknown
|
||||
name: test tokio for wasm32-unknown-unknown (${{ matrix.name }})
|
||||
needs: basics
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- name: macros sync
|
||||
features: "macros sync"
|
||||
- name: macros sync rt
|
||||
features: "macros sync rt"
|
||||
- name: macros sync time rt
|
||||
features: "macros sync time rt"
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- name: Install Rust 1.88.0
|
||||
@ -1022,8 +1031,8 @@ jobs:
|
||||
uses: taiki-e/install-action@wasm-pack
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: test tokio
|
||||
run: wasm-pack test --node -- --features "macros sync"
|
||||
- name: test tokio (${{ matrix.name }})
|
||||
run: wasm-pack test --node -- --features "${{ matrix.features }}"
|
||||
working-directory: tokio
|
||||
|
||||
wasm32-wasip1:
|
||||
|
40
tokio/tests/time_wasm.rs
Normal file
40
tokio/tests/time_wasm.rs
Normal file
@ -0,0 +1,40 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
|
||||
|
||||
use wasm_bindgen_test::wasm_bindgen_test;
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
#[should_panic]
|
||||
fn instant_now_panics() {
|
||||
let _ = tokio::time::Instant::now();
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "rt", not(feature = "time")))]
|
||||
#[wasm_bindgen_test]
|
||||
fn runtime_without_time_does_not_panic() {
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.build()
|
||||
.unwrap();
|
||||
rt.block_on(async {});
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "rt", feature = "time"))]
|
||||
#[wasm_bindgen_test]
|
||||
#[should_panic] // should remove this once time is supported
|
||||
fn runtime_with_time_does_not_panic() {
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.build()
|
||||
.unwrap();
|
||||
rt.block_on(async {});
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "rt", feature = "time"))]
|
||||
#[wasm_bindgen_test]
|
||||
#[should_panic]
|
||||
fn sleep_panics_on_unknown_unknown() {
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_time()
|
||||
.build()
|
||||
.unwrap();
|
||||
rt.block_on(async { tokio::time::sleep(core::time::Duration::from_millis(1)).await });
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user