Skip to content

Commit f688bf1

Browse files
committed
test(repl): make debugger console tests Windows-portable
The debugger console tests failed on every Windows CI job: - The shared source path was hardcoded as `/tmp/dbg_console_suite.robot`, which resolves to a non-writable `\tmp\…` on Windows, so the tests that write that file raised FileNotFoundError. Use the OS temp dir instead. - The resource-keyword test embedded a Windows `tmp_path` (backslashes) into `.robot` source, where Robot's escape handling mangled it and the import failed. Write the path with forward slashes via `as_posix()`.
1 parent 8e62733 commit f688bf1

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tests/robotcode/repl/test_debug_console.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
import io
11+
import tempfile
1112
from pathlib import Path
1213
from typing import IO, Any, AnyStr, Callable, List, Optional, Tuple, Union, cast
1314

@@ -22,7 +23,8 @@
2223
from robotcode.repl.console_interpreter import ConsoleInterpreter
2324
from robotcode.robot.utils import RF_VERSION
2425

25-
_SOURCE = "/tmp/dbg_console_suite.robot"
26+
# A writable temp path (not a hardcoded "/tmp/…", which is not writable on Windows).
27+
_SOURCE = str(Path(tempfile.gettempdir()) / "dbg_console_suite.robot")
2628

2729
# 11 = `Log before`, 12 = `Outer`
2830
STEP_SUITE = """\
@@ -464,7 +466,7 @@ def test_break_with_path_line_format_triggers() -> None:
464466
assert len(stops) == 2
465467
assert stops[0].startswith("* entry")
466468
# The location is shown relative to the cwd (a `…/`-prefixed path here, since
467-
# the test source lives under /tmp); assert the filename:line suffix, which
469+
# the test source lives in a temp dir); assert the filename:line suffix, which
468470
# is stable regardless of where the tests run from.
469471
assert "dbg_console_suite.robot:12)" in stops[1] # the line breakpoint fired
470472

@@ -939,7 +941,9 @@ def test_source_suite_local_keyword_not_resolved() -> None:
939941
def test_source_resource_keyword(tmp_path: Path) -> None:
940942
res = tmp_path / "kw.resource"
941943
res.write_text("*** Keywords ***\nCustom Step\n Log hi\n", encoding="utf-8")
942-
suite_text = f"*** Settings ***\nResource {res}\n\n*** Test Cases ***\nT\n Custom Step\n"
944+
# Forward slashes: a raw Windows path (backslashes) in .robot source would be
945+
# mangled by Robot's escape handling, so the resource import would fail.
946+
suite_text = f"*** Settings ***\nResource {res.as_posix()}\n\n*** Test Cases ***\nT\n Custom Step\n"
943947
messages = _run_debug(suite_text, [".source Custom Step", ".continue"], stop_on_entry=True)
944948
assert any(m.startswith("Custom Step (") and "kw.resource:" in m for m in messages)
945949
assert any(m.lstrip().startswith("->") for m in messages)

0 commit comments

Comments
 (0)