Commit 9ecbad54 authored by Jonas Devlieghere's avatar Jonas Devlieghere
Browse files

[lldb] lldbinline and lldbtest gardening (NFC)

 - Make the open more Pythonic.
 - Remove the unused `cleanup` Make target.
 - Remove commented-out/obvious/low-value comments.
 - Cleanup the forked process PID list.
parent f4476b72
Loading
Loading
Loading
Loading
+11 −21
Original line number Diff line number Diff line
@@ -82,20 +82,16 @@ class CommandParser:


class InlineTest(TestBase):
    # Overrides

    def getBuildDirBasename(self):
        return self.__class__.__name__ + "." + self.testMethodName

    # Internal implementation

    def BuildMakefile(self):
        makefilePath = self.getBuildArtifact("Makefile")
        if os.path.exists(makefilePath):
            return

        categories = {}

        for f in os.listdir(self.getSourceDir()):
            t = source_type(f)
            if t:
@@ -104,14 +100,13 @@ class InlineTest(TestBase):
                else:
                    categories[t] = [f]

        makefile = open(makefilePath, 'w+')

        with open(makefilePath, 'w+') as makefile:
            for t in list(categories.keys()):
                line = t + " := " + " ".join(categories[t])
                makefile.write(line + "\n")

        if ('OBJCXX_SOURCES' in list(categories.keys())) or (
                'OBJC_SOURCES' in list(categories.keys())):
            if ('OBJCXX_SOURCES' in list(categories.keys())) or \
               ('OBJC_SOURCES' in list(categories.keys())):
                makefile.write(
                    "LDFLAGS = $(CFLAGS) -lobjc -framework Foundation\n")

@@ -119,9 +114,6 @@ class InlineTest(TestBase):
                makefile.write("CXXFLAGS += -std=c++11\n")

            makefile.write("include Makefile.rules\n")
        makefile.write("\ncleanup:\n\trm -f Makefile *.d\n\n")
        makefile.flush()
        makefile.close()

    def _test(self):
        self.BuildMakefile()
@@ -168,8 +160,6 @@ class InlineTest(TestBase):
                                               lldb.eStateExited],
                        PROCESS_EXITED)

    # Utilities for testcases

    def check_expression(self, expression, expected_result, use_summary=True):
        value = self.frame().EvaluateExpression(expression)
        self.assertTrue(value.IsValid(), expression + "returned a valid value")
+2 −7
Original line number Diff line number Diff line
@@ -891,13 +891,14 @@ class Base(unittest2.TestCase):
        for p in self.subprocesses:
            p.terminate()
            del p
        del self.subprocesses[:]
        self.subprocesses.clear()
        # Ensure any forked processes are cleaned up
        for pid in self.forkedProcessPids:
            try:
                os.kill(pid, signal.SIGTERM)
            except OSError:
                pass
        self.forkedProcessPids.clear()

    def spawnSubprocess(self, executable, args=[], install_remote=True):
        """ Creates a subprocess.Popen object with the specified executable and arguments,
@@ -1877,9 +1878,6 @@ class TestBase(Base):
        self.addTearDownHook(lambda: os.remove(src))

    def setUp(self):
        #import traceback
        # traceback.print_stack()

        # Works with the test driver to conditionally skip tests via
        # decorators.
        Base.setUp(self)
@@ -1998,9 +1996,6 @@ class TestBase(Base):
            return self.getBuildDir()

    def tearDown(self):
        #import traceback
        # traceback.print_stack()

        # Ensure all the references to SB objects have gone away so that we can
        # be sure that all test-specific resources have been freed before we
        # attempt to delete the targets.