Skip to content

Commit

Permalink
Fix test failures caused by the fzf version (#49)
Browse files Browse the repository at this point in the history
* Remove deprecated `version` in docker-compose.yml

* Refactor the magic number for `time.sleep`

* Update the tests for supporting latest fzf
  • Loading branch information
lebr0nli authored Nov 6, 2024
1 parent 85f5ca5 commit 29157cc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

services:
base: &base-spec
build: .
Expand Down
9 changes: 5 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
SESSION_STARTUP_TIMEOUT = 15
STARTUP_BANNER = b"GEP is running now!"
GDB_HISTORY_NAME = ".gdb_history"
TIME_INTERVAL = 1


def run_with_screen_256color(
Expand Down Expand Up @@ -79,7 +80,7 @@ def start(self, gdb_args: list[str] | None = None, histories: list[str] = None)
while time.time() - now < SESSION_STARTUP_TIMEOUT:
if STARTUP_BANNER in self.capture_pane():
break
time.sleep(1)
time.sleep(TIME_INTERVAL)
else:
raise TimeoutError("GDB session did not start in time")
self.clear_pane()
Expand Down Expand Up @@ -122,7 +123,7 @@ def send_literal(self, literal: str) -> None:
:return: None
"""
run_with_screen_256color(["tmux", "send-keys", "-l", "-t", self.session_name, literal])
time.sleep(1)
time.sleep(TIME_INTERVAL)

@check_session_started
def send_key(self, key: str) -> None:
Expand All @@ -133,7 +134,7 @@ def send_key(self, key: str) -> None:
:return: None
"""
run_with_screen_256color(["tmux", "send-keys", "-t", self.session_name, key])
time.sleep(1)
time.sleep(TIME_INTERVAL)

@check_session_started
def clear_pane(self) -> None:
Expand All @@ -144,7 +145,7 @@ def clear_pane(self) -> None:
:rtype: None
"""
run_with_screen_256color(["tmux", "send-keys", "-t", self.session_name, "C-l"])
time.sleep(1)
time.sleep(TIME_INTERVAL)
run_with_screen_256color(["tmux", "clear-history", "-t", self.session_name])

@check_session_started
Expand Down
5 changes: 4 additions & 1 deletion tests/test_gep.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from conftest import GDBSession

# TODO: Maybe a better way to handle this?
FZF_POINTER = b"\xe2\x96\x8c" # ▌


def grey(b: bytes) -> bytes:
"""
Expand Down Expand Up @@ -57,7 +60,7 @@ def test_fzf_history_search(gdb_session: GDBSession) -> None:
pane_content = gdb_session.capture_pane()
assert b"> 11" in pane_content
assert b"1/3" in pane_content
assert b"> print 11" in pane_content
assert FZF_POINTER + b" print 11" in pane_content

# the selected history should be replaced in buffer
gdb_session.send_key("Enter")
Expand Down

0 comments on commit 29157cc

Please sign in to comment.