def test_coverage_works(self): # This is awkward; by design, running test-webkitpy -c will # create a .coverage file in tools, so we need to be # careful not to clobber an existing one, and to clean up. # FIXME: This design needs to change since it means we can't actually # run this method itself under coverage properly. filesystem = FileSystem() executive = Executive() module_path = filesystem.path_to_module(self.__module__) script_dir = module_path[0:module_path.find('webkitpy') - 1] coverage_file = filesystem.join(script_dir, '.coverage') coverage_file_orig = None if filesystem.exists(coverage_file): coverage_file_orig = coverage_file + '.orig' filesystem.move(coverage_file, coverage_file_orig) try: proc = executive.popen([sys.executable, filesystem.join(script_dir, 'test-webkitpy'), '-c', STUBS_CLASS + '.test_empty'], stdout=executive.PIPE, stderr=executive.PIPE) out, _ = proc.communicate() retcode = proc.returncode self.assertEqual(retcode, 0) self.assertIn('Cover', out) finally: if coverage_file_orig: filesystem.move(coverage_file_orig, coverage_file) elif filesystem.exists(coverage_file): filesystem.remove(coverage_file)
def load_json(self): filesystem = FileSystem() json_path = filesystem.join(filesystem.dirname(filesystem.path_to_module('webkitpy.common.config')), 'contributors.json') try: contributors = json.loads(filesystem.read_text_file(json_path)) except ValueError, e: sys.exit('contributors.json is malformed: ' + str(e))
def load_json(): filesystem = FileSystem() json_path = filesystem.join(filesystem.dirname(filesystem.path_to_module('webkitpy.common.config')), 'contributors.json') contributors = json.loads(filesystem.read_text_file(json_path)) return { 'Contributors': [Contributor(name, data.get('emails'), data.get('nicks')) for name, data in contributors['Contributors'].iteritems()], 'Committers': [Committer(name, data.get('emails'), data.get('nicks')) for name, data in contributors['Committers'].iteritems()], 'Reviewers': [Reviewer(name, data.get('emails'), data.get('nicks')) for name, data in contributors['Reviewers'].iteritems()], }
def integration_test_coverage_works(self): filesystem = FileSystem() executive = Executive() module_path = filesystem.path_to_module(self.__module__) script_dir = module_path[0:module_path.find('webkitpy') - 1] proc = executive.popen([sys.executable, filesystem.join(script_dir, 'test-webkitpy'), '-c', STUBS_CLASS + '.test_empty'], stdout=executive.PIPE, stderr=executive.PIPE) out, _ = proc.communicate() retcode = proc.returncode self.assertEqual(retcode, 0) self.assertIn('Cover', out)
def load_ews_classes(cls): filesystem = FileSystem() json_path = filesystem.join(filesystem.dirname(filesystem.path_to_module('webkitpy.common.config')), 'ews.json') try: ewses = json.loads(filesystem.read_text_file(json_path)) except ValueError: return None classes = [] for name, config in ewses.iteritems(): classes.append(type(str(name.replace(' ', '')), (AbstractEarlyWarningSystem,), { 'name': config['port'] + '-ews', 'port_name': config['port'], 'watchers': config.get('watchers', []), 'run_tests': config.get('runTests', cls.run_tests), })) return classes
def load_ews_classes(cls): filesystem = FileSystem() json_path = filesystem.join(filesystem.dirname(filesystem.path_to_module('webkitpy.common.config')), 'ews.json') try: ewses = json.loads(filesystem.read_text_file(json_path)) except ValueError: return None classes = [] for name, config in ewses.iteritems(): classes.append(type(str(name.replace(' ', '')), (AbstractEarlyWarningSystem,), { 'name': config['port'] + '-ews', 'port_name': config['port'], 'architecture': config.get('architecture', None), 'watchers': config.get('watchers', []), 'run_tests': config.get('runTests', cls.run_tests), })) return classes
def load_ews_classes(cls): filesystem = FileSystem() json_path = filesystem.join(filesystem.dirname(filesystem.path_to_module('webkitpy.common.config')), 'ews.json') try: ewses = json.loads(filesystem.read_text_file(json_path)) except ValueError: return None classes = [] for name, config in ewses.iteritems(): classes.append(type(name.encode('utf-8').translate(None, ' -'), (AbstractEarlyWarningSystem,), { 'name': config.get('name', config['port'] + '-ews'), 'port_name': config['port'], 'architecture': config.get('architecture', None), '_build_style': config.get('style', "release"), 'watchers': config.get('watchers', []), 'run_tests': config.get('runTests', cls.run_tests), })) return classes
def load_ews_classes(cls): filesystem = FileSystem() json_path = filesystem.join(filesystem.dirname(filesystem.path_to_module('webkitpy.common.config')), 'ews.json') try: ewses = json.loads(filesystem.read_text_file(json_path)) except ValueError: return None classes = [] for name, config in ewses.iteritems(): classes.append(type(name.encode('utf-8').translate(None, ' -'), (cls,), { 'name': config.get('name', config['port'] + '-ews'), 'port_name': config['port'], 'architecture': config.get('architecture', None), '_build_style': config.get('style', "release"), 'watchers': config.get('watchers', []), 'run_tests': config.get('runTests', cls.run_tests), '_group': config.get('group', None), 'should_build': config.get('shouldBuild', True), })) return classes
def load_json(): filesystem = FileSystem() json_path = filesystem.join( filesystem.dirname( filesystem.path_to_module('webkitpy.common.config')), 'contributors.json') contributors = json.loads(filesystem.read_text_file(json_path)) return { 'Contributors': [ Contributor(name, data.get('emails'), data.get('nicks')) for name, data in contributors['Contributors'].iteritems() ], 'Committers': [ Committer(name, data.get('emails'), data.get('nicks')) for name, data in contributors['Committers'].iteritems() ], 'Reviewers': [ Reviewer(name, data.get('emails'), data.get('nicks')) for name, data in contributors['Reviewers'].iteritems() ], }
def load_json(self): filesystem = FileSystem() json_path = filesystem.join( filesystem.dirname( filesystem.path_to_module('webkitpy.common.config')), 'contributors.json') try: contributors = json.loads(filesystem.read_text_file(json_path)) except ValueError as e: sys.exit('contributors.json is malformed: ' + str(e)) self._contributors = [] self._committers = [] self._reviewers = [] for name, data in contributors.items(): contributor = None status = data.get('status') if status == "reviewer": contributor = Reviewer(name, data.get('emails'), data.get('nicks'), data.get('aliases'), data.get('expertise')) self._reviewers.append(contributor) self._committers.append(contributor) elif status == "committer": contributor = Committer(name, data.get('emails'), data.get('nicks'), data.get('aliases'), data.get('expertise')) self._committers.append(contributor) elif data.get('class') == 'bot': contributor = Bot(name, data.get('emails'), data.get('nicks'), data.get('aliases'), data.get('expertise')) else: contributor = Contributor(name, data.get('emails'), data.get('nicks'), data.get('aliases'), data.get('expertise')) self._contributors.append(contributor)
def reformat_in_place(self): filesystem = FileSystem() json_path = filesystem.join(filesystem.dirname(filesystem.path_to_module('webkitpy.common.config')), 'contributors.json') filesystem.write_text_file(json_path, self.as_json())