| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright 2011 the V8 project authors. All rights reserved. | |
| 4 # Redistribution and use in source and binary forms, with or without | |
| 5 # modification, are permitted provided that the following conditions are | |
| 6 # met: | |
| 7 # | |
| 8 # * Redistributions of source code must retain the above copyright | |
| 9 # notice, this list of conditions and the following disclaimer. | |
| 10 # * Redistributions in binary form must reproduce the above | |
| 11 # copyright notice, this list of conditions and the following | |
| 12 # disclaimer in the documentation and/or other materials provided | |
| 13 # with the distribution. | |
| 14 # * Neither the name of Google Inc. nor the names of its | |
| 15 # contributors may be used to endorse or promote products derived | |
| 16 # from this software without specific prior written permission. | |
| 17 # | |
| 18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 | |
| 30 | |
| 31 # This is a convenience script to run the existing tools/test.py script | |
| 32 # when using the gyp/make based build. | |
| 33 # It is intended as a stop-gap rather than a long-term solution. | |
| 34 | |
| 35 | |
| 36 import optparse | |
| 37 import os | |
| 38 from os.path import join, dirname, abspath | |
| 39 import subprocess | |
| 40 import sys | |
| 41 | |
| 42 | |
| 43 PROGRESS_INDICATORS = ['verbose', 'dots', 'color', 'mono'] | |
| 44 | |
| 45 | |
| 46 def BuildOptions(): | |
| 47 result = optparse.OptionParser() | |
| 48 | |
| 49 # Flags specific to this wrapper script: | |
| 50 result.add_option("--arch-and-mode", | |
| 51 help='Architecture and mode in the format "arch.mode"', | |
| 52 default=None) | |
| 53 | |
| 54 # Flags this wrapper script handles itself: | |
| 55 result.add_option("-m", "--mode", | |
| 56 help="The test modes in which to run (comma-separated)", | |
| 57 default='release,debug') | |
| 58 result.add_option("--arch", | |
| 59 help='The architectures to run tests for (comma-separated)', | |
| 60 default='ia32,x64,arm') | |
| 61 | |
| 62 # Flags that are passed on to the wrapped test.py script: | |
| 63 result.add_option("-v", "--verbose", help="Verbose output", | |
| 64 default=False, action="store_true") | |
| 65 result.add_option("-p", "--progress", | |
| 66 help="The style of progress indicator (verbose, dots, color, mono)", | |
| 67 choices=PROGRESS_INDICATORS, default="mono") | |
| 68 result.add_option("--report", help="Print a summary of the tests to be run", | |
| 69 default=False, action="store_true") | |
| 70 result.add_option("-s", "--suite", help="A test suite", | |
| 71 default=[], action="append") | |
| 72 result.add_option("-t", "--timeout", help="Timeout in seconds", | |
| 73 default=60, type="int") | |
| 74 result.add_option("--snapshot", help="Run the tests with snapshot turned on", | |
| 75 default=False, action="store_true") | |
| 76 result.add_option("--special-command", default=None) | |
| 77 result.add_option("--valgrind", help="Run tests through valgrind", | |
| 78 default=False, action="store_true") | |
| 79 result.add_option("--cat", help="Print the source of the tests", | |
| 80 default=False, action="store_true") | |
| 81 result.add_option("--warn-unused", help="Report unused rules", | |
| 82 default=False, action="store_true") | |
| 83 result.add_option("-j", help="The number of parallel tasks to run", | |
| 84 default=1, type="int") | |
| 85 result.add_option("--time", help="Print timing information after running", | |
| 86 default=False, action="store_true") | |
| 87 result.add_option("--suppress-dialogs", help="Suppress Windows dialogs for cra
shing tests", | |
| 88 dest="suppress_dialogs", default=True, action="store_true") | |
| 89 result.add_option("--no-suppress-dialogs", help="Display Windows dialogs for c
rashing tests", | |
| 90 dest="suppress_dialogs", action="store_false") | |
| 91 result.add_option("--isolates", help="Whether to test isolates", default=False
, action="store_true") | |
| 92 result.add_option("--store-unexpected-output", | |
| 93 help="Store the temporary JS files from tests that fails", | |
| 94 dest="store_unexpected_output", default=True, action="store_true") | |
| 95 result.add_option("--no-store-unexpected-output", | |
| 96 help="Deletes the temporary JS files from tests that fails", | |
| 97 dest="store_unexpected_output", action="store_false") | |
| 98 result.add_option("--stress-only", | |
| 99 help="Only run tests with --always-opt --stress-opt", | |
| 100 default=False, action="store_true") | |
| 101 result.add_option("--nostress", | |
| 102 help="Don't run crankshaft --always-opt --stress-op test", | |
| 103 default=False, action="store_true") | |
| 104 result.add_option("--crankshaft", | |
| 105 help="Run with the --crankshaft flag", | |
| 106 default=False, action="store_true") | |
| 107 result.add_option("--shard-count", | |
| 108 help="Split testsuites into this number of shards", | |
| 109 default=1, type="int") | |
| 110 result.add_option("--shard-run", | |
| 111 help="Run this shard from the split up tests.", | |
| 112 default=1, type="int") | |
| 113 result.add_option("--noprof", help="Disable profiling support", | |
| 114 default=False) | |
| 115 | |
| 116 # Flags present in the original test.py that are unsupported in this wrapper: | |
| 117 # -S [-> scons_flags] (we build with gyp/make, not scons) | |
| 118 # --no-build (always true) | |
| 119 # --build-only (always false) | |
| 120 # --build-system (always 'gyp') | |
| 121 # --simulator (always true if arch==arm, always false otherwise) | |
| 122 # --shell (automatically chosen depending on arch and mode) | |
| 123 | |
| 124 return result | |
| 125 | |
| 126 | |
| 127 def ProcessOptions(options): | |
| 128 if options.arch_and_mode != None and options.arch_and_mode != "": | |
| 129 tokens = options.arch_and_mode.split(".") | |
| 130 options.arch = tokens[0] | |
| 131 options.mode = tokens[1] | |
| 132 options.mode = options.mode.split(',') | |
| 133 for mode in options.mode: | |
| 134 if not mode in ['debug', 'release']: | |
| 135 print "Unknown mode %s" % mode | |
| 136 return False | |
| 137 options.arch = options.arch.split(',') | |
| 138 for arch in options.arch: | |
| 139 if not arch in ['ia32', 'x64', 'arm']: | |
| 140 print "Unknown architecture %s" % arch | |
| 141 return False | |
| 142 | |
| 143 return True | |
| 144 | |
| 145 | |
| 146 def PassOnOptions(options): | |
| 147 result = [] | |
| 148 if options.verbose: | |
| 149 result += ['--verbose'] | |
| 150 if options.progress != 'mono': | |
| 151 result += ['--progress=' + options.progress] | |
| 152 if options.report: | |
| 153 result += ['--report'] | |
| 154 if options.suite != []: | |
| 155 for suite in options.suite: | |
| 156 result += ['--suite=../../test/' + suite] | |
| 157 if options.timeout != 60: | |
| 158 result += ['--timeout=%s' % options.timeout] | |
| 159 if options.snapshot: | |
| 160 result += ['--snapshot'] | |
| 161 if options.special_command: | |
| 162 result += ['--special-command=' + options.special_command] | |
| 163 if options.valgrind: | |
| 164 result += ['--valgrind'] | |
| 165 if options.cat: | |
| 166 result += ['--cat'] | |
| 167 if options.warn_unused: | |
| 168 result += ['--warn-unused'] | |
| 169 if options.j != 1: | |
| 170 result += ['-j%s' % options.j] | |
| 171 if options.time: | |
| 172 result += ['--time'] | |
| 173 if not options.suppress_dialogs: | |
| 174 result += ['--no-suppress-dialogs'] | |
| 175 if options.isolates: | |
| 176 result += ['--isolates'] | |
| 177 if not options.store_unexpected_output: | |
| 178 result += ['--no-store-unexpected_output'] | |
| 179 if options.stress_only: | |
| 180 result += ['--stress-only'] | |
| 181 if options.nostress: | |
| 182 result += ['--nostress'] | |
| 183 if options.crankshaft: | |
| 184 result += ['--crankshaft'] | |
| 185 if options.shard_count != 1: | |
| 186 result += ['--shard_count=%s' % options.shard_count] | |
| 187 if options.shard_run != 1: | |
| 188 result += ['--shard_run=%s' % options.shard_run] | |
| 189 if options.noprof: | |
| 190 result += ['--noprof'] | |
| 191 return result | |
| 192 | |
| 193 | |
| 194 def Main(): | |
| 195 parser = BuildOptions() | |
| 196 (options, args) = parser.parse_args() | |
| 197 if not ProcessOptions(options): | |
| 198 parser.print_help() | |
| 199 return 1 | |
| 200 | |
| 201 workspace = abspath(join(dirname(sys.argv[0]), '..')) | |
| 202 args_for_children = [workspace + '/tools/test.py'] + PassOnOptions(options) | |
| 203 args_for_children += ['--no-build', '--build-system=gyp'] | |
| 204 for arg in args: | |
| 205 args_for_children += [arg] | |
| 206 returncodes = 0 | |
| 207 | |
| 208 for mode in options.mode: | |
| 209 for arch in options.arch: | |
| 210 print ">>> running tests for %s.%s" % (arch, mode) | |
| 211 shell = workspace + '/out/' + arch + '.' + mode + "/shell" | |
| 212 child = subprocess.Popen(' '.join(args_for_children + | |
| 213 ['--mode=' + mode] + | |
| 214 ['--shell=' + shell]), | |
| 215 shell=True, | |
| 216 cwd=workspace) | |
| 217 returncodes += child.wait() | |
| 218 | |
| 219 return returncodes | |
| 220 | |
| 221 | |
| 222 if __name__ == '__main__': | |
| 223 sys.exit(Main()) | |
| OLD | NEW |