diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b375b03d..486d98fa6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -248,3 +248,12 @@ jobs: use-cross: ${{ matrix.job.use-cross }} command: test args: --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}} + + # drm and unix-file-copy-paste are off by default, so the run above compiles none of their tests. + - name: Run drm and unix-file-copy-paste tests + if: matrix.job.target == 'x86_64-unknown-linux-gnu' + shell: bash + run: | + cargo test --locked --target=${{ matrix.job.target }} --lib --features drm,drm-wake + cargo test --locked --target=${{ matrix.job.target }} -p scrap --features drm + cargo test --locked --target=${{ matrix.job.target }} -p clipboard --features unix-file-copy-paste diff --git a/.github/workflows/flutter-build.yml b/.github/workflows/flutter-build.yml index 4c1237317..4e517d5c5 100644 --- a/.github/workflows/flutter-build.yml +++ b/.github/workflows/flutter-build.yml @@ -2145,59 +2145,6 @@ jobs: export JOBS="" fi echo $JOBS - if [[ "${{ matrix.job.arch }}" == "x86_64" ]]; then - # The drm-gated unit tests, which `cargo test --workspace` (default features) does not - # reach. Debug rather than --release: these are pure logic tests and the release build - # is already the slow part of this job. - # A MINIMAL feature set, not the production one: these are pure logic tests of the drm - # paths, and pulling hwcodec in makes the test binary fail to link at all (undefined - # reference to fcntl64 in this container), so the tests never run. - # - # Two packages, because `cargo test --lib` at the root builds the ROOT package only: - # the provenance tests live in libs/scrap and would never be selected from here. - # - # awk sums the counts rather than bc, which this container does not install. - # - # A cargo test FILTER that matches nothing exits 0, so a rename would turn this into a - # green no-op. Assert each command actually ran something. - run_drm_tests() { - local desc="$1"; shift - local out - out=$("$@" 2>&1) || { echo "$out"; echo "::error::drm tests failed: $desc"; exit 1; } - local ran - ran=$(echo "$out" | awk '/^running [0-9]+ tests?$/ { n += $2 } END { print n+0 }') - echo "$desc ran $ran tests" - if [ "$ran" -lt 1 ]; then - echo "::error::$desc selected no tests; it was renamed or removed" - exit 1 - fi - } - run_drm_tests "rustdesk drm_capturer_tests" \ - cargo test --locked --lib --features drm drm_capturer_tests - run_drm_tests "rustdesk ipc::test" \ - cargo test --locked --lib --features drm ipc::test - run_drm_tests "rustdesk cursor_pos_tests" \ - cargo test --locked --lib --features drm cursor_pos_tests - run_drm_tests "rustdesk peer_abs_sample_tests" \ - cargo test --locked --lib --features drm peer_abs_sample_tests - run_drm_tests "rustdesk input_map_tests" \ - cargo test --locked --lib --features drm input_map_tests - run_drm_tests "rustdesk drm_pacing_tests" \ - cargo test --locked --lib --features drm drm_pacing_tests - run_drm_tests "scrap hotspot_provenance_tests" \ - cargo test --locked -p scrap --features drm hotspot_provenance_tests - run_drm_tests "scrap hotspot_guess_tests" \ - cargo test --locked -p scrap --features drm hotspot_guess_tests - run_drm_tests "scrap crtc_refresh_tests" \ - cargo test --locked -p scrap --features drm crtc_refresh_tests - run_drm_tests "scrap plane_rotation_tests" \ - cargo test --locked -p scrap --features drm plane_rotation_tests - run_drm_tests "scrap drmtap_dl::tests" \ - cargo test --locked -p scrap --features drm drmtap_dl::tests - # Opt-in like drm, and this build already enables it. - run_drm_tests "clipboard unix-file-copy-paste" \ - cargo test --locked -p clipboard --features unix-file-copy-paste - fi cargo build --locked --lib $JOBS --features hwcodec,flutter,unix-file-copy-paste,drm,drm-wake --release rm -rf target/release/deps target/release/build rm -rf ~/.cargo diff --git a/AGENTS.md b/AGENTS.md index 46a9890c3..cca9fc0f6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -193,8 +193,7 @@ A refactor added to cover a corner case rarely converges. Each new counter, time * If the test diff is more than twice the fix, cut it back to the tests that pin the reported behavior. A state that needs long setup to reach is usually too rare to fix. * When the number of tests needed to describe the behavior keeps growing, the implementation is too complex: simplify it instead of adding tests. * Dart tests go in `flutter/test/*_test.dart`, nowhere else: CI runs `flutter test` over that directory and nothing outside it. It runs on the VM, so a `@TestOn('browser')` suite runs in no CI job. -* Rust unit tests go in a `#[cfg(test)]` module beside the code. CI runs `cargo test --workspace` with the default features on x86_64 Linux, `cargo test --lib` on the root package with the release feature set on macOS and Windows plus `-p clipboard` there, and on Linux x86_64 the `drm` test modules by name plus the `clipboard` package with `unix-file-copy-paste`. On macOS and Windows, a platform-gated test in another workspace crate runs only if that platform's job names the crate with `-p`. Gate a test module on a feature or `target_os` only when the code under test is gated; a pure helper that only a gated path calls gets `#[cfg(any(feature = "...", test))]`, so its tests run everywhere. -* A test behind a feature that no CI build enables needs a `cargo test` line in `.github/workflows/flutter-build.yml` that names it. In the Linux x86_64 build job, wrap a drm test in `run_drm_tests` so a filter that matches nothing fails instead of passing. +* Rust unit tests go in a `#[cfg(test)]` module beside the code. CI runs `cargo test --workspace` with the default features on x86_64 Linux, `cargo test --lib` on the root package with the release feature set on macOS and Windows plus `-p clipboard` there, and on x86_64 Linux also the root package with `drm,drm-wake`, `scrap` with `drm` and `clipboard` with `unix-file-copy-paste`. On macOS and Windows, a platform-gated test in another workspace crate runs only if that platform's job names the crate with `-p`. Gate a test module on a feature or `target_os` only when the code under test is gated; a pure helper that only a gated path calls gets `#[cfg(any(feature = "...", test))]`, so its tests run everywhere. * Web core tests are `flutter/web/js/src/*.test.ts`, run by jest in that repository's own CI. ## Reviewing a PR