def CheckGnGen(input_api, output_api): """Runs `gn gen --check` with default args to detect mismatches between #includes and dependencies in the BUILD.gn files, as well as general build errors. """ with _AddToPath(input_api.os_path.join( input_api.PresubmitLocalPath(), 'tools_webrtc', 'presubmit_checks_lib')): from gn_check import RunGnCheck errors = RunGnCheck(input_api.PresubmitLocalPath())[:5] if errors: return [output_api.PresubmitPromptWarning( 'Some #includes do not match the build dependency graph. Please run:\n' ' gn gen --check <out_dir>', long_text='\n\n'.join(errors))] return []
def testCircularDependencyError(self): test_dir = os.path.join(TESTDATA_DIR, 'circular_dependency') expected_errors = ['ERROR Dependency cycle:\n' ' //:bar ->\n //:foo ->\n //:bar'] self.assertListEqual(expected_errors, RunGnCheck(test_dir))