diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b33eaa..5bae600 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - rust_version: ['1.64.0', stable, nightly] + toolchain: ['1.65.0', stable, nightly] platform: - { target: x86_64-pc-windows-msvc, os: windows-latest, } - { target: i686-pc-windows-msvc, os: windows-latest, } @@ -33,9 +33,15 @@ jobs: - { target: x86_64-apple-darwin, os: macos-latest, } - { target: wasm32-unknown-unknown, os: ubuntu-latest, } - { target: aarch64-linux-android, os: ubuntu-latest, cmd: apk, options: "--example winit_test_android" } + exclude: + # Android is tested on stable-3 + - toolchain: '1.65.0' + platform: { target: aarch64-linux-android, os: ubuntu-latest, cmd: apk, options: "--example winit_test_android" } include: - - rust_version: nightly + - toolchain: nightly platform: { target: wasm32-unknown-unknown, os: ubuntu-latest, options: "-Zbuild-std=panic_abort,std", rustflags: "-Ctarget-feature=+atomics,+bulk-memory" } + - toolchain: '1.69.0' + platform: { target: aarch64-linux-android, os: ubuntu-latest, cmd: apk, options: "--example winit_test_android" } env: RUST_BACKTRACE: 1 @@ -57,7 +63,7 @@ jobs: - uses: hecrj/setup-rust-action@v2 with: - rust-version: ${{ matrix.rust_version }}${{ matrix.platform.host }} + rust-version: ${{ matrix.toolchain }}${{ matrix.platform.host }} targets: ${{ matrix.platform.target }} components: clippy, rust-src @@ -65,6 +71,10 @@ jobs: if: (matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686') run: sudo apt-get update && sudo apt-get install gcc-multilib + - name: Install dependencies + if: matrix.platform.os == 'ubuntu-latest' + run: sudo apt-get update && sudo apt-get install libxkbcommon-dev libxkbcommon-x11-dev + - name: Install cargo-apk if: contains(matrix.platform.target, 'android') run: cargo install cargo-apk @@ -81,7 +91,7 @@ jobs: !contains(matrix.platform.target, 'freebsd') && !contains(matrix.platform.target, 'netbsd') && !contains(matrix.platform.target, 'android') && - matrix.rust_version != '1.64.0' + matrix.toolchain != '1.65.0' run: cargo $CMD test --no-run --verbose --target ${{ matrix.platform.target }} $OPTIONS --features $FEATURES - name: Run tests @@ -109,7 +119,7 @@ jobs: - name: Lint with clippy shell: bash if: > - (matrix.rust_version == 'stable') && + (matrix.toolchain == 'stable') && !contains(matrix.platform.options, '--no-default-features') && !((matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686')) && !contains(matrix.platform.target, 'redox') && @@ -120,7 +130,7 @@ jobs: - name: Lint with rustdoc shell: bash if: > - (matrix.rust_version == 'stable') && + (matrix.toolchain == 'stable') && !contains(matrix.platform.options, '--no-default-features') && !((matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686')) && !contains(matrix.platform.target, 'redox') && diff --git a/Cargo.toml b/Cargo.toml index 5282415..350be78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,16 +2,17 @@ name = "winit-test" version = "0.1.2" edition = "2021" -authors = ["John Nunley "] +authors = ["John Nunley "] description = "Run tests using the winit event loop" license = "MIT OR Apache-2.0 OR Zlib" documentation = "https://docs.rs/winit-test" repository = "https://github.com/notgull/winit-test" homepage = "https://github.com/notgull/winit-test" +rust-version = "1.65.0" [dependencies] owo-colors = "3.5.0" -winit = { version = "0.28.6", default-features = false, features = ["android-native-activity"] } +winit = { version = "0.29.2", default-features = false, features = ["android-native-activity"] } [features] default = ["x11", "wayland", "wayland-dlopen"] @@ -24,7 +25,7 @@ wasm-bindgen-test = "0.3" web-time = "0.2" [dev-dependencies] -winit = { version = "0.28.6", default-features = false, features = ["x11", "wayland"] } +winit = { version = "0.29.2", default-features = false, features = ["x11", "wayland"] } [[test]] name = "winit_test" @@ -35,3 +36,4 @@ harness = false name = "winit_test_android" # https://github.com/rust-mobile/cargo-apk/pull/28 crate-type = ["cdylib"] + diff --git a/src/lib.rs b/src/lib.rs index 0bc6358..564efae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,8 +57,8 @@ pub mod __private { #[cfg(target_arch = "wasm32")] pub use wasm_bindgen_test; + use winit::event_loop::EventLoopBuilder; pub use winit::event_loop::EventLoopWindowTarget; - use winit::event_loop::{ControlFlow, EventLoopBuilder}; use owo_colors::OwoColorize; use std::any::Any; @@ -108,7 +108,7 @@ pub mod __private { builder.with_android_app(_ctx); } - let event_loop = builder.build(); + let event_loop = builder.build().expect("Failed to build event loop"); println!("\nRunning {} tests...", tests.len()); let mut state = State { @@ -121,12 +121,14 @@ pub mod __private { // Run the tests. #[cfg(not(target_arch = "wasm32"))] - event_loop.run(move |_, elwt, control_flow| { - run_internal(tests, &mut state, elwt, control_flow); - }); + event_loop + .run(move |_, elwt| { + run_internal(tests, &mut state, elwt); + }) + .expect("Event loop failed to run"); #[cfg(target_arch = "wasm32")] - event_loop.spawn(move |_, elwt, control_flow| { - run_internal(tests, &mut state, elwt, control_flow); + event_loop.spawn(move |_, elwt| { + run_internal(tests, &mut state, elwt); }); } @@ -135,10 +137,9 @@ pub mod __private { tests: &'static [WinitBasedTest], state: &mut State, elwt: &EventLoopWindowTarget, - control_flow: &mut ControlFlow, ) { if state.run { - control_flow.set_exit_with_code(state.code); + elwt.exit(); return; } state.run = true; @@ -191,7 +192,7 @@ pub mod __private { ); state.code = if failures == 0 { 0 } else { 1 }; - control_flow.set_exit_with_code(state.code); + elwt.exit(); } pub struct WinitBasedTest {