def GenerateTests():
  cover_mods = []
  for mod_dir_base in recipe_util.MODULE_DIRS():
    if os.path.isdir(mod_dir_base):
      cover_mods.append(os.path.join(mod_dir_base, '*', '*api.py'))

  for recipe_path, recipe_name in recipe_loader.loop_over_recipes():
    recipe = recipe_loader.load_recipe(recipe_name)
    test_api = recipe_loader.create_test_api(recipe.DEPS)

    covers = cover_mods + [recipe_path]

    for test_data in recipe.GenTests(test_api):
      root, name = os.path.split(recipe_path)
      name = os.path.splitext(name)[0]
      expect_path = os.path.join(root, '%s.expected' % name)

      test_data.properties['recipe'] = recipe_name.replace('\\', '/')
      yield expect_tests.Test(
          '%s.%s' % (recipe_name, test_data.name),
          expect_tests.FuncCall(RunRecipe, test_data),
          expect_dir=expect_path,
          expect_base=test_data.name,
          covers=covers,
          break_funcs=(recipe.GenSteps,)
      )
Ejemplo n.º 2
0
def GenerateTests():
    cover_mods = []
    for mod_dir_base in recipe_util.MODULE_DIRS():
        if os.path.isdir(mod_dir_base):
            cover_mods.append(os.path.join(mod_dir_base, '*', '*api.py'))

    for recipe_path, recipe_name in recipe_loader.loop_over_recipes():
        recipe = recipe_loader.load_recipe(recipe_name)
        test_api = recipe_loader.create_test_api(recipe.DEPS)

        covers = cover_mods + [recipe_path]

        for test_data in recipe.GenTests(test_api):
            root, name = os.path.split(recipe_path)
            name = os.path.splitext(name)[0]
            expect_path = os.path.join(root, '%s.expected' % name)

            test_data.properties['recipe'] = recipe_name.replace('\\', '/')
            yield expect_tests.Test('%s.%s' % (recipe_name, test_data.name),
                                    expect_tests.FuncCall(
                                        RunRecipe, test_data),
                                    expect_dir=expect_path,
                                    expect_base=test_data.name,
                                    covers=covers,
                                    break_funcs=(recipe.GenSteps, ))
Ejemplo n.º 3
0
def run_steps(stream,
              build_properties,
              factory_properties,
              test_data=recipe_test_api.DisabledTestData()):
    """Returns a tuple of (status_code, steps_ran).

  Only one of these values will be set at a time. This is mainly to support the
  testing interface used by unittests/recipes_test.py.
  """
    stream.honor_zero_return_code()

    # TODO(iannucci): Stop this when blamelist becomes sane data.
    if ('blamelist_real' in build_properties
            and 'blamelist' in build_properties):
        build_properties['blamelist'] = build_properties['blamelist_real']
        del build_properties['blamelist_real']

    properties = factory_properties.copy()
    properties.update(build_properties)

    # TODO(iannucci): A much better way to do this would be to dynamically
    #   detect if the mirrors are actually available during the execution of the
    #   recipe.
    if ('use_mirror' not in properties
            and ('TESTING_MASTERNAME' in os.environ
                 or 'TESTING_SLAVENAME' in os.environ)):
        properties['use_mirror'] = False

    # It's an integration point with a new recipe engine that can run steps
    # in parallel (that is not implemented yet). Use new engine only if explicitly
    # asked by setting 'engine' property to 'ParallelRecipeEngine'.
    engine = RecipeEngine.create(stream, properties, test_data)

    # Create all API modules and an instance of top level GenSteps generator.
    # It doesn't launch any recipe code yet (generator needs to be iterated upon
    # to start executing code).
    with stream.step('setup_build') as s:
        assert 'recipe' in factory_properties
        recipe = factory_properties['recipe']
        try:
            recipe_module = recipe_loader.load_recipe(recipe)
            stream.emit('Running recipe with %s' % (properties, ))
            api = recipe_loader.create_recipe_api(recipe_module.DEPS, engine,
                                                  test_data)
            steps = recipe_module.GenSteps(api)
            assert inspect.isgenerator(steps)
            s.step_text('<br/>running recipe: "%s"' % recipe)
        except recipe_loader.NoSuchRecipe as e:
            s.step_text('<br/>recipe not found: %s' % e)
            s.step_failure()
            return RecipeExecutionResult(2, None)

    try:
        # Run the steps emitted by a recipe via the engine, emitting annotations
        # into |stream| along the way.
        return engine.run(steps)
    except BaseException:
        return engine.unhandled_exception()
