Skip to content

[lldb] Add a test for terminal dimensions #126598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

JDevlieghere
Copy link
Member

@JDevlieghere JDevlieghere commented Feb 10, 2025

Add a test for the term-width and term-height settings. I thought I was hitting bug because in my statusline test I was getting the default values when running under PExpect. It turned out hat the issue is that we clear the settings at the start of the test. The Editline tests aren't affected by this because Editline provides its own functions to get the terminal dimensions and explicitly does not rely on LLDB's settings (presumably exactly because of this behavior).

Add a test for the term-width and term-height settings.
@llvmbot
Copy link
Member

llvmbot commented Feb 10, 2025

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

Add a test for the term-width and term-height settings.


Full diff: https://github.com/llvm/llvm-project/pull/126598.diff

1 Files Affected:

  • (added) lldb/test/API/driver/terminal/TestTerminalDimensions.py (+22)
diff --git a/lldb/test/API/driver/terminal/TestTerminalDimensions.py b/lldb/test/API/driver/terminal/TestTerminalDimensions.py
new file mode 100644
index 000000000000000..264cfa5950bfd33
--- /dev/null
+++ b/lldb/test/API/driver/terminal/TestTerminalDimensions.py
@@ -0,0 +1,22 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+
+class TerminalDimensionsTest(PExpectTest):
+    NO_DEBUG_INFO_TESTCASE = True
+
+    @skipIfAsan
+    def test(self):
+        """Test that the lldb driver correctly reports the (PExpect) terminal dimension."""
+        self.launch(dimensions=(40, 40), timeout=1)
+
+        # Tests clear all the settings so we lose the launch values. Resize the
+        # window to update the settings. These new values need to be different
+        # to trigger a SIGWINCH.
+        self.child.setwinsize(20, 60)
+
+        self.expect("settings show term-height", ["term-height (unsigned) = 20"])
+        self.expect("settings show term-width", ["term-width (unsigned) = 60"])

@skipIfAsan
def test(self):
"""Test that the lldb driver correctly reports the (PExpect) terminal dimension."""
self.launch(dimensions=(40, 40), timeout=1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the dimensions matter if they'll get cleared and then reset later in the test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They matter in the sense that they need to be different (noted in the comment below). I. need to remove the , timeout=1 because that was just for local debugging.

@JDevlieghere JDevlieghere merged commit d81b604 into llvm:main Feb 10, 2025
5 of 6 checks passed
@JDevlieghere JDevlieghere deleted the TerminalDimensionsTest branch February 10, 2025 22:46
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
Add a test for the `term-width` and `term-height` settings. I thought I
was hitting bug because in my statusline test I was getting the default
values when running under PExpect. It turned out hat the issue is that
we clear the settings at the start of the test. The Editline tests
aren't affected by this because Editline provides its own functions to
get the terminal dimensions and explicitly does not rely on LLDB's
settings (presumably exactly because of this behavior).
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
Add a test for the `term-width` and `term-height` settings. I thought I
was hitting bug because in my statusline test I was getting the default
values when running under PExpect. It turned out hat the issue is that
we clear the settings at the start of the test. The Editline tests
aren't affected by this because Editline provides its own functions to
get the terminal dimensions and explicitly does not rely on LLDB's
settings (presumably exactly because of this behavior).
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
Add a test for the `term-width` and `term-height` settings. I thought I
was hitting bug because in my statusline test I was getting the default
values when running under PExpect. It turned out hat the issue is that
we clear the settings at the start of the test. The Editline tests
aren't affected by this because Editline provides its own functions to
get the terminal dimensions and explicitly does not rely on LLDB's
settings (presumably exactly because of this behavior).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants