Skip to content

Rust tests sleep instead of waiting for a state or injecting the clock #437

Closed

Description

@yansfil

Problem

The clippy disallowed-methods entry for std::thread::sleep found 59 test functions whose sleep stands in for a state the test could wait for (an event, a file, a process exit) or for time the test could inject.
Each carries #[allow(clippy::disallowed_methods)] // #437 the sleep stands in for a state the test can wait for so new sleeps fail the Rust lint lane while these are fixed.
Sleeps that are the subject of a test (a slow fake peer), a child process kept alive for the test to kill, bounded polling helpers and production waits are allowed with their own reason and are not in this list.

#434 fixed some of the original list (herdr-core/src/live.rs, herdr-core/src/usage.rs, hide-ai/src/router.rs) and their allows were removed when this branch took main.

Test functions by file

File Functions
hide-platform/tests/ipc.rs 8
herdr-core/src/worktree_behavior_tests.rs 5
herdr-core/src/reader.rs 3
herdr-core/src/runtime/tests/device_catalog.rs 3
herdr-core/src/runtime/tests/view_areas.rs 3
herdr-core/src/live.rs 2
herdr-core/src/remote/host.rs 2
herdr-core/src/runtime/tests/documents.rs 2
herdr-core/src/runtime/tests/project_sessions.rs 2
herdr-core/src/runtime/tests/terminal.rs 2
hide-ai/src/router.rs 2
hide-ai/tests/claude_cli.rs 2
hide-host/tests/worktrees.rs 2
hide-kit/src/process.rs 2
hide-platform/tests/fs.rs 2
hided/tests/real_herdr.rs 2
herdr-core/src/ai.rs 1
herdr-core/src/changes.rs 1
herdr-core/src/runtime/session_search.rs 1
herdr-core/src/runtime/tests/home.rs 1
hide-ai/tests/codex_app_server.rs 1
hide-ai/tests/process_ownership.rs 1
hide-herdr-client/tests/real_herdr.rs 1
hide-host/tests/save.rs 1
hide-host/tests/session_activity.rs 1
hide-kit/src/tests.rs 1
hide-platform/tests/process.rs 1
hide-platform/tests/watch.rs 1
hided/src/watch.rs 1
hided/tests/connect_build.rs 1
hided/tests/connect_stop.rs 1

Done when

Each function waits for its state (channel, file, process exit, or an injected clock) and the allow comment is gone, so no #437 allow remains in the tree.
See docs/TESTING.md, "Writing a Rust test".

Not covered by the ban: park_timeout, Condvar::wait_timeout used as a delay, Command::new("sleep") and time.sleep in a Python child (hide-ai/tests/process_ownership.rs).

Activity

  1. added
    rust
    on Oct 5, 2026
  2. yansfil commented on Oct 5, 2026

    @yansfil
    ContributorAuthor

    main 1ca784a 기준 #437 allow 0개입니다. 각 sleep은 상태 대기(채널, 파일, 프로세스 종료)나 주입한 시계로 바뀌었고, 테스트 대상 자체인 sleep은 고유 이유의 allow로 재분류했습니다. 머지된 PR: #503 #504 #509 #512 #520 #525 #527 #528 #544. 부하에서 드러난 hide connect 기한 문제도 #544로 고쳤습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    rust

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions