diff options
author | Mirko Bonadei <mbonadei@webrtc.org> | 2017-09-19 10:54:24 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2017-09-19 10:54:40 +0000 |
commit | 034a6b8a4cdf151ae7377c87c5b2b6156d658173 (patch) | |
tree | c81d51d2aa56167486642e00081569f1490cffc6 /presubmit_test.py | |
parent | 0c15c5332fea2bbf5fe29dd806f9f4e606eeb9b8 (diff) | |
download | webrtc-034a6b8a4cdf151ae7377c87c5b2b6156d658173.tar.gz |
Revert "Adding PRESUBMIT check to avoid mixing C, C++ and Objc-C/Obj-C++."
This reverts commit 0c15c5332fea2bbf5fe29dd806f9f4e606eeb9b8.
Reason for revert: This causes problems in this moment. I have to fix a target in rtc_base before landing this presubmit check.
Original change's description:
> Adding PRESUBMIT check to avoid mixing C, C++ and Objc-C/Obj-C++.
>
> The error message will be something like:
>
> GN targets cannot mix .c (or .cc) and .m (or .mm) source files.
> Please create a separate target for each collection of sources.
> Mixed sources:
> {
> BUILD_GN_PATH: [
> [
> TARGET_NAME,
> [
> SOURCES
> ]
> ],
> ...
> ],
> ...
> }
>
> Bug: webrtc:7743
> Change-Id: I45dd2c621b830e5aeb081fa8d17c9497a49c2554
> Reviewed-on: https://webrtc-review.googlesource.com/1980
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Henrik Kjellander <kjellander@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#19897}
TBR=kjellander@webrtc.org,mbonadei@webrtc.org
Change-Id: I73ff609b0140719473afd36ead1632e5cc3b41f6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:7743
Reviewed-on: https://webrtc-review.googlesource.com/2180
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19898}
Diffstat (limited to 'presubmit_test.py')
-rwxr-xr-x | presubmit_test.py | 75 |
1 files changed, 4 insertions, 71 deletions
diff --git a/presubmit_test.py b/presubmit_test.py index 5e342baf5b..f17a20f5b2 100755 --- a/presubmit_test.py +++ b/presubmit_test.py @@ -60,7 +60,7 @@ class CheckNewlineAtTheEndOfProtoFilesTest(unittest.TestCase): shutil.rmtree(self.tmp_dir, ignore_errors=True) def testErrorIfProtoFileDoesNotEndWithNewline(self): - self._GenerateProtoWithoutNewlineAtTheEnd() + self.__GenerateProtoWithoutNewlineAtTheEnd() self.input_api.files = [MockFile(self.proto_file_path)] errors = PRESUBMIT.CheckNewlineAtTheEndOfProtoFiles(self.input_api, self.output_api) @@ -70,13 +70,13 @@ class CheckNewlineAtTheEndOfProtoFilesTest(unittest.TestCase): str(errors[0])) def testNoErrorIfProtoFileEndsWithNewline(self): - self._GenerateProtoWithNewlineAtTheEnd() + self.__GenerateProtoWithNewlineAtTheEnd() self.input_api.files = [MockFile(self.proto_file_path)] errors = PRESUBMIT.CheckNewlineAtTheEndOfProtoFiles(self.input_api, self.output_api) self.assertEqual(0, len(errors)) - def _GenerateProtoWithNewlineAtTheEnd(self): + def __GenerateProtoWithNewlineAtTheEnd(self): with open(self.proto_file_path, 'w') as f: f.write(textwrap.dedent(""" syntax = "proto2"; @@ -84,7 +84,7 @@ class CheckNewlineAtTheEndOfProtoFilesTest(unittest.TestCase): package webrtc.audioproc; """)) - def _GenerateProtoWithoutNewlineAtTheEnd(self): + def __GenerateProtoWithoutNewlineAtTheEnd(self): with open(self.proto_file_path, 'w') as f: f.write(textwrap.dedent(""" syntax = "proto2"; @@ -92,72 +92,5 @@ class CheckNewlineAtTheEndOfProtoFilesTest(unittest.TestCase): package webrtc.audioproc;""")) -class CheckNoMixingSourcesTest(unittest.TestCase): - - def setUp(self): - self.tmp_dir = tempfile.mkdtemp() - self.file_path = os.path.join(self.tmp_dir, 'BUILD.gn') - self.input_api = MockInputApi() - self.output_api = MockOutputApi() - - def tearDown(self): - shutil.rmtree(self.tmp_dir, ignore_errors=True) - - def testErrorIfCAndCppAreMixed(self): - self._AssertNumberOfErrorsWithSources(1, ['foo.c', 'bar.cc', 'bar.h']) - - def testErrorIfCAndObjCAreMixed(self): - self._AssertNumberOfErrorsWithSources(1, ['foo.c', 'bar.m', 'bar.h']) - - def testErrorIfCAndObjCppAreMixed(self): - self._AssertNumberOfErrorsWithSources(1, ['foo.c', 'bar.mm', 'bar.h']) - - def testErrorIfCppAndObjCAreMixed(self): - self._AssertNumberOfErrorsWithSources(1, ['foo.cc', 'bar.m', 'bar.h']) - - def testErrorIfCppAndObjCppAreMixed(self): - self._AssertNumberOfErrorsWithSources(1, ['foo.cc', 'bar.mm', 'bar.h']) - - def testNoErrorIfOnlyC(self): - self._AssertNumberOfErrorsWithSources(0, ['foo.c', 'bar.c', 'bar.h']) - - def testNoErrorIfOnlyCpp(self): - self._AssertNumberOfErrorsWithSources(0, ['foo.cc', 'bar.cc', 'bar.h']) - - def testNoErrorIfOnlyObjC(self): - self._AssertNumberOfErrorsWithSources(0, ['foo.m', 'bar.m', 'bar.h']) - - def testNoErrorIfOnlyObjCpp(self): - self._AssertNumberOfErrorsWithSources(0, ['foo.mm', 'bar.mm', 'bar.h']) - - def testNoErrorIfObjCAndObjCppAreMixed(self): - self._AssertNumberOfErrorsWithSources(0, ['foo.m', 'bar.mm', 'bar.h']) - - 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_source_set("foo_bar") { - sources = [ - "%s", - "%s", - "%s", - ], - } - """ % tuple(sources))) - 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])) - - def _GenerateBuildFile(self, content): - with open(self.file_path, 'w') as f: - f.write(content) - - if __name__ == '__main__': unittest.main() |