Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(865)

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/port/factory.py

Issue 546133003: Reformat webkitpy.layout_tests w/ format-webkitpy. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (C) 2010 Google Inc. All rights reserved. 1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 20 matching lines...) Expand all
31 import fnmatch 31 import fnmatch
32 import optparse 32 import optparse
33 import re 33 import re
34 34
35 from webkitpy.layout_tests.port import builders 35 from webkitpy.layout_tests.port import builders
36 36
37 37
38 def platform_options(use_globs=False): 38 def platform_options(use_globs=False):
39 return [ 39 return [
40 optparse.make_option('--platform', action='store', 40 optparse.make_option('--platform', action='store',
41 help=('Glob-style list of platform/ports to use (e.g., "mac*")' if u se_globs else 'Platform to use (e.g., "mac-lion")')), 41 help=('Glob-style list of platform/ports to use (e. g., "mac*")' if use_globs else 'Platform to use (e.g., "mac-lion")')),
42 42
43 # FIXME: Update run_webkit_tests.sh, any other callers to no longer pass --chromium, then remove this flag. 43 # FIXME: Update run_webkit_tests.sh, any other callers to no longer pass --chromium, then remove this flag.
44 optparse.make_option('--chromium', action='store_const', dest='platform' , 44 optparse.make_option('--chromium', action='store_const', dest='platform' ,
45 const=('chromium*' if use_globs else 'chromium'), 45 const=('chromium*' if use_globs else 'chromium'),
46 help=('Alias for --platform=chromium*' if use_globs else 'Alias for --platform=chromium')), 46 help=('Alias for --platform=chromium*' if use_globs else 'Alias for --platform=chromium')),
47 47
48 optparse.make_option('--android', action='store_const', dest='platform', 48 optparse.make_option('--android', action='store_const', dest='platform',
49 const=('android*' if use_globs else 'android'), 49 const=('android*' if use_globs else 'android'),
50 help=('Alias for --platform=android*' if use_globs else 'Alias for - -platform=android')), 50 help=('Alias for --platform=android*' if use_globs else 'Alias for --platform=android')),
51 ] 51 ]
52 52
53 53
54 def configuration_options(): 54 def configuration_options():
55 return [ 55 return [
56 optparse.make_option("-t", "--target", dest="configuration", 56 optparse.make_option('-t', '--target', dest='configuration',
57 help="specify the target configuration to use (Debu g/Release)"), 57 help='specify the target configuration to use (Debu g/Release)'),
58 optparse.make_option('--debug', action='store_const', const='Debug', des t="configuration", 58 optparse.make_option('--debug', action='store_const', const='Debug', des t='configuration',
59 help='Set the configuration to Debug'), 59 help='Set the configuration to Debug'),
60 optparse.make_option('--release', action='store_const', const='Release', dest="configuration", 60 optparse.make_option('--release', action='store_const', const='Release', dest='configuration',
61 help='Set the configuration to Release'), 61 help='Set the configuration to Release'),
62 ] 62 ]
63
64 63
65 64
66 def _builder_options(builder_name): 65 def _builder_options(builder_name):
67 configuration = "Debug" if re.search(r"[d|D](ebu|b)g", builder_name) else "R elease" 66 configuration = 'Debug' if re.search(r"[d|D](ebu|b)g", builder_name) else 'R elease'
68 is_webkit2 = builder_name.find("WK2") != -1 67 is_webkit2 = builder_name.find('WK2') != -1
69 builder_name = builder_name 68 builder_name = builder_name
70 return optparse.Values({'builder_name': builder_name, 'configuration': confi guration}) 69 return optparse.Values({'builder_name': builder_name, 'configuration': confi guration})
71 70
72 71
73 class PortFactory(object): 72 class PortFactory(object):
74 PORT_CLASSES = ( 73 PORT_CLASSES = (
75 'android.AndroidPort', 74 'android.AndroidPort',
76 'linux.LinuxPort', 75 'linux.LinuxPort',
77 'mac.MacPort', 76 'mac.MacPort',
78 'win.WinPort', 77 'win.WinPort',
(...skipping 22 matching lines...) Expand all
101 100
102 # FIXME(steveblock): There's no longer any need to pass '--platform 101 # FIXME(steveblock): There's no longer any need to pass '--platform
103 # chromium' on the command line so we can remove this logic. 102 # chromium' on the command line so we can remove this logic.
104 if port_name == 'chromium': 103 if port_name == 'chromium':
105 port_name = self._host.platform.os_name 104 port_name = self._host.platform.os_name
106 105
107 if 'browser_test' in port_name: 106 if 'browser_test' in port_name:
108 module_name, class_name = port_name.rsplit('.', 1) 107 module_name, class_name = port_name.rsplit('.', 1)
109 module = __import__(module_name, globals(), locals(), [], -1) 108 module = __import__(module_name, globals(), locals(), [], -1)
110 port_class_name = module.get_port_class_name(class_name) 109 port_class_name = module.get_port_class_name(class_name)
111 if port_class_name != None: 110 if port_class_name is not None:
112 cls = module.__dict__[port_class_name] 111 cls = module.__dict__[port_class_name]
113 port_name = cls.determine_full_port_name(self._host, options, cl ass_name) 112 port_name = cls.determine_full_port_name(self._host, options, cl ass_name)
114 return cls(self._host, port_name, options=options, **kwargs) 113 return cls(self._host, port_name, options=options, **kwargs)
115 else: 114 else:
116 for port_class in self.PORT_CLASSES: 115 for port_class in self.PORT_CLASSES:
117 module_name, class_name = port_class.rsplit('.', 1) 116 module_name, class_name = port_class.rsplit('.', 1)
118 module = __import__(module_name, globals(), locals(), [], -1) 117 module = __import__(module_name, globals(), locals(), [], -1)
119 cls = module.__dict__[class_name] 118 cls = module.__dict__[class_name]
120 if port_name.startswith(cls.port_name): 119 if port_name.startswith(cls.port_name):
121 port_name = cls.determine_full_port_name(self._host, options , port_name) 120 port_name = cls.determine_full_port_name(self._host, options , port_name)
122 return cls(self._host, port_name, options=options, **kwargs) 121 return cls(self._host, port_name, options=options, **kwargs)
123 raise NotImplementedError('unsupported platform: "%s"' % port_name) 122 raise NotImplementedError('unsupported platform: "%s"' % port_name)
124 123
125 def all_port_names(self, platform=None): 124 def all_port_names(self, platform=None):
126 """Return a list of all valid, fully-specified, "real" port names. 125 """Return a list of all valid, fully-specified, "real" port names.
127 126
128 This is the list of directories that are used as actual baseline_paths() 127 This is the list of directories that are used as actual baseline_paths()
129 by real ports. This does not include any "fake" names like "test" 128 by real ports. This does not include any "fake" names like "test"
130 or "mock-mac", and it does not include any directories that are not. 129 or "mock-mac", and it does not include any directories that are not.
131 130
132 If platform is not specified, we will glob-match all ports""" 131 If platform is not specified, we will glob-match all ports"""
133 platform = platform or '*' 132 platform = platform or '*'
134 return fnmatch.filter(builders.all_port_names(), platform) 133 return fnmatch.filter(builders.all_port_names(), platform)
135 134
136 def get_from_builder_name(self, builder_name): 135 def get_from_builder_name(self, builder_name):
137 port_name = builders.port_name_for_builder_name(builder_name) 136 port_name = builders.port_name_for_builder_name(builder_name)
138 assert port_name, "unrecognized builder name '%s'" % builder_name 137 assert port_name, "unrecognized builder name '%s'" % builder_name
139 return self.get(port_name, _builder_options(builder_name)) 138 return self.get(port_name, _builder_options(builder_name))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698