Skip to content

Commit

Permalink
Fix Keysym names for named Keysyms and test them agains xkbcommon
Browse files Browse the repository at this point in the history
  • Loading branch information
pentamassiv committed Nov 1, 2023
1 parent e94ff66 commit 94d6112
Show file tree
Hide file tree
Showing 6 changed files with 2,667 additions and 2,556 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies
run: sudo apt-get install -y libxkbcommon-dev
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# SPDX-License-Identifier: MIT OR Apache-2.0 OR Zlib
# Copyright 2022-2023 John Nunley
#
# Licensed under the Apache License, Version 2.0, the MIT License, and
# the Zlib license ("the Licenses"), you may not use this file except in
# compliance with one of the the Licenses, at your option. You may obtain
# a copy of the Licenses at
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://opensource.org/licenses/MIT
# http://opensource.org/licenses/Zlib
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Licenses is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the Licenses for the specific language governing permissions and
# limitations under the Licenses.

name: Test

permissions:
contents: read
on:
push:
branches:
- master
pull_request:
workflow_dispatch:

env:
RUSTFLAGS: -Dwarnings
CARGO_TERM_COLOR: always

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust:
- stable
- beta
- nightly
- 1.58.1

steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update -q -y
sudo apt-get upgrade -y
sudo apt-get install -y libxkbcommon-dev
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Run the tests
run: cargo test -- --include-ignored

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ rust-version = "1.58.1"
[dev-dependencies]
bytemuck = "1.12.3"
x11rb = "0.12.0"
xkbcommon = "0.7.0" # Used for testing
rayon = "1.8.0" # Used for testing

[workspace]
members = [
Expand Down
5 changes: 3 additions & 2 deletions keysym-generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub mod key {{
#[allow(unreachable_patterns)]
pub(crate) const fn name(keysym: Keysym) -> Option<&'static str> {
match keysym {
Keysym::NoSymbol => Some(\"XK_NoSymbol\"),\n"
Keysym::NoSymbol => Some(\"NoSymbol\"),\n"
.to_string();

// we're looking for lines of the following form:
Expand Down Expand Up @@ -210,7 +210,8 @@ pub(crate) const fn name(keysym: Keysym) -> Option<&'static str> {
writeln!(
keysym_dump,
" Keysym::{} => Some(\"{}\"),",
&keysym_name, &name
&keysym_name,
&name.replace("XK_", "")
)
.unwrap();
}
Expand Down
Loading

0 comments on commit 94d6112

Please sign in to comment.