-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
nixos/test-driver: run callbacks during Machine.wait_for_console_text #155730
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
base: master
Are you sure you want to change the base?
Changes from all commits
f10ec3c
a750000
39e3d48
b8895eb
de64360
738f4ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -805,21 +805,22 @@ def screen_matches(last: bool) -> bool: | |
| with self.nested("waiting for {} to appear on screen".format(regex)): | ||
| retry(screen_matches) | ||
|
|
||
| def wait_for_console_text(self, regex: str) -> None: | ||
| def wait_for_console_text(self, regex: str) -> re.Match[str]: | ||
| with self.nested("waiting for {} to appear on console".format(regex)): | ||
| # Buffer the console output, this is needed | ||
| # to match multiline regexes. | ||
| console = io.StringIO() | ||
| while True: | ||
| try: | ||
| console.write(self.last_lines.get()) | ||
| console.write(self.last_lines.get(timeout=1)) | ||
|
||
| except queue.Empty: | ||
| self.run_callbacks() | ||
| self.sleep(1) | ||
| continue | ||
| console.seek(0) | ||
| matches = re.search(regex, console.read()) | ||
| if matches is not None: | ||
| return | ||
| return matches | ||
|
|
||
| def send_key(self, key: str) -> None: | ||
| key = CHAR_TO_KEY.get(key, key) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like this isn't used anywhere, or ist it just too early in the morning for me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it was too late at night last night I guess. I packaged all prerequisites for the I wrote for #155622 into one pr, should've mentioned that. I also wrote a similar local function in #154168, and it seems like it would be more generally useful so I thought it would be best to just provide it within the test driver