Skip to content

Commit 1ccebac

Browse files
committed
fix(contest): expect "rendered_cmd" but not "cmd" in assert_complete()
When extracting the completion candidates from the Bash output, we expect "rendered_cmd" rather than "cmd". Note that "rendered_cmd" (i.e., the text representation of the command line by Bash) can be different from "cmd" (i.e., the command input by the user) when "cmd" contains TABs or control characters.
1 parent bde5676 commit 1ccebac

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/t/conftest.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -755,12 +755,16 @@ def assert_complete(
755755
bash.send(cmd + "\t")
756756
# Sleep a bit if requested, to avoid `.*` matching too early
757757
time.sleep(kwargs.get("sleep_after_tab", 0))
758-
bash.expect_exact(kwargs.get("rendered_cmd", cmd))
758+
rendered_cmd = kwargs.get("rendered_cmd", cmd)
759+
bash.expect_exact(rendered_cmd)
759760
bash.send(MAGIC_MARK)
760761
got = bash.expect(
761762
[
762763
# 0: multiple lines, result in .before
763-
r"\r\n" + re.escape(PS1 + cmd) + ".*" + re.escape(MAGIC_MARK),
764+
r"\r\n"
765+
+ re.escape(PS1 + rendered_cmd)
766+
+ ".*"
767+
+ re.escape(MAGIC_MARK),
764768
# 1: no completion
765769
r"^" + re.escape(MAGIC_MARK),
766770
# 2: on same line, result in .match

0 commit comments

Comments
 (0)