This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Move TestDarwinNSLogOutput to PExpectTest and allow checking for missing substrs in PExpectTest
Needs RevisionPublic

Authored by teemperor on Aug 19 2020, 4:07 AM.

Details

Summary

TestDarwinNSLogOutput reimplements all the utility functions of the PexpectTestCase. The
test is also randomly failing for me when it tries to tear down the process after LLDB was already
closed.

This patch removes all the custom logic in this test and just uses the PExpectTest equivalents.
The only missing functionality that PExpectTest didn't have was checking for missing substrs
in command output (to test that one can disable the NSLog output), so I extended PExpectTest
for that.

Diff Detail

Event Timeline

teemperor requested review of this revision.Aug 19 2020, 4:07 AM
teemperor created this revision.
labath added inline comments.Aug 19 2020, 4:37 AM
lldb/packages/Python/lldbsuite/test/lldbpexpect.py
66–82

I think a better approach would be to just eat the entire output until the next prompt, and them pattern match the output normally. We could even delegate to the "real" expect method to do that part. Something like this (untested) snippet should do it:

self.child.expect('(.*)'+ self.PROMPT)
super(PExpectTest, self).expect(self.child.match.group(1), substrs=substrs, matching=matching)

Another advantage of this would be that we would avoid waiting for the timeout in case the command does not produce the expected output (but it still terminates correctly, so we can match the next prompt).

labath requested changes to this revision.Nov 26 2021, 3:09 AM

I still like the idea from the inline comment, but mainly clicking request changes to get this off my queue.

This revision now requires changes to proceed.Nov 26 2021, 3:09 AM