[lldb-dev] Moving pexpect and unittest2 to lldb/third_party

Zachary Turner via lldb-dev lldb-dev at lists.llvm.org
Thu Oct 22 09:26:19 PDT 2015

Todd, Greg, can you guys confirm this is true?   The import lldb would
succeed if someone had their PYTHONPATH set up just right, but if really
none of us care about it, I'm with Tamas in that I'd rather remove it.

On Thu, Oct 22, 2015 at 2:55 AM Tamas Berghammer <tberghammer at google.com>

> Hi Zach,
> I think nobody is using the "if __name__ == '__main__'" block as
> executing a test file directly isn't working at the moment (the "import
> lldb" command fails). If you plan to change all test file then I would
> prefer to remove the reference to unittest2 from them for simplicity if
> nobody have an objection against it.
> Tamas
> On Wed, Oct 21, 2015 at 8:57 PM Zachary Turner via lldb-dev <
> lldb-dev at lists.llvm.org> wrote:
>> *TL;DR - Nobody has to do anything, this is just a heads up that a 400+
>> file CL is coming.*
>> IANAL, but I've been told by one that I need to move all third party code
>> used by LLDB to lldb/third_party.  Currently there is only one thing there:
>> the Python `six` module used for creating code that is portable across
>> Python 2 and Python 3.
>> The only other 2 instances that I'm aware of are pexpect and unittest2,
>> which are under lldb/test.  I've got some patches locally which move
>> pexpect and unittest2 to lldb/third_party.  I'll hold off on checking them
>> in for a bit to give people a chance to see this message first, because
>> otherwise you might be surprised when you see a CL with 400 files being
>> checked in.
>> Nobody will have to do anything after this CL goes in, and everything
>> should continue to work exactly as it currently does.
>> The main reason for the churn is that pretty much every single test in
>> LLDB does something like this:
>> *import unittest2*
>> ...
>> if __name__ == '__main__':
>>     import atexit
>>     lldb.SBDebugger.Initialize()
>>     atexit.register(lambda: lldb.SBDebugger.Terminate())
>>     *unittest2.main()*
>> This worked when unittest2 was a subfolder of test, but not when it's
>> somewhere else.  Since LLDB's python code is not organized into a standard
>> python package and we treat the scripts like dotest etc as standalone
>> scripts, the way I've made this work is by introducing a module called *lldb_shared
>> *under test which, when you import it, fixes up sys.path to correctly
>> add all the right locations under lldb/third_party.
>> So, every single test now needs a line at the top to import lldb_shared.
>> TBH I don't even know if we need this unittest2 stuff anymore (does
>> anyone even use it?)  but even if the answer is no, then that still means
>> changing every file to delete the import statement and the if __name__ ==
>> '__main__': block.
>> If there are no major concerns I plan to check this in by the end of the
>> day, or tomorrow.
> _______________________________________________
>> lldb-dev mailing list
>> lldb-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20151022/b26e6d86/attachment.html>

More information about the lldb-dev mailing list