示例#1
0
 def _missing_deps_finder(self):
     dep_analyzer = JvmDependencyAnalyzer(
         get_buildroot(),
         self.context.products.get_data('runtime_classpath'))
     return MissingDependencyFinder(
         dep_analyzer,
         CompileErrorExtractor(
             self.get_options().class_not_found_error_patterns))
示例#2
0
 def _missing_deps_finder(self):
   return MissingDependencyFinder(self._dep_analyzer, CompileErrorExtractor(
     self.get_options().class_not_found_error_patterns))
示例#3
0
 def setUp(self):
     self.compile_error_finder = CompileErrorExtractor(CLASS_NOT_FOUND_ERROR_PATTERNS)
示例#4
0
class CompileErrorExtractorTest(unittest.TestCase):
    ERROR_MESSAGES = [
        r"""
        [error] /path/to/file/Hello.java:3:1: cannot find symbol
        [error]   symbol:   class Nullable
        [error]   location: package javax.annotation
        [error] import javax.annotation.Nullable;""",
        r"""
        [error] /path/to/file/Hello.java:63:1: cannot access org.apache.thrift.TBase
        [error]   class file for org.apache.thrift.TBase not found""",
        r"""
        [error] /path/to/file/Hello.java:6:1: package a.b.c does not exist
        [error] import a.b.c.ImmutableMap;""",
        r"""
        [error] /path/to/file/Hello.java:36:1: cannot find symbol
        [error]   symbol:   class XYZ
        [error]   location: package a.b.c""",
        r"""
        [error] /path/to/file/Hello.java:102:1: package a.b.c does not exist
        [error]     public static final A<a.b.c.XYZ> xyz = new ...;    """,
        r"""
        [error] ## Exception when compiling /path/to/file/Hello.java and others...
        [error] Type com.twitter.util.lint.Rule not present""",
        r"""
        [error] ## Exception when compiling /path/to/file/Hello.java and others...
        [error] java.lang.NoClassDefFoundError: a.b.c.XYZ""",
        r"""
        [error] /path/to/file/Hello.scala:211:26: exception during macro expansion:
        [error] java.lang.ClassNotFoundException: com.twitter.x.thrift.thriftscala.Y""",
        r"""
        [error] /path/to/file/Hello.scala:7:33: object x is not a member of package a.b.c
        [error] import a.b.c.x.Y""",
        r"""
        java.lang.NoClassDefFoundError: org/apache/thrift/TEnum""",
        r"""
        [error] missing or invalid dependency detected while loading class file 'Logging.class'.
        [error] Could not access type Future in value com.twitter.util,""",
        r"""
        [error] Class a.b.c.X not found - continuing with a stub.""",
        r"""
        [error] /path/to/file/Hello.scala:34:6: Symbol 'type <none>.w.XYZ' is missing from the classpath.
        [error] This symbol is required by 'class a.b.c.DEF'.
        [error] Make sure that type XYZ is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
        [error] A full rebuild may help if 'DEF.class' was compiled against an incompatible version of <none>.w.""",
        r"""
        [error] /path/to/file/Hello.scala:34:6: Symbol 'class u.v.w.XYZ' is missing from the classpath.
        [error] This symbol is required by 'class a.b.c.DEF'.
        [error] Make sure that class XYZ is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
        [error] A full rebuild may help if 'DEF.class' was compiled against an incompatible version of u.v.w.""",
        r"""
        [error] Symbol 'type u.v.w.XYZ' is missing from the classpath.
        [error] This symbol is required by 'method DEF.method'.
        [error] Make sure that type XYZ is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
        [error] A full rebuild may help if 'DEF.class' was compiled against an incompatible version of u.v.w.""",
    ]

    EXPECTED_ERRORS = [
        ClassNotFoundError("/path/to/file/Hello.java", "3", "javax.annotation.Nullable"),
        ClassNotFoundError("/path/to/file/Hello.java", "63", "org.apache.thrift.TBase"),
        ClassNotFoundError("/path/to/file/Hello.java", "6", "a.b.c.ImmutableMap"),
        ClassNotFoundError("/path/to/file/Hello.java", "36", "a.b.c.XYZ"),
        ClassNotFoundError("/path/to/file/Hello.java", "102", "a.b.c.XYZ"),
        ClassNotFoundError("/path/to/file/Hello.java", None, "com.twitter.util.lint.Rule"),
        ClassNotFoundError("/path/to/file/Hello.java", None, "a.b.c.XYZ"),
        ClassNotFoundError(
            "/path/to/file/Hello.scala", "211", "com.twitter.x.thrift.thriftscala.Y"
        ),
        ClassNotFoundError("/path/to/file/Hello.scala", "7", "a.b.c.x.Y"),
        ClassNotFoundError(None, None, "org.apache.thrift.TEnum"),
        ClassNotFoundError(None, None, "com.twitter.util.Future"),
        ClassNotFoundError(None, None, "a.b.c.X"),
        ClassNotFoundError(None, None, "w.XYZ"),
        ClassNotFoundError(None, None, "u.v.w.XYZ"),
        ClassNotFoundError(None, None, "u.v.w.XYZ"),
    ]

    def setUp(self):
        self.compile_error_finder = CompileErrorExtractor(CLASS_NOT_FOUND_ERROR_PATTERNS)

    def test_extract_single_error(self):
        for error_message, expected_error in zip(self.ERROR_MESSAGES, self.EXPECTED_ERRORS):
            self.assertEqual([expected_error], self.compile_error_finder.extract(error_message))

    def test_extract_all_errors(self):
        compile_log = "\n".join(self.ERROR_MESSAGES)
        self.assertEqual(self.EXPECTED_ERRORS, self.compile_error_finder.extract(compile_log))
 def setUp(self):
   self.compile_error_finder = CompileErrorExtractor(CLASS_NOT_FOUND_ERROR_PATTERNS)
