示例#1
0
 def testNoErrorIfSourcesAreInExclusiveIfBranches(self):
   self._GenerateBuildFile(textwrap.dedent("""
     rtc_source_set("bar_foo") {
       if (is_win) {
         sources = [
           "bar.cc",
         ],
       }
       if (is_ios) {
         sources = [
           "bar.mm",
         ],
       }
     }
     rtc_source_set("foo_bar") {
       if (is_win) {
         sources = [
           "foo.cc",
         ],
       }
       if (is_ios) {
         sources = [
           "foo.mm",
         ],
       }
     }
   """))
   self.input_api.files = [MockFile(self.file_path)]
   errors = PRESUBMIT.CheckNoMixingSources(self.input_api,
                                           [MockFile(self.file_path)],
                                           self.output_api)
   self.assertEqual(0, len(errors))
示例#2
0
 def _AssertNumberOfErrorsWithSources(self, number_of_errors, sources):
   assert 3 == len(sources), 'This function accepts a list of 3 source files'
   self._GenerateBuildFile(textwrap.dedent("""
     rtc_static_library("bar_foo") {
       sources = [
         "%s",
         "%s",
         "%s",
       ],
     }
     rtc_source_set("foo_bar") {
       sources = [
         "%s",
         "%s",
         "%s",
       ],
     }
   """ % (tuple(sources) * 2)))
   self.input_api.files = [MockFile(self.file_path)]
   errors = PRESUBMIT.CheckNoMixingSources(self.input_api,
                                           [MockFile(self.file_path)],
                                           self.output_api)
   self.assertEqual(number_of_errors, len(errors))
   if number_of_errors == 1:
     for source in sources:
       if not source.endswith('.h'):
         self.assertTrue(source in str(errors[0]))
示例#3
0
 def testErrorIfSourcesAreNotInExclusiveIfBranches(self):
     self._GenerateBuildFile(
         textwrap.dedent("""
   rtc_library("bar_foo") {
     if (is_win) {
       sources = [
         "bar.cc",
       ],
     }
     if (foo_bar) {
       sources += [
         "bar.mm",
       ],
     }
   }
   rtc_library("foo_bar") {
     if (is_win) {
       sources = [
         "foo.cc",
       ],
     }
     if (foo_bar) {
       sources += [
         "foo.mm",
       ],
     }
     if (is_ios) {
       sources = [
         "bar.m",
         "bar.c",
       ],
     }
   }
 """))
     self.input_api.files = [MockFile(self.file_path)]
     errors = PRESUBMIT.CheckNoMixingSources(self.input_api,
                                             [MockFile(self.file_path)],
                                             self.output_api)
     self.assertEqual(1, len(errors))
     self.assertTrue('bar.cc' in str(errors[0]))
     self.assertTrue('bar.mm' in str(errors[0]))
     self.assertTrue('foo.cc' in str(errors[0]))
     self.assertTrue('foo.mm' in str(errors[0]))
     self.assertTrue('bar.m' in str(errors[0]))
     self.assertTrue('bar.c' in str(errors[0]))