diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 805967e..0c70f52 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -2,10 +2,10 @@ name: Coverage on: workflow_dispatch: - push: - branches: [main, release-*] - pull_request: - branches: [main, release-*] + # push: + # branches: [main, release-*] + # pull_request: + # branches: [main, release-*] env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 4416a18..00cbdfa 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -22,10 +22,10 @@ jobs: include: - os: ubuntu-latest headless: Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - - os: macos-latest - extra: -- --skip test_afrim + # - os: macos-latest + # extra: -- --skip test_afrim - os: windows-latest - extra: -- --skip test_afrim + # extra: -- --skip test_afrim steps: - uses: actions/checkout@v4 @@ -71,14 +71,18 @@ jobs: cargo test --no-run -p afrim-preprocessor --all-features --verbose cargo test --no-run -p afrim --all-features --verbose + - uses: OrbitalOwen/desktop-screenshot-action@0.1 + with: + file-name: 'desktop1.jpg' + - name: Run tests (minimal) run: | - cargo test -p afrim-memory --verbose - cargo test -p afrim-preprocessor --no-default-features --verbose - cargo test -p afrim-translator --no-default-features --verbose - cargo test -p afrim-config --no-default-features --verbose cargo test -p afrim --no-default-features --verbose ${{matrix.extra}} + - uses: OrbitalOwen/desktop-screenshot-action@0.1 + with: + file-name: 'desktop2.jpg' + - name: Run tests (normal) run: | cargo test -p afrim-preprocessor --verbose diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index ab371ef..50ff179 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -2,10 +2,10 @@ name: Web on: workflow_dispatch: - push: - branches: [main, release-*] - pull_request: - branches: [main, release-*] + # push: + # branches: [main, release-*] + # pull_request: + # branches: [main, release-*] env: CARGO_TERM_COLOR: always diff --git a/service/src/lib.rs b/service/src/lib.rs index 2472cee..5de2a20 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -205,8 +205,8 @@ pub fn run( mod tests { use crate::{frontend::Console, run, Config}; use afrish::{self, TkPackLayout}; - use rdev::{self, Button, EventType::*, Key::*}; - use std::sync::mpsc::{self, Sender}; + use rdev::{self, EventType::*, Key::*}; + use std::sync::mpsc::{self}; use std::{thread, time::Duration}; macro_rules! input { @@ -255,11 +255,7 @@ mod tests { input_field } - fn end_sandbox() { - afrish::end_wish(); - } - - fn start_simulation(signal: Sender<()>) { + fn start_simulation() { let typing_speed_ms = Duration::from_millis(500); // To detect excessive backspace @@ -268,15 +264,10 @@ mod tests { // Start the sandbox let textfield = start_sandbox(LIMIT); - // Send the ready signal. - signal.send(()).unwrap(); - - rdev::simulate(&MouseMove { x: 100.0, y: 100.0 }).unwrap(); - thread::sleep(typing_speed_ms); - rdev::simulate(&ButtonPress(Button::Left)).unwrap(); - thread::sleep(typing_speed_ms); - rdev::simulate(&ButtonRelease(Button::Left)).unwrap(); - thread::sleep(typing_speed_ms); + rdev::simulate(&KeyPress(Alt)).unwrap(); + rdev::simulate(&KeyPress(Tab)).unwrap(); + rdev::simulate(&KeyRelease(Alt)).unwrap(); + rdev::simulate(&KeyRelease(Tab)).unwrap(); input!(KeyU, typing_speed_ms); #[cfg(not(feature = "inhibit"))] @@ -378,8 +369,6 @@ mod tests { rdev::simulate(&KeyPress(ShiftLeft)).unwrap(); input!(Minus, typing_speed_ms); rdev::simulate(&KeyRelease(ShiftLeft)).unwrap(); - - end_sandbox(); } #[test] @@ -388,16 +377,20 @@ mod tests { let (tx, rx) = mpsc::channel(); - // TODO: handle simulation errors. - let simulation_thread = thread::spawn(move || start_simulation(tx)); + let afrim_thread = thread::spawn(move || { + let test_config = Config::from_file(Path::new("./data/test.toml")).unwrap(); + // Send the ready signal. + tx.send(()).unwrap(); + + assert!(run(test_config, Console::default()).is_ok()); + }); // Wait the ready signal. rx.recv().unwrap(); - let test_config = Config::from_file(Path::new("./data/test.toml")).unwrap(); - assert!(run(test_config, Console::default()).is_ok()); + start_simulation(); - // Wait the simulation to end properly. - simulation_thread.join().unwrap(); + // Wait the afrim to end properly. + afrim_thread.join().unwrap(); } }