Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"command": "uv run python -m tests.e2e.bench_suite --pairs 5 --out /tmp/bench-1503 -k watch",
"ran_at": 1791769095,
"exit_code": 0,
"commit": "409ebb5a7e1da55d1516983fcd936cae7fdc952c",
"branch": "bot/1503-bench-watch-1011"
}
12 changes: 8 additions & 4 deletions packages/python/tests/e2e/watch_speed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import pytest

from .speed_of_light import (
Natives,
Startup,
assert_speed_of_light,
cli,
Expand Down Expand Up @@ -147,6 +148,11 @@ def close(self):
self.proc.wait(timeout=60)


def measure(native, dirsql):
natives = Natives({"inotifywait": native.sample}, [])
return paired(natives, lambda _timeout: dirsql.sample(), NO_STARTUP, PAIRS)


def describe_watch_speed_of_light():
@pytest.fixture(scope="module")
def trees(tmp_path_factory):
Expand All @@ -165,9 +171,7 @@ def trees(tmp_path_factory):

def it_delivers_a_write_to_the_consumer_within_the_bar(trees):
native, dirsql = trees
result = paired(
native.sample, lambda _timeout: dirsql.sample(), NO_STARTUP, PAIRS
)
assert result.native_rows == next(native.writer.samples) - 1
result = measure(native, dirsql)
assert result.native_rows == {"inotifywait": next(native.writer.samples) - 1}
assert result.dirsql_rows == next(dirsql.writer.samples) - 1
assert_speed_of_light("watch", result, NO_STARTUP)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Hermetic test that the watch case hands the harness a well-formed native."""

import os
from itertools import count
from unittest.mock import patch

import pytest

from tests.e2e.watch_speed_test import measure


class Side:
def __init__(self, seconds):
self.seconds = seconds
self.samples = count(1)
self.last = 0

def sample(self):
self.last = next(self.samples)
return self.last, self.seconds


@pytest.fixture(params=[False, True], ids=["ratchet", "suite"])
def mode(request):
env = {"DIRSQL_BENCH_PAIRS": "", "DIRSQL_BENCH_OUT": ""}
if request.param:
env = {"DIRSQL_BENCH_PAIRS": "3", "DIRSQL_BENCH_OUT": "/tmp/unused"}
with patch.dict(os.environ, env):
yield


def describe_measure():
def it_pairs_the_watcher_with_dirsql(mode):
native, dirsql = Side(1.0), Side(1.0)
result = measure(native, dirsql)
assert list(result.native_seconds) == ["inotifywait"]
assert result.native_rows == {"inotifywait": native.last}
assert result.dirsql_rows == dirsql.last
assert result.bar == "inotifywait"
Loading