Tighten up sys.path, and use absolute imports everywhere.

For convenience, we had added the folder that dotest.py was in
to sys.path, so that we could easily write things like
`import lldbutil` from anywhere and any test.  This introduces
a subtle problem when using Python's package system, because when
unittest2 imports a particular test suite, the test suite is detached
from the package.  Thus, writing "import lldbutil" from dotest imports
it as part of the package, and writing the same line from a test
does a fresh import since the importing module was not part of
the same package.

The real way to fix this is to use absolute imports everywhere.  Instead
of writing "import lldbutil", we need to write "import
lldbsuite.test.util".  This patch fixes up that and all other similar
cases, and additionally removes the script directory from sys.path
to ensure that this can't happen again.

llvm-svn: 251886
This commit is contained in:
Zachary Turner
2015-11-03 02:06:18 +00:00
parent 6f4ed269b9
commit 95c453a221
414 changed files with 815 additions and 772 deletions

View File

@@ -8,8 +8,9 @@ import use_lldb_suite
import os, time
import re
import lldb, lldbutil
from lldbtest import *
import lldb
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
class DisasmAPITestCase(TestBase):
@@ -103,7 +104,7 @@ class DisasmAPITestCase(TestBase):
self.assertTrue(sa1 and sa2 and sa1 == sa2,
"The two starting addresses should be the same")
from lldbutil import get_description
from lldbsuite.test.lldbutil import get_description
desc1 = get_description(sa1)
desc2 = get_description(sa2)
self.assertTrue(desc1 and desc2 and desc1 == desc2,

View File

@@ -8,8 +8,9 @@ import use_lldb_suite
import os, time
import re
import lldb, lldbutil
from lldbtest import *
import lldb
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
class SymbolAPITestCase(TestBase):