OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
4 # for details. All rights reserved. Use of this source code is governed by a | 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. | 5 # BSD-style license that can be found in the LICENSE file. |
6 | 6 |
7 """ | 7 """ |
8 Pub buildbot steps. | 8 Pub buildbot steps. |
9 | 9 |
10 Runs tests for pub and the pub packages that are hosted in the main Dart repo. | 10 Runs tests for pub and the pub packages that are hosted in the main Dart repo. |
11 """ | 11 """ |
12 | 12 |
13 import os | 13 import os |
14 import re | 14 import re |
15 import shutil | |
16 import sys | |
17 | 15 |
18 import bot | 16 import bot |
19 import bot_utils | |
20 | |
21 utils = bot_utils.GetUtils() | |
22 | |
23 BUILD_OS = utils.GuessOS() | |
24 | 17 |
25 PUB_BUILDER = r'pub-(linux|mac|win)' | 18 PUB_BUILDER = r'pub-(linux|mac|win)' |
26 | 19 |
27 def PubConfig(name, is_buildbot): | 20 def PubConfig(name, is_buildbot): |
28 """Returns info for the current buildbot based on the name of the builder. | 21 """Returns info for the current buildbot based on the name of the builder. |
29 | 22 |
30 Currently, this is just: | 23 Currently, this is just: |
31 - mode: always release, we don't run pub in debug mode | 24 - mode: always release, we don't run pub in debug mode |
32 - system: "linux", "mac", or "win" | 25 - system: "linux", "mac", or "win" |
33 - checked: always true | 26 - checked: always true |
34 """ | 27 """ |
35 pub_pattern = re.match(PUB_BUILDER, name) | 28 pub_pattern = re.match(PUB_BUILDER, name) |
36 if not pub_pattern: | 29 if not pub_pattern: |
37 return None | 30 return None |
38 | 31 |
39 system = pub_pattern.group(1) | 32 system = pub_pattern.group(1) |
40 mode = 'release' | 33 mode = 'release' |
41 if system == 'win': system = 'windows' | 34 if system == 'win': system = 'windows' |
42 | 35 |
43 return bot.BuildInfo('none', 'vm', mode, system, checked=True) | 36 return bot.BuildInfo('none', 'vm', mode, system, checked=True) |
44 | 37 |
45 def Run(command): | |
46 print "Running %s" % ' '.join(command) | |
47 return bot.RunProcess(command) | |
48 | |
49 def PubSteps(build_info): | 38 def PubSteps(build_info): |
50 sdk_bin = os.path.join( | |
51 bot_utils.DART_DIR, | |
52 utils.GetBuildSdkBin(BUILD_OS, build_info.mode, build_info.arch)) | |
53 pub_script_name = 'pub.bat' if build_info.system == 'windows' else 'pub' | |
54 pub_bin = os.path.join(sdk_bin, pub_script_name) | |
55 | |
56 pub_copy = os.path.join(utils.GetBuildRoot(BUILD_OS), 'pub_copy') | |
57 pub_location = os.path.join('third_party', 'pkg', 'pub') | 39 pub_location = os.path.join('third_party', 'pkg', 'pub') |
58 | 40 |
59 with bot.BuildStep('Make copy of pub for testing'): | 41 with bot.BuildStep('Running pub tests'): |
60 print 'Removing old copy %s' % pub_copy | 42 bot.RunTestRunner(build_info, pub_location) |
61 shutil.rmtree(pub_copy, ignore_errors=True) | |
62 print 'Copying %s to %s' % (pub_location, pub_copy) | |
63 shutil.copytree(pub_location, pub_copy) | |
64 | |
65 # TODO(nweiz): add logic for testing pub. | |
66 with bot.BuildStep('Doing the magic ls'): | |
67 with utils.ChangedWorkingDirectory(pub_copy): | |
68 Run(['ls', '-l']) | |
69 | |
70 with bot.BuildStep('Running pub'): | |
71 Run([pub_bin, '--version']) | |
72 | |
73 | 43 |
74 if __name__ == '__main__': | 44 if __name__ == '__main__': |
75 bot.RunBot(PubConfig, PubSteps) | 45 bot.RunBot(PubConfig, PubSteps) |
OLD | NEW |