Add an an implicit check() that the step exists when getting an item from the steps dictionary.

Whereas before to avoid a potential KeyError when attempting to access information for a given
step you would want to do something similar to:
def my_check_fn(check, steps_dict, step):
  step_present = check(step in steps_dict)
  if step_present:
    check('--my-flag' in steps_dict[step]['cmd'])

You can now simply do:
def my_check_fn(check, steps_dict, step):
  check('--my-flag' in steps_dict[step]['cmd'])

If step is not in steps_dict, the execution of the function will stop and the test will fail
with a check failure similar to:
      .../recipes-py/recipe_modules/my_module/tests/ - my_check_fn()
        `check(('--my-flag' in steps_dict[step]['cmd']))`
      .../recipes-py/recipe_engine/internal/ - __getitem__()
        `step_present = check((step in steps_dict))`
          step: 'foo'
          steps_dict.keys(): ['$result', 'InfraFailure', 'infra failure']
      added .../infra/recipes-py/recipe_modules/my_module/tests/

Bug: 939115
Change-Id: Id8f33c7ee7618133026c875ad3aa0d494bab127d
Commit-Queue: Garrett Beaty <>
Reviewed-by: Robbie Iannucci <>
6 files changed
tree: b10600f2f9ee58f6c4f2e3d11adab9ddd8d59793
  1. .gitattributes
  2. .gitignore
  3. .vpython
  11. codereview.settings
  12. doc/
  13. infra/
  14. misc/
  15. recipe_engine/
  16. recipe_modules/
  17. recipe_proto/
  19. recipes/
  20. unittests/


Recipes are a domain-specific language (embedded in python) for specifying sequences of subprocess calls in a cross-platform and testable way.



    This file!

  • doc/

    Documentation for the recipe engine (including this file!). See the design doc for more detailed design information about the recipe engine.

  • infra/

    Chrome infra config files.


    The main entry point to the recipe engine. It has many subcommands and flags; run -h to see them. Include this in your repository to start using recipes.

  • recipes/

    Recipes in the recipe engine. These are either example recipes, or recipes which are used to test the engine (see to see these run)

  • recipe_modules/

    Built in recipe modules. These are very useful when writing recipes; take a look in there, and look at each of their examples subfolders to get an idea how to use them in a recipe.

  • recipe_engine/

    The core functionality of the recipe engine. Noteworthy files include:

    • -- The main entrypoint for the recipe engine.
    • recipes_cfg.proto -- The protobuf file which defines the format of a recipes.cfg file.
    • third_party/ -- third_party code which is vendored into the recipe engine.
    • -- The api exposed to a recipe module.
    • unittests -- Unittests for the engine.

    There are also several files which correspond to a subcommand of; run, and autoroll are some examples.

  • unittests/

    Somewhat poorly named, these are higher level integration tests.


  • Sign the Google CLA.
  • Make sure your and are configured in git config.

Run the following to setup the code review tool and create your first review:

git clone $HOME/src/depot_tools
export PATH="$PATH:$HOME/src/depot_tools"
git checkout -b work origin/master

# hack hack

git commit -a -m "This is awesome"
# This will ask for your Google Account credentials.
git cl upload -s -r
# Wait for approval over email.
# Click "Submit to CQ" button or ask reviewer to do it for you.
# Wait for the change to be tested and landed automatically.

Use git cl help and git cl help <cmd> for more details.