class CompileErrorExtractorTest(unittest.TestCase):
  ERROR_MESSAGES = [
    r"""
      [error] /path/to/file/Hello.java:3:1: cannot find symbol
      [error]   symbol:   class Nullable
      [error]   location: package javax.annotation
      [error] import javax.annotation.Nullable;""",
    r"""
      [error] /path/to/file/Hello.java:63:1: cannot access org.apache.thrift.TBase
      [error]   class file for org.apache.thrift.TBase not found""",
    r"""
      [error] /path/to/file/Hello.java:6:1: package a.b.c does not exist
      [error] import a.b.c.ImmutableMap;""",
    r"""
      [error] /path/to/file/Hello.java:36:1: cannot find symbol
      [error]   symbol:   class XYZ
      [error]   location: package a.b.c""",
    r"""
      [error] /path/to/file/Hello.java:102:1: package a.b.c does not exist
      [error]     public static final A<a.b.c.XYZ> xyz = new ...;    """,
    r"""
      [error] ## Exception when compiling /path/to/file/Hello.java and others...
      [error] Type com.twitter.util.lint.Rule not present""",
    r"""
      [error] ## Exception when compiling /path/to/file/Hello.java and others...
      [error] java.lang.NoClassDefFoundError: a.b.c.XYZ""",
    r"""
      [error] /path/to/file/Hello.scala:211:26: exception during macro expansion:
      [error] java.lang.ClassNotFoundException: com.twitter.x.thrift.thriftscala.Y""",
    r"""
      [error] /path/to/file/Hello.scala:7:33: object x is not a member of package a.b.c
      [error] import a.b.c.x.Y""",
    r"""
      java.lang.NoClassDefFoundError: org/apache/thrift/TEnum""",
    r"""
      [error] missing or invalid dependency detected while loading class file 'Logging.class'.
      [error] Could not access type Future in value com.twitter.util,""",
    r"""
      [error] Class a.b.c.X not found - continuing with a stub.""",
    r"""
      [error] /path/to/file/Hello.scala:34:6: Symbol 'type <none>.w.XYZ' is missing from the classpath.
      [error] This symbol is required by 'class a.b.c.DEF'.
      [error] Make sure that type XYZ is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
      [error] A full rebuild may help if 'DEF.class' was compiled against an incompatible version of <none>.w.""",
    r"""
      [error] /path/to/file/Hello.scala:34:6: Symbol 'class u.v.w.XYZ' is missing from the classpath.
      [error] This symbol is required by 'class a.b.c.DEF'.
      [error] Make sure that class XYZ is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
      [error] A full rebuild may help if 'DEF.class' was compiled against an incompatible version of u.v.w.""",
    r"""
      [error] Symbol 'type u.v.w.XYZ' is missing from the classpath.
      [error] This symbol is required by 'method DEF.method'.
      [error] Make sure that type XYZ is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
      [error] A full rebuild may help if 'DEF.class' was compiled against an incompatible version of u.v.w.""",

  ]

  EXPECTED_ERRORS = [
    ClassNotFoundError('/path/to/file/Hello.java', '3', 'javax.annotation.Nullable'),
    ClassNotFoundError('/path/to/file/Hello.java', '63', 'org.apache.thrift.TBase'),
    ClassNotFoundError('/path/to/file/Hello.java', '6', 'a.b.c.ImmutableMap'),
    ClassNotFoundError('/path/to/file/Hello.java', '36', 'a.b.c.XYZ'),
    ClassNotFoundError('/path/to/file/Hello.java', '102', 'a.b.c.XYZ'),
    ClassNotFoundError('/path/to/file/Hello.java', None, 'com.twitter.util.lint.Rule'),
    ClassNotFoundError('/path/to/file/Hello.java', None, 'a.b.c.XYZ'),
    ClassNotFoundError('/path/to/file/Hello.scala', '211', 'com.twitter.x.thrift.thriftscala.Y'),
    ClassNotFoundError('/path/to/file/Hello.scala', '7', 'a.b.c.x.Y'),
    ClassNotFoundError(None, None, 'org.apache.thrift.TEnum'),
    ClassNotFoundError(None, None, 'com.twitter.util.Future'),
    ClassNotFoundError(None, None, 'a.b.c.X'),
    ClassNotFoundError(None, None, 'w.XYZ'),
    ClassNotFoundError(None, None, 'u.v.w.XYZ'),
    ClassNotFoundError(None, None, 'u.v.w.XYZ'),
  ]

  def setUp(self):
    self.compile_error_finder = CompileErrorExtractor(CLASS_NOT_FOUND_ERROR_PATTERNS)

  def test_extract_single_error(self):
    for error_message, expected_error in zip(self.ERROR_MESSAGES, self.EXPECTED_ERRORS):
      self.assertEqual([expected_error], self.compile_error_finder.extract(error_message))

  def test_extract_all_errors(self):
    compile_log = '\n'.join(self.ERROR_MESSAGES)
    self.assertEqual(self.EXPECTED_ERRORS,
      self.compile_error_finder.extract(compile_log))
