1# Copyright 2016 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5 6# Recipe which runs the Skia infra tests. 7 8 9DEPS = [ 10 'infra', 11 'recipe_engine/context', 12 'recipe_engine/path', 13 'recipe_engine/properties', 14 'recipe_engine/step', 15 'vars', 16] 17 18 19def RunSteps(api): 20 api.vars.setup() 21 22 # Run the infra tests. 23 repo_name = api.properties['repository'].split('/')[-1] 24 if repo_name.endswith('.git'): 25 repo_name = repo_name[:-len('.git')] 26 repo_root = api.path['start_dir'].join(repo_name) 27 infra_tests = repo_root.join('infra', 'bots', 'infra_tests.py') 28 29 # Merge the default environment with the Go environment. 30 env = {} 31 env.update(api.infra.go_env) 32 for k, v in api.vars.default_env.iteritems(): 33 # The PATH variable gets merged; all others get replaced. 34 if k == 'PATH': 35 # This works because the value for PATH in go_env and default_env includes 36 # the '%(PATH)s' placeholder. 37 env[k] = env[k] % {k: v} 38 else: 39 env[k] = v 40 41 with api.context(cwd=repo_root, env=env): 42 # Some tests assume that they're being run inside a git repo. 43 api.step('git init', cmd=['git', 'init']) 44 api.step('git add .', cmd=['git', 'add', '.']) 45 api.step('git commit', cmd=['git', 'commit', '-a', '-m', 'initial commit']) 46 47 # Unfortunately, the recipe tests are flaky due to file removal on Windows. 48 # Run multiple attempts. 49 last_exc = None 50 for _ in range(3): 51 try: 52 api.step('infra_tests', cmd=['python', '-u', infra_tests]) 53 break 54 except api.step.StepFailure as e: # pragma: nocover 55 last_exc = e 56 else: # pragma: nocover 57 raise last_exc 58 59def GenTests(api): 60 yield ( 61 api.test('infra_tests') + 62 api.properties(buildername='Housekeeper-PerCommit-InfraTests_Win', 63 repository='https://skia.googlesource.com/skia.git', 64 path_config='kitchen', 65 swarm_out_dir='[SWARM_OUT_DIR]') 66 ) 67