From b182750ed9edd63dbca487ace80eba44eb836221 Mon Sep 17 00:00:00 2001 From: "phajdan.jr@chromium.org" Date: Thu, 4 Feb 2016 17:41:33 +0000 Subject: [PATCH] depot_tools: add presubmit recipe module BUG=584197 Review URL: https://codereview.chromium.org/1668803002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@298588 0039d316-1c4b-4281-b951-d872f2087c98 --- recipe_modules/presubmit/__init__.py | 3 +++ recipe_modules/presubmit/api.py | 13 +++++++++++++ .../presubmit/example.expected/basic.json | 16 ++++++++++++++++ recipe_modules/presubmit/example.py | 15 +++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 recipe_modules/presubmit/__init__.py create mode 100644 recipe_modules/presubmit/api.py create mode 100644 recipe_modules/presubmit/example.expected/basic.json create mode 100755 recipe_modules/presubmit/example.py diff --git a/recipe_modules/presubmit/__init__.py b/recipe_modules/presubmit/__init__.py new file mode 100644 index 000000000..9af297e58 --- /dev/null +++ b/recipe_modules/presubmit/__init__.py @@ -0,0 +1,3 @@ +DEPS = [ + 'recipe_engine/python', +] diff --git a/recipe_modules/presubmit/api.py b/recipe_modules/presubmit/api.py new file mode 100644 index 000000000..3fbf31690 --- /dev/null +++ b/recipe_modules/presubmit/api.py @@ -0,0 +1,13 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +from recipe_engine import recipe_api + +class PresubmitApi(recipe_api.RecipeApi): + def __call__(self, *args, **kwargs): + """Return a presubmit step.""" + name = kwargs.pop('name', 'presubmit') + return self.m.python( + name, self.package_resource('presubmit_support.py'), list(args), + **kwargs) diff --git a/recipe_modules/presubmit/example.expected/basic.json b/recipe_modules/presubmit/example.expected/basic.json new file mode 100644 index 000000000..d19e769a8 --- /dev/null +++ b/recipe_modules/presubmit/example.expected/basic.json @@ -0,0 +1,16 @@ +[ + { + "cmd": [ + "python", + "-u", + "RECIPE_PACKAGE[depot_tools]/presubmit_support.py" + ], + "cwd": "[SLAVE_BUILD]", + "name": "presubmit" + }, + { + "name": "$result", + "recipe_result": null, + "status_code": 0 + } +] \ No newline at end of file diff --git a/recipe_modules/presubmit/example.py b/recipe_modules/presubmit/example.py new file mode 100755 index 000000000..1253519a3 --- /dev/null +++ b/recipe_modules/presubmit/example.py @@ -0,0 +1,15 @@ +# Copyright 2016 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +DEPS = [ + 'presubmit', +] + + +def RunSteps(api): + api.presubmit() + + +def GenTests(api): + yield api.test('basic')