OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # | |
3 # Copyright (c) 2011, 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 """ | |
9 Runs a Dart unit test in different configurations: dartium, chromium, ia32, x64, | |
10 arm, simarm, and dartc. Example: | |
11 | |
12 run.py --arch=dartium --mode=release --test=Test.dart | |
13 """ | |
14 | |
15 import optparse | |
16 import sys | |
17 | |
18 from testing import architecture | |
19 import utils | |
20 | |
21 | |
22 def AreOptionsValid(options): | |
23 if not options.arch in ['ia32', 'x64', 'arm', 'simarm', 'dartc', 'dartium', | |
24 'chromium', 'frogium']: | |
25 print 'Unknown arch %s' % options.arch | |
26 return None | |
27 | |
28 return options.test | |
29 | |
30 | |
31 def Flags(): | |
32 result = optparse.OptionParser() | |
33 result.add_option("-v", "--verbose", | |
34 help="Print messages", | |
35 default=False, | |
36 action="store_true") | |
37 result.add_option("-t", "--test", | |
38 help="App or Dart file containing the test", | |
39 type="string", | |
40 action="store", | |
41 default=None) | |
42 result.add_option("--arch", | |
43 help="The architecture to run tests for", | |
44 metavar="[ia32,x64,arm,simarm,dartc,chromium,dartium]", | |
45 default=utils.GuessArchitecture()) | |
46 result.add_option("-m", "--mode", | |
47 help="The test modes in which to run", | |
48 metavar='[debug,release]', | |
49 default='debug') | |
50 result.set_usage("run.py --arch ARCH --mode MODE -t TEST") | |
51 return result | |
52 | |
53 | |
54 def Main(): | |
55 parser = Flags() | |
56 (options, args) = parser.parse_args() | |
57 if not AreOptionsValid(options): | |
58 parser.print_help() | |
59 return 1 | |
60 | |
61 return architecture.GetArchitecture(options.arch, options.mode, | |
62 options.test).RunTest(options.verbose) | |
63 | |
64 | |
65 if __name__ == '__main__': | |
66 sys.exit(Main()) | |
OLD | NEW |