| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 #!/usr/bin/python |  | 
| 2 |  | 
| 3 # Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file |  | 
| 4 # for details. All rights reserved. Use of this source code is governed by a |  | 
| 5 # BSD-style license that can be found in the LICENSE file. |  | 
| 6 |  | 
| 7 """ |  | 
| 8 Buildbot steps for functional testing master and slaves |  | 
| 9 """ |  | 
| 10 |  | 
| 11 import os |  | 
| 12 import os.path |  | 
| 13 import re |  | 
| 14 import shutil |  | 
| 15 import subprocess |  | 
| 16 import sys |  | 
| 17 |  | 
| 18 import bot |  | 
| 19 import bot_utils |  | 
| 20 |  | 
| 21 utils = bot_utils.GetUtils() |  | 
| 22 |  | 
| 23 FT_BUILDER = r'ft-slave-(linux|mac)' |  | 
| 24 FT_MASTER = r'ft-master' |  | 
| 25 |  | 
| 26 HOST_OS = utils.GuessOS() |  | 
| 27 |  | 
| 28 def IsWindows(): |  | 
| 29   return HOST_OS == 'win32' |  | 
| 30 |  | 
| 31 def SrcConfig(name, is_buildbot): |  | 
| 32   """Returns info for the current buildbot based on the name of the builder. |  | 
| 33 |  | 
| 34   - mode: always "release" |  | 
| 35   - system: always "linux" or "mac" |  | 
| 36   """ |  | 
| 37   pattern = re.match(FT_BUILDER, name) |  | 
| 38   master_pattern = re.match(FT_MASTER, name) |  | 
| 39   if not pattern and not master_pattern: |  | 
| 40     return None |  | 
| 41   if master_pattern: |  | 
| 42     tag = 'master' |  | 
| 43     system = 'linux' |  | 
| 44   else: |  | 
| 45     tag = 'slave' |  | 
| 46     system = pattern.group(1) |  | 
| 47   return bot.BuildInfo('none', 'none', 'release', system, |  | 
| 48                        builder_tag=tag) |  | 
| 49 |  | 
| 50 def Run(args): |  | 
| 51   print "Running: %s" % ' '.join(args) |  | 
| 52   sys.stdout.flush() |  | 
| 53   bot.RunProcess(args) |  | 
| 54 |  | 
| 55 def FTSlave(config): |  | 
| 56 |  | 
| 57   # Run SWTBot tests |  | 
| 58   if len(sys.argv) > 0: |  | 
| 59     scriptdir = os.path.dirname(sys.argv[0]) |  | 
| 60     builddir = os.path.join(scriptdir, '..', '..', 'editor', 'build') |  | 
| 61     testScript = os.path.join(builddir, 'testswteditor.py') |  | 
| 62     cmd = [sys.executable, testScript] |  | 
| 63     try: |  | 
| 64       subprocess.call(cmd, shell=IsWindows()) |  | 
| 65     except: |  | 
| 66       pass |  | 
| 67 |  | 
| 68   # Prepare to run EggPlant tests |  | 
| 69   with bot.BuildStep('Fetching editor'): |  | 
| 70     revision = int(os.environ['BUILDBOT_GOT_REVISION']) |  | 
| 71     bot_name, _ = bot.GetBotName() |  | 
| 72     print bot_name |  | 
| 73     channel = bot_utils.GetChannelFromName(bot_name) |  | 
| 74     namer = bot_utils.GCSNamer(channel=channel) |  | 
| 75     system = config.system |  | 
| 76     if system == 'mac': |  | 
| 77       system = 'macos' |  | 
| 78     editor_path = namer.editor_zipfilepath(revision, system, 'x64') |  | 
| 79     gsutils = bot_utils.GSUtil() |  | 
| 80     editor_location='/home/chrome-bot/Desktop' |  | 
| 81     if system == 'macos': |  | 
| 82       editor_location='/Users/chrome-bot/Desktop' |  | 
| 83     local_path = os.path.join(editor_location, 'editor.zip') |  | 
| 84     if os.path.exists(local_path): |  | 
| 85       os.remove(local_path) |  | 
| 86     local_extracted = os.path.join(editor_location, 'dart') |  | 
| 87     shutil.rmtree(local_extracted, ignore_errors=True) |  | 
| 88     gsutils.execute(['cp', editor_path, local_path]) |  | 
| 89     Run(['unzip', local_path, '-d', editor_location]) |  | 
| 90 |  | 
| 91 def FTMaster(config): |  | 
| 92   run = int(os.environ['BUILDBOT_ANNOTATED_STEPS_RUN']) |  | 
| 93   with bot.BuildStep('Master run %s' % run): |  | 
| 94     if run == 1: |  | 
| 95       print 'Not doing anything on master before the triggers' |  | 
| 96       return |  | 
| 97     else: |  | 
| 98       builddir = os.path.join(bot_utils.DART_DIR, |  | 
| 99                               utils.GetBuildDir(HOST_OS), |  | 
| 100                               'functional_testing') |  | 
| 101       shutil.rmtree(builddir, ignore_errors=True) |  | 
| 102       os.makedirs(builddir) |  | 
| 103       script_locations = os.path.join(bot_utils.DART_DIR, 'editor', 'ft') |  | 
| 104       Run(['/home/chrome-bot/func-test/bot-run', builddir, script_locations]) |  | 
| 105       #TODO Copy builddir to shared storage somewhere. |  | 
| 106 |  | 
| 107 def FTSteps(config): |  | 
| 108   if config.builder_tag == 'master': |  | 
| 109     FTMaster(config) |  | 
| 110   else: |  | 
| 111     FTSlave(config) |  | 
| 112 |  | 
| 113 if __name__ == '__main__': |  | 
| 114   bot.RunBot(SrcConfig, FTSteps, build_step=None) |  | 
| OLD | NEW | 
|---|