Provided a mechanism for the test class to cleanup after itself once it's done.
This will remove the confusion experienced when previous test runs left some
files (both intermediate or by-product as a result of the test).
lldbtest.TestBase defines a classmethod tearDownClass(cls) which invokes the
platform-specific cleanup() function as defined by the plugin; after that, it
invokes a subclass-specific function classCleanup(cls) if defined; and, finally,
it restores the old working directory.
An example of classCleanup(cls) is in settings/TestSettings.py:
@classmethod
def classCleanup(cls):
system(["/bin/sh", "-c", "rm output.txt"])
where it deletes the by-product "output.txt" as a result of running a.out.
llvm-svn: 114058
diff --git a/lldb/test/settings/TestSettings.py b/lldb/test/settings/TestSettings.py
index f18c0bc..e7dbdce 100644
--- a/lldb/test/settings/TestSettings.py
+++ b/lldb/test/settings/TestSettings.py
@@ -11,6 +11,10 @@
mydir = "settings"
+ @classmethod
+ def classCleanup(cls):
+ system(["/bin/sh", "-c", "rm output.txt"])
+
def test_set_prompt(self):
"""Test that 'set prompt' actually changes the prompt."""
@@ -62,7 +66,7 @@
self.runCmd("run", RUN_SUCCEEDED)
# Read the output file produced by running the program.
- output = open('/tmp/output.txt', 'r').read()
+ output = open('output.txt', 'r').read()
self.assertTrue(output.startswith("argv[1] matches") and
output.find("argv[2] matches") > 0 and