Skip to content

Commit

Permalink
breaking: Bump to winit v0.29.2
Browse files Browse the repository at this point in the history
This is a breaking change.

Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull authored Oct 26, 2023
1 parent 87d3674 commit 7cf29f2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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, }
Expand All @@ -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
Expand All @@ -57,14 +63,18 @@ 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

- name: Install GCC Multilib
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
Expand All @@ -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
Expand Down Expand Up @@ -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') &&
Expand All @@ -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') &&
Expand Down
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
name = "winit-test"
version = "0.1.2"
edition = "2021"
authors = ["John Nunley <[email protected]>"]
authors = ["John Nunley <[email protected]>"]
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"]
Expand All @@ -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"
Expand All @@ -35,3 +36,4 @@ harness = false
name = "winit_test_android"
# https://github.com/rust-mobile/cargo-apk/pull/28
crate-type = ["cdylib"]

21 changes: 11 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
});
}

Expand All @@ -135,10 +137,9 @@ pub mod __private {
tests: &'static [WinitBasedTest<T>],
state: &mut State,
elwt: &EventLoopWindowTarget<T>,
control_flow: &mut ControlFlow,
) {
if state.run {
control_flow.set_exit_with_code(state.code);
elwt.exit();
return;
}
state.run = true;
Expand Down Expand Up @@ -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<T: 'static> {
Expand Down

0 comments on commit 7cf29f2

Please sign in to comment.