示例#7
0
class CompileErrorExtractorTest(unittest.TestCase):
    ERROR_MESSAGES = [
        r"""
      [error] /path/to/file/Hello.java:3:1: cannot find symbol
      [error]   symbol:   class Nullable
      [error]   location: package javax.annotation
      [error] import javax.annotation.Nullable;""",
        r"""
      [error] /path/to/file/Hello.java:63:1: cannot access org.apache.thrift.TBase
      [error]   class file for org.apache.thrift.TBase not found""",
        r"""
      [error] /path/to/file/Hello.java:6:1: package a.b.c does not exist
      [error] import a.b.c.ImmutableMap;""",
        r"""
      [error] /path/to/file/Hello.java:36:1: cannot find symbol
      [error]   symbol:   class XYZ
      [error]   location: package a.b.c""",
        r"""
      [error] /path/to/file/Hello.java:102:1: package a.b.c does not exist
      [error]     public static final A<a.b.c.XYZ> xyz = new ...;    """,
        r"""
      [error] ## Exception when compiling /path/to/file/Hello.java and others...
      [error] Type com.twitter.util.lint.Rule not present""",
        r"""
      [error] ## Exception when compiling /path/to/file/Hello.java and others...
      [error] java.lang.NoClassDefFoundError: a.b.c.XYZ""",
        r"""
      [error] /path/to/file/Hello.scala:211:26: exception during macro expansion:
      [error] java.lang.ClassNotFoundException: com.twitter.x.thrift.thriftscala.Y""",
        r"""
      [error] /path/to/file/Hello.scala:7:33: object x is not a member of package a.b.c
      [error] import a.b.c.x.Y""",
        r"""
      java.lang.NoClassDefFoundError: org/apache/thrift/TEnum""",
        r"""
      [error] missing or invalid dependency detected while loading class file 'Logging.class'.
      [error] Could not access type Future in value com.twitter.util,""",
        r"""
      [error] Class a.b.c.X not found - continuing with a stub.""",
    ]

    EXPECTED_ERRORS = [
        ClassNotFoundError('/path/to/file/Hello.java', '3',
                           'javax.annotation.Nullable'),
        ClassNotFoundError('/path/to/file/Hello.java', '63',
                           'org.apache.thrift.TBase'),
        ClassNotFoundError('/path/to/file/Hello.java', '6',
                           'a.b.c.ImmutableMap'),
        ClassNotFoundError('/path/to/file/Hello.java', '36', 'a.b.c.XYZ'),
        ClassNotFoundError('/path/to/file/Hello.java', '102', 'a.b.c.XYZ'),
        ClassNotFoundError('/path/to/file/Hello.java', None,
                           'com.twitter.util.lint.Rule'),
        ClassNotFoundError('/path/to/file/Hello.java', None, 'a.b.c.XYZ'),
        ClassNotFoundError('/path/to/file/Hello.scala', '211',
                           'com.twitter.x.thrift.thriftscala.Y'),
        ClassNotFoundError('/path/to/file/Hello.scala', '7', 'a.b.c.x.Y'),
        ClassNotFoundError(None, None, 'org.apache.thrift.TEnum'),
        ClassNotFoundError(None, None, 'com.twitter.util.Future'),
        ClassNotFoundError(None, None, 'a.b.c.X'),
    ]

    def setUp(self):
        self.compile_error_finder = CompileErrorExtractor(
            CLASS_NOT_FOUND_ERROR_PATTERNS)

    def test_extract_single_error(self):
        for error_message, expected_error in zip(self.ERROR_MESSAGES,
                                                 self.EXPECTED_ERRORS):
            self.assertEqual([expected_error],
                             self.compile_error_finder.extract(error_message))

    def test_extract_all_errors(self):
        compile_log = '\n'.join(self.ERROR_MESSAGES)
        self.assertEqual(self.EXPECTED_ERRORS,
                         self.compile_error_finder.extract(compile_log))