From 030e580a4907c8d867e3fc1d6f3a3587d9006865 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 28 Oct 2026 20:56:27 -0700 Subject: [PATCH] build(repo): sync the neutral core to kfw while it is on its way there scripts/sync-e2e-core copies komorebi_vm.core and the unit tests that belong to it into another directory, and --check says whether the copy is in step, so that kfw's Windows platform can be written against the code it will run with while the move is not made. This repository is the source until the move, and the script goes with it. Two of those tests imported Rect and Checks from komorebi_vm, which pulls in the KDE half; they import them from komorebi_vm.core now. The copy passes its 25 tests in a directory with nothing but pytest and Pillow. --- nix/tests/vm/lib/tests/test_checks.py | 2 +- nix/tests/vm/lib/tests/test_pixels.py | 2 +- scripts/sync-e2e-core | 51 +++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100755 scripts/sync-e2e-core diff --git a/nix/tests/vm/lib/tests/test_checks.py b/nix/tests/vm/lib/tests/test_checks.py index a763366e..dede6580 100644 --- a/nix/tests/vm/lib/tests/test_checks.py +++ b/nix/tests/vm/lib/tests/test_checks.py @@ -1,6 +1,6 @@ import pytest -from komorebi_vm import Checks +from komorebi_vm.core.checks import Checks def test_counts_passes_and_failures(capsys: pytest.CaptureFixture[str]) -> None: diff --git a/nix/tests/vm/lib/tests/test_pixels.py b/nix/tests/vm/lib/tests/test_pixels.py index cdc396f4..609bce09 100644 --- a/nix/tests/vm/lib/tests/test_pixels.py +++ b/nix/tests/vm/lib/tests/test_pixels.py @@ -1,6 +1,6 @@ from PIL import Image, ImageDraw -from komorebi_vm import Rect +from komorebi_vm.core.geometry import Rect from komorebi_vm.core.pixels import leftmost, near, pixel, ring BLUE = (66, 165, 245) diff --git a/scripts/sync-e2e-core b/scripts/sync-e2e-core new file mode 100755 index 00000000..67b353e3 --- /dev/null +++ b/scripts/sync-e2e-core @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# Keeps a copy of the platform-neutral part of the VM library in step with this repository, while +# that part is on its way to kfw (the plan in docs/dev/vm-tests.md, "Writing a scenario"): the +# package komorebi_vm.core, and the unit tests that belong to it. The source is this repository until +# the move is made, and the script goes with it. +# +# scripts/sync-e2e-core DEST copy into DEST/komorebi_vm/core and DEST/tests +# scripts/sync-e2e-core --check DEST say what differs, and exit 1 if anything does +# +# Nothing else of DEST is touched, and a file of DEST that is not here is reported and left alone. +set -euo pipefail + +check=0 +if [ "${1:-}" = --check ]; then + check=1 + shift +fi +dest=${1:?usage: sync-e2e-core [--check] DEST} +repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) +lib=$repo/nix/tests/vm/lib + +tests=(fake_platform.py test_checks.py test_pixels.py test_snapshot.py test_tiling.py test_focus_moving.py) + +status=0 +sync() { + local from=$1 to=$2 + if [ "$check" = 1 ]; then + diff -r -x __pycache__ "$from" "$to" >/dev/null 2>&1 || { echo "differs: $to"; status=1; } + else + mkdir -p "$to" + rsync -a --delete --exclude __pycache__ "$from"/ "$to"/ + fi +} + +sync "$lib/komorebi_vm/core" "$dest/komorebi_vm/core" + +for t in "${tests[@]}"; do + if [ "$check" = 1 ]; then + cmp -s "$lib/tests/$t" "$dest/tests/$t" || { echo "differs: $dest/tests/$t"; status=1; } + else + mkdir -p "$dest/tests" + cp "$lib/tests/$t" "$dest/tests/$t" + fi +done + +if [ "$check" = 0 ]; then + echo "synced komorebi_vm/core and ${#tests[@]} tests into $dest" +else + [ "$status" = 0 ] && echo "in step" +fi +exit "$status"