Ejemplo n.º 4
0
def run_steps(stream, build_properties, factory_properties,
              test_data=recipe_test_api.DisabledTestData()):
  """Returns a tuple of (status_code, steps_ran).

  Only one of these values will be set at a time. This is mainly to support the
  testing interface used by unittests/recipes_test.py.
  """
  stream.honor_zero_return_code()

  # TODO(iannucci): Stop this when blamelist becomes sane data.
  if ('blamelist_real' in build_properties and
      'blamelist' in build_properties):
    build_properties['blamelist'] = build_properties['blamelist_real']
    del build_properties['blamelist_real']

  properties = factory_properties.copy()
  properties.update(build_properties)

  # TODO(iannucci): A much better way to do this would be to dynamically
  #   detect if the mirrors are actually available during the execution of the
  #   recipe.
  if ('use_mirror' not in properties and (
    'TESTING_MASTERNAME' in os.environ or
    'TESTING_SLAVENAME' in os.environ)):
    properties['use_mirror'] = False

  # It's an integration point with a new recipe engine that can run steps
  # in parallel (that is not implemented yet). Use new engine only if explicitly
  # asked by setting 'engine' property to 'ParallelRecipeEngine'.
  engine = RecipeEngine.create(stream, properties, test_data)

  # Create all API modules and an instance of top level GenSteps generator.
  # It doesn't launch any recipe code yet (generator needs to be iterated upon
  # to start executing code).
  with stream.step('setup_build') as s:
    assert 'recipe' in factory_properties
    recipe = factory_properties['recipe']
    try:
      recipe_module = recipe_loader.load_recipe(recipe)
      stream.emit('Running recipe with %s' % (properties,))
      api = recipe_loader.create_recipe_api(recipe_module.DEPS,
                                            engine,
                                            test_data)
      steps = recipe_module.GenSteps(api)
      assert inspect.isgenerator(steps)
      s.step_text('<br/>running recipe: "%s"' % recipe)
    except recipe_loader.NoSuchRecipe as e:
      s.step_text('<br/>recipe not found: %s' % e)
      s.step_failure()
      return RecipeExecutionResult(2, None)

  try:
    # Run the steps emitted by a recipe via the engine, emitting annotations
    # into |stream| along the way.
    return engine.run(steps)
  except BaseException:
    return engine.unhandled_exception()
Ejemplo n.º 5
0
def GenerateTests():
  for recipe_path, recipe_name in recipe_loader.loop_over_recipes():
    recipe = recipe_loader.load_recipe(recipe_name)
    test_api = recipe_loader.create_test_api(recipe.DEPS)
    for test_data in recipe.GenTests(test_api):
      root, name = os.path.split(recipe_path)
      name = os.path.splitext(name)[0]
      expect_path = os.path.join(root, '%s.expected' % name)

      test_data.properties['recipe'] = recipe_name.replace('\\', '/')
      yield expect_tests.Test(
          '%s.%s' % (recipe_name, test_data.name),
          RunRecipe, args=(test_data,),
          expect_dir=expect_path,
          expect_base=test_data.name,
          break_funcs=(recipe.GenSteps,)
      )
Ejemplo n.º 6
0
def GenerateTests():
    for recipe_path, recipe_name in recipe_loader.loop_over_recipes():
        recipe = recipe_loader.load_recipe(recipe_name)
        test_api = recipe_loader.create_test_api(recipe.DEPS)
        for test_data in recipe.GenTests(test_api):
            root, name = os.path.split(recipe_path)
            name = os.path.splitext(name)[0]
            expect_path = os.path.join(root, "%s.expected" % name)

            test_data.properties["recipe"] = recipe_name.replace("\\", "/")
            yield expect_tests.Test(
                "%s.%s" % (recipe_name, test_data.name),
                RunRecipe,
                args=(test_data,),
                expect_dir=expect_path,
                expect_base=test_data.name,
                break_funcs=(recipe.GenSteps,),
            )
Ejemplo n.º 7
0
def run_steps(stream,
              build_properties,
              factory_properties,
              test_data=recipe_test_api.DisabledTestData()):
    """Returns a tuple of (status_code, steps_ran).

  Only one of these values will be set at a time. This is mainly to support the
  testing interface used by unittests/recipes_test.py.
  """
    stream.honor_zero_return_code()

    # TODO(iannucci): Stop this when blamelist becomes sane data.
    if ('blamelist_real' in build_properties
            and 'blamelist' in build_properties):
        build_properties['blamelist'] = build_properties['blamelist_real']
        del build_properties['blamelist_real']

    properties = factory_properties.copy()
    properties.update(build_properties)

    # TODO(iannucci): A much better way to do this would be to dynamically
    #   detect if the mirrors are actually available during the execution of the
    #   recipe.
    if ('use_mirror' not in properties
            and ('TESTING_MASTERNAME' in os.environ
                 or 'TESTING_SLAVENAME' in os.environ)):
        properties['use_mirror'] = False

    # It's an integration point with a new recipe engine that can run steps
    # in parallel (that is not implemented yet). Use new engine only if explicitly
    # asked by setting 'engine' property to 'ParallelRecipeEngine'.
    engine = RecipeEngine.create(stream, properties, test_data)

    # Create all API modules and an instance of top level GenSteps generator.
    # It doesn't launch any recipe code yet (generator needs to be iterated upon
    # to start executing code).
    api = None
    with stream.step('setup_build') as s:
        assert 'recipe' in factory_properties
        recipe = factory_properties['recipe']

        properties_to_print = properties.copy()
        if 'use_mirror' in properties:
            del properties_to_print['use_mirror']

        run_recipe_help_lines = [
            'To repro this locally, run the following line from a build checkout:',
            '',
            './scripts/tools/run_recipe.py %s --properties-file - <<EOF' %
            recipe,
            repr(properties_to_print),
            'EOF',
            '',
            'To run on Windows, you can put the JSON in a file and redirect the',
            'contents of the file into run_recipe.py, with the < operator.',
        ]

        for line in run_recipe_help_lines:
            s.step_log_line('run_recipe', line)
        s.step_log_end('run_recipe')

        try:
            recipe_module = recipe_loader.load_recipe(recipe)
            stream.emit('Running recipe with %s' % (properties, ))
            api = recipe_loader.create_recipe_api(recipe_module.DEPS, engine,
                                                  test_data)
            steps = recipe_module.GenSteps
            s.step_text('<br/>running recipe: "%s"' % recipe)
        except recipe_loader.NoSuchRecipe as e:
            s.step_text('<br/>recipe not found: %s' % e)
            s.step_failure()
            return RecipeExecutionResult(2, None)

    # Run the steps emitted by a recipe via the engine, emitting annotations
    # into |stream| along the way.
    return engine.run(steps, api)