Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 33 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
name: Rust Unit Tests
name: Tests

on:
workflow_dispatch:
push:
branches:
- '**'

branches: ['**']
pull_request:
branches:
- '**'
branches: ['**']

jobs:
test:
runs-on: ubuntu-latest
native:
name: Tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Test platform adapters on their native OS; an all-features build
# cannot exercise both the Linux and Windows integrations.
include:
- os: ubuntu-latest
features: mpris,scrape,extra-audio-formats
- os: windows-latest
features: media-controls,scrape,extra-audio-formats
- os: macos-latest
features: scrape,extra-audio-formats
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Install dependencies
run: sudo apt install libasound2-dev

- name: Setup rust
- uses: actions/checkout@v5
- name: Install ALSA development headers
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libasound2-dev
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Run tests
run: cargo test --all --verbose
- name: Check formatting
run: cargo fmt --check
- name: Run standard tests
run: cargo test --locked
- name: Run tests without default features
run: cargo test --locked --no-default-features
- name: Run native feature tests
run: cargo test --locked --features ${{ matrix.features }}
- name: Check native features without default features
run: cargo check --locked --all-targets --no-default-features --features ${{ matrix.features }}
4 changes: 2 additions & 2 deletions src/scrapers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ async fn get(client: &Client, path: &str, source: Source) -> eyre::Result<String
file.write_all(text.as_bytes()).await?;

if status.is_redirection() {
bail!("redirect: {path}")
bail!("redirect: {path}");
}

if status == 404 {
bail!("not found: {path}")
bail!("not found: {path}");
}

Ok(text)
Expand Down
13 changes: 9 additions & 4 deletions src/tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ mod window {
let (render, height) = w.render(vec![String::from("abc")]).unwrap();

const MIDDLE: &str = "─────";
assert_eq!(format!("┌{MIDDLE}┐\n{}\n└{MIDDLE}┘", sided("abc")), render);
assert_eq!(height, 3);
assert_eq!(
format!("┌{MIDDLE}┐\n{}\n└{MIDDLE}┘", sided("abc")).trim_end(),
render.trim_end()
);
// Lowfi's renderer adds a final row on Windows to avoid repeatedly
// writing to the terminal's last line; the visible content is identical.
assert_eq!(height, if cfg!(windows) { 4 } else { 3 });
}

#[test]
Expand All @@ -106,9 +111,9 @@ mod window {
sided(" b "),
sided("c "),
),
render
render.trim_end()
);
assert_eq!(height, 5);
assert_eq!(height, if cfg!(windows) { 6 } else { 5 });
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/ui/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ impl crate::Tasks {
media_controls,
})
}
}
}
10 changes: 4 additions & 6 deletions src/ui/media_controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
use std::sync::Arc;
use std::time::Duration;

use souvlaki::{
MediaControlEvent, MediaControls, MediaMetadata, MediaPlayback, PlatformConfig,
};
use souvlaki::{MediaControlEvent, MediaControls, MediaMetadata, MediaPlayback, PlatformConfig};
use tokio::sync::{broadcast, mpsc};

use crate::player::Current;
Expand Down Expand Up @@ -164,8 +162,8 @@ mod windows {
use ::windows::Win32::System::LibraryLoader::GetModuleHandleW;
use ::windows::Win32::UI::WindowsAndMessaging::{
CreateWindowExW, DefWindowProcW, DestroyWindow, DispatchMessageW, PeekMessageW,
RegisterClassExW, TranslateMessage, MSG, PM_REMOVE, WINDOW_EX_STYLE, WINDOW_STYLE,
WM_QUIT, WNDCLASSEXW,
RegisterClassExW, TranslateMessage, MSG, PM_REMOVE, WINDOW_EX_STYLE, WINDOW_STYLE, WM_QUIT,
WNDCLASSEXW,
};

pub struct DummyWindow {
Expand Down Expand Up @@ -242,4 +240,4 @@ mod windows {
}
}
}
}
}