OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Dart frog buildbot steps | 7 """Dart frog buildbot steps |
8 | 8 |
9 Runs tests for the frog compiler (running on the vm or the self-hosting version) | 9 Runs tests for the frog compiler (running on the vm or the self-hosting version) |
10 """ | 10 """ |
11 | 11 |
12 import os | 12 import os |
13 import re | 13 import re |
14 import subprocess | 14 import subprocess |
15 import sys | 15 import sys |
16 | 16 |
17 BUILDER_NAME = 'BUILDBOT_BUILDERNAME' | 17 BUILDER_NAME = 'BUILDBOT_BUILDERNAME' |
18 | 18 |
19 FROG_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 19 FROG_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
20 | 20 |
21 BUILDER_PATTERN = r'(frog|frogsh|frogium)-linux-(debug|release)' | 21 BUILDER_PATTERN = r'(frog|frogsh|frogium)-(linux|mac|windows)-(debug|release)' |
22 | 22 |
23 NO_COLOR_ENV = dict(os.environ) | 23 NO_COLOR_ENV = dict(os.environ) |
24 NO_COLOR_ENV['TERM'] = 'nocolor' | 24 NO_COLOR_ENV['TERM'] = 'nocolor' |
25 | 25 |
26 def GetBuildInfo(): | 26 def GetBuildInfo(): |
27 """Returns a tuple (name, mode) where: | 27 """Returns a tuple (name, mode, system) where: |
28 - name: 'frog', 'frogsh', or None when the builder has an incorrect name | 28 - name: 'frog', 'frogsh', or None when the builder has an incorrect name |
29 - mode: 'debug' or 'release' | 29 - mode: 'debug' or 'release' |
| 30 - system: 'linux', 'mac', or 'windows' |
30 """ | 31 """ |
31 name = None | 32 name = None |
32 mode = None | 33 mode = None |
| 34 system = None |
33 builder_name = os.environ.get(BUILDER_NAME) | 35 builder_name = os.environ.get(BUILDER_NAME) |
34 if builder_name: | 36 if builder_name: |
35 pattern = re.match(BUILDER_PATTERN, builder_name) | 37 pattern = re.match(BUILDER_PATTERN, builder_name) |
36 if pattern: | 38 if pattern: |
37 name = pattern.group(1) | 39 name = pattern.group(1) |
38 mode = pattern.group(2) | 40 system = pattern.group(2) |
39 return (name, mode) | 41 mode = pattern.group(3) |
| 42 return (name, mode, system) |
40 | 43 |
41 # TODO(sigmund): delete this convertion when test.py uses the same | 44 # TODO(sigmund): delete this convertion when test.py uses the same |
42 # configuration we do here. | 45 # configuration we do here. |
43 def ConvertConfiguration(arch, mode): | 46 def ConvertConfiguration(arch, mode): |
44 ''' Convert arch/mode into modes/flags for test.py ''' | 47 ''' Convert arch/mode into modes/flags for test.py ''' |
45 # TODO(ngeoffray): do something meaningful for debug. | 48 # TODO(ngeoffray): do something meaningful for debug. |
46 testpy_mode = 'release' | 49 testpy_mode = 'release' |
47 flags = None | 50 flags = None |
48 if mode == 'debug': | 51 if mode == 'debug': |
49 flags = '--checked' | 52 flags = ['--checked'] |
50 return (testpy_mode, flags) | 53 return (testpy_mode, flags) |
51 | 54 |
52 def TestStep(name, mode, component, targets, flags): | 55 def TestStep(name, mode, component, targets, flags): |
53 print '@@@BUILD_STEP %s tests: %s@@@' % (name, component) | 56 print '@@@BUILD_STEP %s tests: %s@@@' % (name, component) |
54 if component == 'frogium': | 57 if component == 'frogium' or component == 'webdriver': |
55 cmd = ['xvfb-run'] | 58 cmd = ['xvfb-run', '-a'] |
56 else: | 59 else: |
57 cmd = [] | 60 cmd = [] |
58 | 61 |
59 cmd = (cmd | 62 cmd = (cmd |
60 + [sys.executable, | 63 + [sys.executable, |
61 '../tools/test_wrapper.py', | 64 '../tools/test_wrapper.py', |
62 '--mode=' + mode, | 65 '--mode=' + mode, |
63 '--component=' + component, | 66 '--component=' + component, |
64 '--time', | 67 '--time', |
65 '--report', | 68 '--report', |
66 '--progress=buildbot', | 69 '--progress=buildbot', |
67 '-v'] | 70 '-v'] |
68 + targets) | 71 + targets) |
69 if flags: | 72 if flags: |
70 cmd.append(flags) | 73 cmd.extend(flags) |
| 74 |
71 exit_code = subprocess.call(cmd, env=NO_COLOR_ENV) | 75 exit_code = subprocess.call(cmd, env=NO_COLOR_ENV) |
72 if exit_code != 0: | 76 if exit_code != 0: |
73 print '@@@STEP_FAILURE@@@' | 77 print '@@@STEP_FAILURE@@@' |
74 return exit_code | 78 return exit_code |
75 | 79 |
76 def TestFrog(arch, mode): | 80 def TestFrog(arch, mode, system): |
77 """ build and test frog. | 81 """ build and test frog. |
78 Args: | 82 Args: |
79 - arch: either 'frog', 'frogsh' (frog self-hosted), or 'frogium' | 83 - arch: either 'frog', 'frogsh' (frog self-hosted), or 'frogium' |
80 - mode: either 'debug' (with type checks) or 'release' (without) | 84 - mode: either 'debug' (with type checks) or 'release' (without) |
| 85 - system: either 'linux', 'mac', or 'windows' |
81 """ | 86 """ |
82 | 87 |
83 # Make sure we are in the frog directory | 88 # Make sure we are in the frog directory |
84 os.chdir(FROG_PATH) | 89 os.chdir(FROG_PATH) |
85 testpy_mode, flags = ConvertConfiguration(arch, mode) | 90 testpy_mode, flags = ConvertConfiguration(arch, mode) |
86 | 91 |
87 print '@@@BUILD_STEP build frog@@@' | 92 print '@@@BUILD_STEP build frog@@@' |
88 if subprocess.call( | 93 if subprocess.call( |
89 [sys.executable, '../tools/build.py', '--mode=' + testpy_mode], | 94 [sys.executable, '../tools/build.py', '--mode=' + testpy_mode], |
90 env=NO_COLOR_ENV) != 0: | 95 env=NO_COLOR_ENV) != 0: |
91 return 1 | 96 return 1 |
92 | 97 |
93 if arch != 'frogium': # frog and frogsh | 98 if arch != 'frogium': # frog and frogsh |
94 TestStep("frog", testpy_mode, arch, [], flags) | 99 TestStep("frog", testpy_mode, arch, [], flags) |
95 TestStep("frog_extra", testpy_mode, arch, ['frog', 'peg', 'css'], flags) | 100 TestStep("frog_extra", testpy_mode, arch, ['frog', 'peg', 'css'], flags) |
96 | 101 |
97 TestStep("leg_extra", testpy_mode, arch, ['leg', 'leg_only'], flags) | 102 TestStep("leg_extra", testpy_mode, arch, ['leg', 'leg_only'], flags) |
98 | 103 |
99 if arch == 'frogsh': | 104 if arch == 'frogsh': |
100 # There is no need to run these tests both for frog and frogsh. | 105 # There is no need to run these tests both for frog and frogsh. |
101 | 106 |
102 TestStep("leg", testpy_mode, 'leg', [], flags) | 107 TestStep("leg", testpy_mode, 'leg', [], flags) |
103 TestStep("leg_extra", testpy_mode, 'leg', ['leg_only'], flags) | 108 TestStep("leg_extra", testpy_mode, 'leg', ['leg_only'], flags) |
104 # Leg isn't self-hosted (yet) so we run the leg unit tests on the VM. | 109 # Leg isn't self-hosted (yet) so we run the leg unit tests on the VM. |
105 TestStep("leg_extra", testpy_mode, 'vm', ['leg'], flags) | 110 TestStep("leg_extra", testpy_mode, 'vm', ['leg'], flags) |
106 | 111 |
107 else: | 112 else: |
108 if (TestStep("browser", testpy_mode, 'frogium', | 113 # DumpRenderTree tests: |
109 ['client', 'language', 'corelib', 'isolate', 'frog', | 114 tests = [ |
110 'leg', 'peg', 'css'], flags) != 0): | 115 'client', 'language', 'corelib', 'isolate', 'frog', 'leg', 'peg', 'css'] |
111 return 1 | 116 TestStep("browser", testpy_mode, 'frogium', tests, flags) |
| 117 |
| 118 # Webdriver tests. |
| 119 if system == 'linux': |
| 120 browsers = ['ff', 'chrome'] |
| 121 elif system == 'mac': |
| 122 browsers = ['ff', 'chrome', 'safari'] |
| 123 else: |
| 124 browsers = ['ff', 'chrome', 'ie'] |
| 125 |
| 126 for browser in browsers: |
| 127 TestStep(browser, testpy_mode, 'webdriver', tests, |
| 128 flags + ['--browser=' + browser]) |
112 | 129 |
113 return 0 | 130 return 0 |
114 | 131 |
115 def main(): | 132 def main(): |
116 print 'main' | 133 print 'main' |
117 if len(sys.argv) == 0: | 134 if len(sys.argv) == 0: |
118 print 'Script pathname not known, giving up.' | 135 print 'Script pathname not known, giving up.' |
119 return 1 | 136 return 1 |
120 | 137 |
121 arch, mode = GetBuildInfo() | 138 arch, mode, system = GetBuildInfo() |
122 print "arch: %s, mode: %s" % (arch, mode) | 139 print "arch: %s, mode: %s, system: %s" % (arch, mode, system) |
123 if arch is None: | 140 if arch is None: |
124 return 1 | 141 return 1 |
125 | 142 |
126 status = TestFrog(arch, mode) | 143 status = TestFrog(arch, mode, system) |
127 if status != 0: | 144 if status != 0: |
128 print '@@@STEP_FAILURE@@@' | 145 print '@@@STEP_FAILURE@@@' |
129 return status | 146 return status |
130 | 147 |
131 | 148 |
132 if __name__ == '__main__': | 149 if __name__ == '__main__': |
133 sys.exit(main()) | 150 sys.exit(main()) |
OLD | NEW |