Continue the cleanup started on r158737

Adds a utility class method to TestBase that checks and removes a temp
file.
Removed every use of system() to execute rm -f.

llvm-svn: 158809
This commit is contained in:
Filipe Cabecinhas 2012-06-20 10:13:40 +00:00
parent 8cb8e9987b
commit 0eec15acf2
5 changed files with 19 additions and 15 deletions

View File

@ -14,7 +14,8 @@ class BreakpointCommandTestCase(TestBase):
@classmethod
def classCleanup(cls):
"""Cleanup the test byproduct of breakpoint_command_sequence(self)."""
system(["/bin/sh", "-c", "rm -f output.txt output2.txt"])
cls.RemoveTempFile("output.txt")
cls.RemoveTempFile("output2.txt")
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@dsym_test
@ -109,10 +110,8 @@ class BreakpointCommandTestCase(TestBase):
patterns = ["Breakpoint created: [0-9]+: source regex = \"is about to return \[12\]0\", locations = 1"])
# Run the program. Remove 'output.txt' if it exists.
if os.path.exists('output.txt'):
os.remove('output.txt')
if os.path.exists('output2.txt'):
os.remove('output2.txt')
self.RemoveTempFile("output.txt")
self.RemoveTempFile("output2.txt")
self.runCmd("run", RUN_SUCCEEDED)
# Check that the file 'output.txt' exists and contains the string "lldb".

View File

@ -1222,3 +1222,8 @@ class TestBase(Base):
return
print child
@classmethod
def RemoveTempFile(cls, file):
if os.path.exists(file):
os.remove(file)

View File

@ -14,10 +14,10 @@ class SettingsCommandTestCase(TestBase):
@classmethod
def classCleanup(cls):
"""Cleanup the test byproducts."""
system(["/bin/sh", "-c", "rm -f output1.txt"])
system(["/bin/sh", "-c", "rm -f output2.txt"])
system(["/bin/sh", "-c", "rm -f stderr.txt"])
system(["/bin/sh", "-c", "rm -f stdout.txt"])
cls.RemoveTempFile("output1.txt")
cls.RemoveTempFile("output2.txt")
cls.RemoveTempFile("stderr.txt")
cls.RemoveTempFile("stdout.txt")
def test_apropos_should_also_search_settings_description(self):
"""Test that 'apropos' command should also search descriptions for the settings variables."""

View File

@ -15,10 +15,10 @@ class CommandLineCompletionTestCase(TestBase):
@classmethod
def classCleanup(cls):
"""Cleanup the test byproducts."""
system(["/bin/sh", "-c", "rm -f child_send1.txt"])
system(["/bin/sh", "-c", "rm -f child_read1.txt"])
system(["/bin/sh", "-c", "rm -f child_send2.txt"])
system(["/bin/sh", "-c", "rm -f child_read2.txt"])
cls.RemoveTempFile("child_send1.txt")
cls.RemoveTempFile("child_read1.txt")
cls.RemoveTempFile("child_send2.txt")
cls.RemoveTempFile("child_read2.txt")
def test_stty_dash_a_before_and_afetr_invoking_lldb_command(self):
"""Test that 'stty -a' displays the same output before and after running the lldb command."""

View File

@ -14,8 +14,8 @@ class UUIDMismatchWarningCase(TestBase):
@classmethod
def classCleanup(cls):
"""Cleanup the test byproducts."""
system(["/bin/sh", "-c", "rm -f child_send.txt"])
system(["/bin/sh", "-c", "rm -f child_read.txt"])
cls.RemoveTempFile("child_send.txt")
cls.RemoveTempFile("child_read.txt")
def setUp(self):
TestBase.setUp(self)