Skip to content
Draft
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
10 changes: 10 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ Tests are written as standalone functions (`test_*`), not grouped into
`class TestFoo:` blocks — use descriptive function names and file
organization instead. This applies to pytest tests, not doctests.

`just test -m syrupy_snapshot` checks the ordinary and terminal goldens
on Python 3.12 or later. Refresh the selected goldens after changing CLI
output with the same marker.

```console
$ just test -m syrupy_snapshot --snapshot-update
```

Append a pytest node ID to refresh one case.

**libvcs fixtures.** The suite leans on libvcs's pytest plugin:
`create_git_remote_repo`, `create_svn_remote_repo`, `create_hg_remote_repo`
(factory fixtures), `git_repo`, `svn_repo`, `hg_repo` (pre-made repository
Expand Down
16 changes: 8 additions & 8 deletions tests/cli/__snapshots__/test_vt_snapshots.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -1134,17 +1134,17 @@
# ---
# name: test_cli_sync_watchdog_timeout_pty_vt_snapshots[timeout_pty_delta]
header: size=96x22 cursor=(3,44,vis=False) alt=False modes=[] -> size=96x22 cursor=(15,0,vis=True) alt=False modes=[]
row 1 cols 0..81: "Cloning into 'hung-analytics-warehouse'... " -> '- Timed out hung-analytics-warehouse after 1.0s → ~/code/hung-analytics-warehouse'
row 1 cols 0..81: "Cloning into 'hung-analytics-warehouse'... " -> '- Timed out hung-analytics-warehouse after 5.0s → ~/code/hung-analytics-warehouse'
row 2 cols 0..29: 'Receiving objects: 12% (6/50)' -> ' '
row 3 cols 0..49: '⠋ Syncing hung-analytics-warehouse ... 0.1s ' -> 'Summary: 2 repos, 1 synced, 1 failed, 1 timed out'
row 5 cols 0..36: ' ' -> 'Timed out: 1 repository exceeded 1s.'
row 5 cols 0..36: ' ' -> 'Timed out: 1 repository exceeded 5s.'
styles: r3[0..1]: fg=cyan, r3[10..34]: fg=cyan -> r1[0..1]: fg=yellow, r1[12..36]: fg=cyan, r1[43..47]: fg=yellow (+18 more)
- size=96x22 cursor=(3,44,vis=False) alt=False modes=[]
+ size=96x22 cursor=(15,0,vis=True) alt=False modes=[]
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│✓ Synced fast-sdk → ~/code/fast-sdk │
- │Cloning into 'hung-analytics-warehouse'... │
+ │- Timed out hung-analytics-warehouse after 1.0s → ~/code/hung-analytics-warehouse │
+ │- Timed out hung-analytics-warehouse after 5.0s → ~/code/hung-analytics-warehouse │
│^^^^^^^ ^^ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ │
- │Receiving objects: 12% (6/50) │
+ │ │
Expand All @@ -1154,10 +1154,10 @@
│^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^^ │
│ │
- │ │
+ │Timed out: 1 repository exceeded 1s. │
+ │Timed out: 1 repository exceeded 5s. │
│^^^^^ ^^^^ ^ ^^^^^^^^^^ ^^^^^^^^ ^^^ │
- │ │
+ │ - hung-analytics-warehouse → ~/code/hung-analytics-warehouse (1.0s elapsed) │
+ │ - hung-analytics-warehouse → ~/code/hung-analytics-warehouse (5.0s elapsed) │
│ ^ ^^^^^^^^^^^^^^^^^^^^^^^^ ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ ^^^^^^^^ │
│ │
- │ │
Expand Down Expand Up @@ -1214,12 +1214,12 @@
size=96x22 cursor=(15,0,vis=True) alt=False modes=[]
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│✓ Synced fast-sdk → ~/code/fast-sdk │
│- Timed out hung-analytics-warehouse after 1.0s → ~/code/hung-analytics-warehouse │
│- Timed out hung-analytics-warehouse after 5.0s → ~/code/hung-analytics-warehouse │
│ │
│Summary: 2 repos, 1 synced, 1 failed, 1 timed out │
│ │
│Timed out: 1 repository exceeded 1s. │
│ - hung-analytics-warehouse → ~/code/hung-analytics-warehouse (1.0s elapsed) │
│Timed out: 1 repository exceeded 5s. │
│ - hung-analytics-warehouse → ~/code/hung-analytics-warehouse (5.0s elapsed) │
│ │
│→ Rerun just the affected repositories with a larger timeout: │
│ vcspull sync --workspace '~/code' --timeout 120 hung-analytics-warehouse │
Expand Down
14 changes: 9 additions & 5 deletions tests/cli/test_vt_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ def test_cli_sync_watchdog_timeout_pty_vt_snapshots(
vt_pty: PtyFactory,
vt_snapshot: SnapshotAssertion,
) -> None:
"""``--timeout 1`` PTY snapshots mid-hang spinner, 32-col rerun recipe, and log."""
"""Snapshot the slow clone timeout, rerun recipe, and log hint."""
from libvt.testing import vt_screen

real_git = shutil.which("git")
Expand All @@ -1485,6 +1485,7 @@ def test_cli_sync_watchdog_timeout_pty_vt_snapshots(
ws_dir.mkdir(parents=True)
bin_dir = tmp_path / "bin"
log_file = fake_home / ".vcspull" / "logs" / "timeout.log"
timeout_seconds = 5

remote_fast, _ = _init_local_bare_remote(tmp_path, "fast-sdk")
remote_hung, _ = _init_local_bare_remote(tmp_path, "hung-analytics-warehouse")
Expand Down Expand Up @@ -1533,7 +1534,7 @@ def test_cli_sync_watchdog_timeout_pty_vt_snapshots(
"--jobs",
"1",
"--timeout",
"1",
str(timeout_seconds),
"--log-file",
str(log_file),
"--file",
Expand All @@ -1543,8 +1544,8 @@ def test_cli_sync_watchdog_timeout_pty_vt_snapshots(
env = _pty_cli_env(fake_home, prepend_bin=bin_dir)
scrubbers = [
(fake_home, "~"),
(r"after \d+\.\ds", "after 1.0s"),
(r"\(\d+\.\ds elapsed\)", "(1.0s elapsed)"),
(r"after \d+\.\ds", f"after {timeout_seconds}.0s"),
(r"\(\d+\.\ds elapsed\)", f"({timeout_seconds}.0s elapsed)"),
*_SYNC_SCRUBBERS,
]

Expand All @@ -1570,7 +1571,10 @@ async def _exercise() -> None:
assert rc == 0
assert done_snap.cursor.visible is True
assert pty.terminal.synchronized is False
assert "Timed out: 1 repository exceeded 1s." in done_snap.text
assert (
f"Timed out: 1 repository exceeded {timeout_seconds}s."
in done_snap.text
)
assert "Rerun just the affected repositories" in done_snap.text
assert "Probe each repository manually" in done_snap.text
assert vt_screen(done_snap, scrubbers=scrubbers) == vt_snapshot(
Expand Down
Loading