Run doc tests on Web as well (#3799)
This commit is contained in:
parent
88bbdb33da
commit
73c01fff96
5 changed files with 39 additions and 12 deletions
|
|
@ -4,3 +4,6 @@
|
||||||
[build]
|
[build]
|
||||||
rustflags = ["--cfg=unreleased_changelogs"]
|
rustflags = ["--cfg=unreleased_changelogs"]
|
||||||
rustdocflags = ["--cfg=unreleased_changelogs"]
|
rustdocflags = ["--cfg=unreleased_changelogs"]
|
||||||
|
|
||||||
|
[target.wasm32-unknown-unknown]
|
||||||
|
runner = "wasm-bindgen-test-runner"
|
||||||
|
|
|
||||||
35
.github/workflows/ci.yml
vendored
35
.github/workflows/ci.yml
vendored
|
|
@ -60,20 +60,26 @@ jobs:
|
||||||
- { name: 'iOS Aarch64', target: aarch64-apple-ios, os: macos-latest, }
|
- { name: 'iOS Aarch64', target: aarch64-apple-ios, os: macos-latest, }
|
||||||
- { name: 'Web', target: wasm32-unknown-unknown, os: ubuntu-latest, }
|
- { name: 'Web', target: wasm32-unknown-unknown, os: ubuntu-latest, }
|
||||||
exclude:
|
exclude:
|
||||||
|
# Web on nightly needs extra arguments
|
||||||
|
- toolchain: nightly
|
||||||
|
platform: { name: 'Web', target: wasm32-unknown-unknown, os: ubuntu-latest }
|
||||||
# Android is tested on stable-3
|
# Android is tested on stable-3
|
||||||
- toolchain: '1.73'
|
- toolchain: '1.73'
|
||||||
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
|
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
|
||||||
include:
|
include:
|
||||||
- toolchain: '1.73'
|
- toolchain: '1.73'
|
||||||
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
|
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
|
||||||
|
- toolchain: 'nightly'
|
||||||
|
platform: { name: 'Web', target: wasm32-unknown-unknown, os: ubuntu-latest, test-options: -Zdoctest-xcompile }
|
||||||
- toolchain: 'nightly'
|
- toolchain: 'nightly'
|
||||||
platform: {
|
platform: {
|
||||||
name: 'Web Atomic',
|
name: 'Web Atomic',
|
||||||
target: wasm32-unknown-unknown,
|
target: wasm32-unknown-unknown,
|
||||||
os: ubuntu-latest,
|
os: ubuntu-latest,
|
||||||
options: '-Zbuild-std=panic_abort,std',
|
options: '-Zbuild-std=panic_abort,std',
|
||||||
rustflags: '-Ctarget-feature=+atomics,+bulk-memory',
|
test-options: -Zdoctest-xcompile,
|
||||||
components: rust-src,
|
rustflags: '-Ctarget-feature=+atomics,+bulk-memory',
|
||||||
|
components: rust-src,
|
||||||
}
|
}
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|
@ -83,8 +89,10 @@ jobs:
|
||||||
|
|
||||||
# Faster compilation and error on warnings
|
# Faster compilation and error on warnings
|
||||||
RUSTFLAGS: '--codegen=debuginfo=0 --deny=warnings ${{ matrix.platform.rustflags }}'
|
RUSTFLAGS: '--codegen=debuginfo=0 --deny=warnings ${{ matrix.platform.rustflags }}'
|
||||||
|
RUSTDOCFLAGS: ${{ matrix.platform.rustflags }}
|
||||||
|
|
||||||
OPTIONS: --target=${{ matrix.platform.target }} ${{ matrix.platform.options }}
|
OPTIONS: --target=${{ matrix.platform.target }} ${{ matrix.platform.options }}
|
||||||
|
TEST_OPTIONS: ${{ matrix.platform.test-options }}
|
||||||
CMD: ${{ matrix.platform.cmd }}
|
CMD: ${{ matrix.platform.cmd }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -131,6 +139,11 @@ jobs:
|
||||||
if: contains(matrix.platform.target, 'android') && (steps.cargo-apk-cache.outputs.cache-hit != 'true')
|
if: contains(matrix.platform.target, 'android') && (steps.cargo-apk-cache.outputs.cache-hit != 'true')
|
||||||
run: cargo install cargo-apk --version=^0.9.7 --locked
|
run: cargo install cargo-apk --version=^0.9.7 --locked
|
||||||
|
|
||||||
|
- uses: taiki-e/cache-cargo-install-action@v2
|
||||||
|
if: contains(matrix.platform.target, 'wasm32') && matrix.toolchain == 'nightly'
|
||||||
|
with:
|
||||||
|
tool: wasm-bindgen-cli
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@master
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: ${{ matrix.toolchain }}${{ matrix.platform.host }}
|
toolchain: ${{ matrix.toolchain }}${{ matrix.platform.host }}
|
||||||
|
|
@ -162,29 +175,29 @@ jobs:
|
||||||
if: >
|
if: >
|
||||||
!contains(matrix.platform.target, 'android') &&
|
!contains(matrix.platform.target, 'android') &&
|
||||||
!contains(matrix.platform.target, 'ios') &&
|
!contains(matrix.platform.target, 'ios') &&
|
||||||
!contains(matrix.platform.target, 'wasm32') &&
|
(!contains(matrix.platform.target, 'wasm32') || matrix.toolchain == 'nightly') &&
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
matrix.toolchain != '1.73'
|
matrix.toolchain != '1.73'
|
||||||
run: cargo $CMD test $OPTIONS
|
run: cargo $CMD test $OPTIONS
|
||||||
|
|
||||||
- name: Lint with clippy
|
- name: Lint with clippy
|
||||||
if: (matrix.toolchain == 'stable') && !contains(matrix.platform.options, '--no-default-features')
|
if: (matrix.toolchain == 'stable') && !contains(matrix.platform.options, '--no-default-features')
|
||||||
run: cargo clippy --all-targets $OPTIONS -- -Dwarnings
|
run: cargo clippy --all-targets $OPTIONS $TEST_OPTIONS -- -Dwarnings
|
||||||
|
|
||||||
- name: Build tests with serde enabled
|
- name: Build tests with serde enabled
|
||||||
if: >
|
if: >
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
matrix.toolchain != '1.73'
|
matrix.toolchain != '1.73'
|
||||||
run: cargo $CMD test --no-run $OPTIONS --features serde
|
run: cargo $CMD test --no-run $OPTIONS $TEST_OPTIONS --features serde
|
||||||
|
|
||||||
- name: Run tests with serde enabled
|
- name: Run tests with serde enabled
|
||||||
if: >
|
if: >
|
||||||
!contains(matrix.platform.target, 'android') &&
|
!contains(matrix.platform.target, 'android') &&
|
||||||
!contains(matrix.platform.target, 'ios') &&
|
!contains(matrix.platform.target, 'ios') &&
|
||||||
!contains(matrix.platform.target, 'wasm32') &&
|
(!contains(matrix.platform.target, 'wasm32') || matrix.toolchain == 'nightly') &&
|
||||||
!contains(matrix.platform.target, 'redox') &&
|
!contains(matrix.platform.target, 'redox') &&
|
||||||
matrix.toolchain != '1.73'
|
matrix.toolchain != '1.73'
|
||||||
run: cargo $CMD test $OPTIONS --features serde
|
run: cargo $CMD test $OPTIONS $TEST_OPTIONS --features serde
|
||||||
|
|
||||||
- name: Check docs.rs documentation
|
- name: Check docs.rs documentation
|
||||||
if: matrix.toolchain == 'nightly'
|
if: matrix.toolchain == 'nightly'
|
||||||
|
|
|
||||||
|
|
@ -331,6 +331,7 @@ concurrent-queue = { version = "2", default-features = false }
|
||||||
[target.'cfg(target_family = "wasm")'.dev-dependencies]
|
[target.'cfg(target_family = "wasm")'.dev-dependencies]
|
||||||
console_error_panic_hook = "0.1"
|
console_error_panic_hook = "0.1"
|
||||||
tracing-web = "0.1"
|
tracing-web = "0.1"
|
||||||
|
wasm-bindgen-test = "0.3"
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
doc-scrape-examples = true
|
doc-scrape-examples = true
|
||||||
|
|
|
||||||
|
|
@ -616,7 +616,7 @@ pub struct KeyEvent {
|
||||||
/// In games, you often want to ignore repated key events - this can be
|
/// In games, you often want to ignore repated key events - this can be
|
||||||
/// done by ignoring events where this property is set.
|
/// done by ignoring events where this property is set.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```no_run
|
||||||
/// use winit::event::{ElementState, KeyEvent, WindowEvent};
|
/// use winit::event::{ElementState, KeyEvent, WindowEvent};
|
||||||
/// use winit::keyboard::{KeyCode, PhysicalKey};
|
/// use winit::keyboard::{KeyCode, PhysicalKey};
|
||||||
/// # let window_event = WindowEvent::RedrawRequested; // To make the example compile
|
/// # let window_event = WindowEvent::RedrawRequested; // To make the example compile
|
||||||
|
|
|
||||||
|
|
@ -1568,10 +1568,15 @@ impl NamedKey {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// # #[cfg(web_platform)]
|
||||||
|
/// # wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
/// # #[cfg_attr(web_platform, wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
|
/// # fn main() {
|
||||||
/// use winit::keyboard::NamedKey;
|
/// use winit::keyboard::NamedKey;
|
||||||
///
|
///
|
||||||
/// assert_eq!(NamedKey::Enter.to_text(), Some("\r"));
|
/// assert_eq!(NamedKey::Enter.to_text(), Some("\r"));
|
||||||
/// assert_eq!(NamedKey::F20.to_text(), None);
|
/// assert_eq!(NamedKey::F20.to_text(), None);
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn to_text(&self) -> Option<&str> {
|
pub fn to_text(&self) -> Option<&str> {
|
||||||
match self {
|
match self {
|
||||||
|
|
@ -1591,11 +1596,16 @@ impl Key {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// # #[cfg(web_platform)]
|
||||||
|
/// # wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
/// # #[cfg_attr(web_platform, wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
|
/// # fn main() {
|
||||||
/// use winit::keyboard::{Key, NamedKey};
|
/// use winit::keyboard::{Key, NamedKey};
|
||||||
///
|
///
|
||||||
/// assert_eq!(Key::Character("a".into()).to_text(), Some("a"));
|
/// assert_eq!(Key::Character("a".into()).to_text(), Some("a"));
|
||||||
/// assert_eq!(Key::Named(NamedKey::Enter).to_text(), Some("\r"));
|
/// assert_eq!(Key::Named(NamedKey::Enter).to_text(), Some("\r"));
|
||||||
/// assert_eq!(Key::Named(NamedKey::F20).to_text(), None);
|
/// assert_eq!(Key::Named(NamedKey::F20).to_text(), None);
|
||||||
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn to_text(&self) -> Option<&str> {
|
pub fn to_text(&self) -> Option<&str> {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue