mirror of
https://github.com/intel/llvm.git
synced 2026-02-06 06:31:50 +08:00
Fix flakyness in TestCommandScriptImmediateOutput
I'm not sure why this surfaced at this particular point, but TestCommandScriptImmediateOutput (a pexpect test) had a synchronization issue, where the (lldb) promts it was expecting were getting out of sync. This happened for two reasons: - it did not expect the initial (lldb) prompt we print at startup - launchArgs() returned None, which resulted in an extra "target create None" command being issued to lldb (and an extra unhandled prompt being printed). Resolving these two issues seems to fix (or at least, improve) the test. llvm-svn: 357459
This commit is contained in:
@@ -31,7 +31,9 @@ class CommandScriptImmediateOutputTestCase (PExpectTest):
|
||||
@skipIfDarwin
|
||||
def test_command_script_immediate_output_console(self):
|
||||
"""Test that LLDB correctly allows scripted commands to set immediate output to the console."""
|
||||
prompt = "\(lldb\) "
|
||||
self.launch(timeout=10)
|
||||
self.expect(prompt)
|
||||
|
||||
script = os.path.join(self.getSourceDir(), 'custom_command.py')
|
||||
prompt = "\(lldb\) "
|
||||
@@ -44,7 +46,7 @@ class CommandScriptImmediateOutputTestCase (PExpectTest):
|
||||
'mycommand',
|
||||
patterns='this is a test string, just a test string')
|
||||
self.sendline('command script delete mycommand', patterns=[prompt])
|
||||
self.quit(gracefully=False)
|
||||
self.quit()
|
||||
|
||||
@skipIfRemote # test not remote-ready llvm.org/pr24813
|
||||
@expectedFailureAll(
|
||||
@@ -54,7 +56,9 @@ class CommandScriptImmediateOutputTestCase (PExpectTest):
|
||||
@skipIfDarwin
|
||||
def test_command_script_immediate_output_file(self):
|
||||
"""Test that LLDB correctly allows scripted commands to set immediate output to a file."""
|
||||
prompt = "\(lldb\) "
|
||||
self.launch(timeout=10)
|
||||
self.expect(prompt)
|
||||
|
||||
test_files = {self.getBuildArtifact('read.txt'): 'r',
|
||||
self.getBuildArtifact('write.txt'): 'w',
|
||||
@@ -71,7 +75,6 @@ class CommandScriptImmediateOutputTestCase (PExpectTest):
|
||||
init.write(starter_string)
|
||||
|
||||
script = os.path.join(self.getSourceDir(), 'custom_command.py')
|
||||
prompt = "\(lldb\) "
|
||||
|
||||
self.sendline('command script import %s' % script, patterns=[prompt])
|
||||
|
||||
@@ -85,7 +88,7 @@ class CommandScriptImmediateOutputTestCase (PExpectTest):
|
||||
|
||||
self.sendline('command script delete mywrite', patterns=[prompt])
|
||||
|
||||
self.quit(gracefully=False)
|
||||
self.quit()
|
||||
|
||||
for path, mode in test_files.items():
|
||||
with open(path, 'r') as result:
|
||||
@@ -96,4 +99,3 @@ class CommandScriptImmediateOutputTestCase (PExpectTest):
|
||||
result.readline(), write_string + mode + '\n')
|
||||
|
||||
self.assertTrue(os.path.isfile(path))
|
||||
os.remove(path)
|
||||
|
||||
@@ -27,7 +27,7 @@ else:
|
||||
TestBase.setUp(self)
|
||||
|
||||
def launchArgs(self):
|
||||
pass
|
||||
return ""
|
||||
|
||||
def launch(self, timeout=None):
|
||||
if timeout is None:
|
||||
|
||||
Reference in New Issue
Block a user