Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(732)

Unified Diff: mojo/PRESUBMIT_test.py

Issue 886453002: Add checks on services' public BUILD.gn files to //mojo/PRESUBMIT.py (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Add definition of services vars Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« mojo/PRESUBMIT.py ('K') | « mojo/PRESUBMIT.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/PRESUBMIT_test.py
diff --git a/mojo/PRESUBMIT_test.py b/mojo/PRESUBMIT_test.py
index 7ef8c34c7b93462f872693ac3fd8748d359cfc5a..ac386daf866f3fad8d5d441f8d12308a7ef0559f 100755
--- a/mojo/PRESUBMIT_test.py
+++ b/mojo/PRESUBMIT_test.py
@@ -15,11 +15,13 @@ from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi
_SDK_BUILD_FILE = 'mojo/public/some/path/BUILD.gn'
_EDK_BUILD_FILE = 'mojo/edk/some/path/BUILD.gn'
+_SERVICE_BUILD_FILE = 'mojo/services/some_service/public/BUILD.gn'
_IRRELEVANT_BUILD_FILE = 'mojo/foo/some/path/BUILD.gn'
_PACKAGE_BUILDFILES = {
"SDK" : _SDK_BUILD_FILE,
"EDK" : _EDK_BUILD_FILE,
+ "services" : _SERVICE_BUILD_FILE
}
class AbsoluteReferencesInBuildFilesTest(unittest.TestCase):
@@ -30,6 +32,8 @@ class AbsoluteReferencesInBuildFilesTest(unittest.TestCase):
self.sdk_relative_path = 'mojo/public/some/relative/path'
self.edk_absolute_path = '//mojo/edk/some/absolute/path'
self.edk_relative_path = 'mojo/edk/some/relative/path'
+ self.service_absolute_path = '//mojo/services/some/service'
+ self.service_relative_path = '../../../some/service'
self.whitelisted_external_path = '//testing/gtest'
self.non_whitelisted_external_path = '//base'
@@ -158,6 +162,33 @@ class AbsoluteReferencesInBuildFilesTest(unittest.TestCase):
"""Tests that an external path in an EDK buildfile is not flagged."""
self._testExternalReferenceInPackage("EDK")
+ def testAbsoluteSDKReferenceInServiceBuildFile(self):
+ """Tests that an absolute SDK path within a service's public buildfile is
+ flagged."""
+ self._testAbsoluteSDKReferenceInPackage("services")
+
+ def testAbsoluteServiceReferenceInServiceBuildFile(self):
+ """Tests that an absolute path to a service within a service's public
+ buildfile is flagged."""
+ mock_input_api = self.inputApiContainingFileWithPaths(
+ _SERVICE_BUILD_FILE,
+ [ self.service_relative_path, self.service_absolute_path ])
+ warnings = PRESUBMIT._BuildFileChecks(mock_input_api, MockOutputApi())
+
+ self.assertEqual(1, len(warnings))
+ expected_message = \
+ PRESUBMIT._ILLEGAL_SERVICES_ABSOLUTE_PATH_WARNING_MESSAGE
+ self.checkWarningWithSingleItem(warnings[0],
+ expected_message,
+ _SERVICE_BUILD_FILE,
+ 2,
+ self.service_absolute_path)
+
+ def testExternalReferenceInServiceBuildFile(self):
+ """Tests that an illegal external path in a service's buildfile is flagged
+ ."""
+ self._testExternalReferenceInPackage("services")
+
def testIrrelevantBuildFile(self):
"""Tests that nothing is flagged in a non SDK/EDK buildfile."""
mock_input_api = self.inputApiContainingFileWithPaths(
@@ -257,6 +288,16 @@ class SourceSetTypesInBuildFilesTest(unittest.TestCase):
"""Tests that a mojo_sdk_source_set within an EDK buildfile is flagged."""
self._testWrongTypeOfWrapperSourceSetInPackage("EDK")
+ def testNakedSourceSetInServiceBuildFile(self):
+ """Tests that a source_set within a service's public buildfile is flagged.
+ """
+ self._testNakedSourceSetInPackage("services")
+
+ def testEDKSourceSetInServiceBuildFile(self):
+ """Tests that a mojo_edk_source_set within a service's public buildfile is
+ flagged."""
+ self._testWrongTypeOfWrapperSourceSetInPackage("services")
+
def testIrrelevantBuildFile(self):
"""Tests that a source_set in a non-SDK/EDK buildfile isn't flagged."""
mock_input_api = self.inputApiContainingFileWithSourceSets(
« mojo/PRESUBMIT.py ('K') | « mojo/PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698