@@ -262,6 +262,47 @@ def _CheckLayering(input_api, output_api):
262262 return []
263263
264264
265+ def _CheckTestPlan (input_api , output_api ):
266+ """Run test plan check.
267+
268+ Each change that touches specified directories in the checkout are required
269+ to have TEST= line explaining how this change was validated.
270+ """
271+
272+ DIRS = [
273+ 'runtime/vm' ,
274+ 'runtime/bin' ,
275+ 'runtime/lib' ,
276+ 'runtime/include' ,
277+ 'runtime/observatory' ,
278+ 'runtime/observatory_2' ,
279+ 'runtime/platform' ,
280+ 'pkg/vm' ,
281+ 'sdk/lib/_internal/vm' ,
282+ ]
283+
284+ # Run only if directory was affected.
285+ files = [f .LocalPath () for f in input_api .AffectedFiles ()]
286+ affected = filter (lambda dir : any (f .startswith (dir ) for f in files ), DIRS )
287+ if len (affected ) != 0 and input_api .change .tags .get ('TEST' , '' ) == '' :
288+ return [
289+ output_api .PresubmitError ('Change is missing TEST= line' ,
290+ long_text = """
291+ When changing files in one of the following directories you
292+ must include TEST= line at the end of your change description.
293+
294+ %s
295+
296+ This line is expected to explain in a free form the kind of testing
297+ that was performed to validate effect of the change. For example,
298+ it can list newly added tests or already existing tests which are assumed
299+ to cover the change.
300+ """ % (' ' .join (affected )))
301+ ]
302+
303+ return []
304+
305+
265306def _CheckClangTidy (input_api , output_api ):
266307 """Run clang-tidy on VM changes."""
267308
@@ -333,6 +374,7 @@ def _CommonChecks(input_api, output_api):
333374 results .extend (_CheckLayering (input_api , output_api ))
334375 results .extend (_CheckClangTidy (input_api , output_api ))
335376 results .extend (_CheckTestMatrixValid (input_api , output_api ))
377+ results .extend (_CheckTestPlan (input_api , output_api ))
336378 results .extend (
337379 input_api .canned_checks .CheckPatchFormatted (input_api , output_api ))
338380 return results
0 commit comments