From 95a95c31affda2a86f11fe0b555b6bf4706d9b76 Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Wed, 21 Aug 2024 23:50:27 +0000 Subject: [PATCH] [infra] Add a presubmit check for edits in DDC Check for edits in compiler.dart or compiler_new.dart without an edit in the counterpart and warn about keeping them in sync. Change-Id: Ia54421a602367d7349df706d8f41615231b6bf32 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381384 Reviewed-by: Sigmund Cherem Commit-Queue: Nicholas Shahan --- PRESUBMIT.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 54d43973c96..41fe279b3d4 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -513,6 +513,30 @@ def _CheckNoNewObservatoryServiceTests(input_api, output_api): 'not runtime/observatory/tests/service:\n' + '\n'.join(files)) ] + +def _CheckDevCompilerSync(input_api, output_api): + """Make sure that any changes in the original and the temporary forked + version of the DDC compiler are kept in sync. If a CL touches the + compiler.dart there should probably be in a change in compiler_new.dart + as well. + """ + OLD = "pkg/dev_compiler/lib/src/kernel/compiler.dart" + NEW = "pkg/dev_compiler/lib/src/kernel/compiler_new.dart" + + files = [git_file.LocalPath() for git_file in input_api.AffectedTextFiles()] + + if (OLD in files and NEW not in files): + return [ + output_api.PresubmitPromptWarning( + "Make sure to keep the original and temporary forked versions " + "of compiler.dart in sync.\n" + "You may need to copy or adapt changes between these files:\n" + + "\n".join([OLD, NEW])) + ] + + return [] + + def _CommonChecks(input_api, output_api): results = [] results.extend(_CheckValidHostsInDEPS(input_api, output_api)) @@ -527,6 +551,7 @@ def _CommonChecks(input_api, output_api): results.extend(_CheckCopyrightYear(input_api, output_api)) results.extend(_CheckAnalyzerFiles(input_api, output_api)) results.extend(_CheckNoNewObservatoryServiceTests(input_api, output_api)) + results.extend(_CheckDevCompilerSync(input_api, output_api)) return results