Skip to content

Conversation

unvalley
Copy link

@unvalley unvalley commented Aug 3, 2025

Motivation

Closes #7360

Solution

Add minimal tests on wasm32-unknown-unknown to check the intended behavior from #7360

  • Instant::now() panics on unknown WASM.
  • Runtime without time feature (rt only) does not panic.
  • With time feature enabled, using time APIs (sleep) panics on unknown WASM.

@unvalley unvalley changed the title test: add tests for time and wasm test: add tests for time in wasm32-unknown-unknown Aug 3, 2025
@unvalley unvalley marked this pull request as ready for review August 3, 2025 17:51
@ADD-SP ADD-SP added the A-tokio Area: The main tokio crate label Aug 4, 2025
@Darksonn Darksonn added the T-wasm Topic: Web Assembly label Aug 4, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wasm target runs according to this configuration:

tokio/.github/workflows/ci.yml

Lines 1041 to 1057 in 0922aa2

wasm32-unknown-unknown:
name: test tokio for wasm32-unknown-unknown
needs: basics
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust ${{ env.rust_stable }}
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.rust_stable }}
- name: Install wasm-pack
uses: taiki-e/install-action@wasm-pack
- uses: Swatinem/rust-cache@v2
- name: test tokio
run: wasm-pack test --node -- --features "macros sync"
working-directory: tokio

Here, time is not enabled, so this means that we do not run these tests with time enabled at all! You'll have to modify the ci.yml file to test the time case.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, thank you for clarifying! Do we also need to add rt feature here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to run multiple combinations here to really test this.

@@ -1047,7 +1047,7 @@ jobs:

- uses: Swatinem/rust-cache@v2
- name: test tokio
run: wasm-pack test --node -- --features "macros sync"
run: wasm-pack test --node -- --features "macros sync time rt"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you could expand this job to run both with and without time?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for late, I've updated how it tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate T-wasm Topic: Web Assembly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests for Instant::now() and wasm32-unknown-unknown
3 participants