tfiala added a comment.

In http://reviews.llvm.org/D19215#404143, @zturner wrote:

> It seems very strange to me to be changing a .pyc filename to a .py
>  filename.  I think we should try to understand where the .pyc filename is
>  coming from to begin with, and this is just masking the real error.


Testing: 38 test suites, 12 threads
 7 out of 38 test suites processed - TestChar1632T.py

  Traceback (most recent call last):
    File "test/dotest.py", line 7, in <module>
      lldbsuite.test.run_suite()
    File 
"/Volumes/Data/src/lldb-llvm.org/lldb/packages/Python/lldbsuite/test/dotest.py",
 line 952, in run_suite
      visit('Test', dirpath, filenames)
    File 
"/Volumes/Data/src/lldb-llvm.org/lldb/packages/Python/lldbsuite/test/dotest.py",
 line 747, in visit
      
configuration.suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base))
    File 
"/Volumes/Data/src/lldb-llvm.org/lldb/third_party/Python/module/unittest2/unittest2/loader.py",
 line 103, in loadTestsFromName
      module = __import__('.'.join(parts_copy))
    File 
"/Volumes/Data/src/lldb-llvm.org/lldb/packages/Python/lldbsuite/test/lang/cpp/lambdas/TestLambdas.py",
 line 4, in <module>
      lldbinline.MakeInlineTest(__file__, globals(), [])
    File 
"/Volumes/Data/src/lldb-llvm.org/lldb/packages/Python/lldbsuite/test/lldbinline.py",
 line 210, in MakeInlineTest
      raise Exception("lldbinline file ends with .pyc: {}".format(__file))
  Exception: lldbinline file ends with .pyc: 
/Volumes/Data/src/lldb-llvm.org/lldb/packages/Python/lldbsuite/test/lang/cpp/lambdas/TestLambdas.pyc

The __file__ for lldbinline.py-based tests is getting set to .pyc via the 
unittest2 loader.  This callstack comes from inserting this code into 
lldbinline.py:

  diff --git a/packages/Python/lldbsuite/test/lldbinline.py 
b/packages/Python/lldbsuite/test/lldbinline.py
  index 4eaa2a7..3eef4ee 100644
  --- a/packages/Python/lldbsuite/test/lldbinline.py
  +++ b/packages/Python/lldbsuite/test/lldbinline.py
  @@ -206,6 +206,10 @@ def MakeInlineTest(__file, __globals, decorators=None):
       __globals.update({test_name : test})
  
       # Store the name of the originating file.o
  -    test.test_filename = __file
  +    if __file is not None and __file.endswith(".pyc"):
  +        raise Exception("lldbinline file ends with .pyc: {}".format(__file))
  +        test.test_filename = __file[0:-1]
  +    else:
  +        test.test_filename = __file
       return test

So - I can either intercept it right there and convert to .py, or I can protect 
it at the API ingestion level.  If we go with the former, then I want to add an 
assert to the latter to make sure any cases of this sneaking in are caught.

Since this case was only happening for lldbinline tests, I suspect it was 
always happening and just wasn't caught.

I'll adjust the patch shortly to have the API ingestion of the test_filename 
assert on .pyc (and I'll ensure it ends in .py, not just that it *isn't* .pyc). 
 I'll also fix up the lldbinline case at the point where we grab it from the 
unittest2 loader code.


http://reviews.llvm.org/D19215



_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to