def RunTest(self, test_dir, check_all_build_files=False): logger = Logger(test_dir) build_files = [os.path.join(test_dir, 'BUILD.gn')] if check_all_build_files: build_files = None CheckPackageBoundaries(test_dir, logger, build_files) expected_messages = ReadPylFile(os.path.join(test_dir, 'expected.pyl')) self.assertListEqual(sorted(expected_messages), sorted(logger.messages))
def CheckNoPackageBoundaryViolations(input_api, gn_files, output_api): cwd = input_api.PresubmitLocalPath() with _AddToPath(input_api.os_path.join( cwd, 'tools_webrtc', 'presubmit_checks_lib')): from check_package_boundaries import CheckPackageBoundaries build_files = [os.path.join(cwd, gn_file.LocalPath()) for gn_file in gn_files] errors = CheckPackageBoundaries(cwd, build_files)[:5] if errors: return [output_api.PresubmitError( 'There are package boundary violations in the following GN files:', long_text='\n\n'.join(str(err) for err in errors))] return []
def _RunTest(self, test_dir, check_all_build_files=False): build_files = [os.path.join(test_dir, 'BUILD.gn')] if check_all_build_files: build_files = None messages = [] for violation in CheckPackageBoundaries(test_dir, build_files): build_file_path = os.path.relpath(violation.build_file_path, test_dir) build_file_path = build_file_path.replace(os.path.sep, '/') messages.append(violation._replace(build_file_path=build_file_path)) expected_messages = ReadPylFile(os.path.join(test_dir, 'expected.pyl')) self.assertListEqual(sorted(expected_messages), sorted(messages))
def testRelativeFilename(self): test_dir = os.path.join(TESTDATA_DIR, 'all_build_files') with self.assertRaises(AssertionError): CheckPackageBoundaries(test_dir, ["BUILD.gn"])