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

Side by Side Diff: Tools/Scripts/webkitpy/test/main_unittest.py

Issue 458643003: Remove serial test support from test-webkitpy. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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) 2012 Google, Inc. 1 # Copyright (C) 2012 Google, Inc.
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 4 # modification, are permitted provided that the following conditions
5 # are met: 5 # are met:
6 # 1. Redistributions of source code must retain the above copyright 6 # 1. Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright 8 # 2. Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the 9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution. 10 # documentation and/or other materials provided with the distribution.
(...skipping 20 matching lines...) Expand all
31 from webkitpy.test.main import Tester, _Loader 31 from webkitpy.test.main import Tester, _Loader
32 32
33 33
34 STUBS_CLASS = __name__ + ".TestStubs" 34 STUBS_CLASS = __name__ + ".TestStubs"
35 35
36 36
37 class TestStubs(unittest.TestCase): 37 class TestStubs(unittest.TestCase):
38 def test_empty(self): 38 def test_empty(self):
39 pass 39 pass
40 40
41 def serial_test_empty(self):
42 pass
43
44 41
45 class TesterTest(unittest.TestCase): 42 class TesterTest(unittest.TestCase):
46 43
47 def test_no_tests_found(self): 44 def test_no_tests_found(self):
48 tester = Tester() 45 tester = Tester()
49 errors = StringIO.StringIO() 46 errors = StringIO.StringIO()
50 47
51 # Here we need to remove any existing log handlers so that they 48 # Here we need to remove any existing log handlers so that they
52 # don't log the messages webkitpy.test while we're testing it. 49 # don't log the messages webkitpy.test while we're testing it.
53 root_logger = logging.getLogger() 50 root_logger = logging.getLogger()
(...skipping 16 matching lines...) Expand all
70 self.assertIn('No tests to run', errors.getvalue()) 67 self.assertIn('No tests to run', errors.getvalue())
71 self.assertIn('No tests to run', logs) 68 self.assertIn('No tests to run', logs)
72 69
73 def _find_test_names(self, args): 70 def _find_test_names(self, args):
74 tester = Tester() 71 tester = Tester()
75 tester._options, args = tester._parse_args(args) 72 tester._options, args = tester._parse_args(args)
76 return tester._test_names(_Loader(), args) 73 return tester._test_names(_Loader(), args)
77 74
78 def test_individual_names_are_not_run_twice(self): 75 def test_individual_names_are_not_run_twice(self):
79 args = [STUBS_CLASS + '.test_empty'] 76 args = [STUBS_CLASS + '.test_empty']
80 parallel_tests, serial_tests = self._find_test_names(args) 77 tests = self._find_test_names(args)
81 self.assertEqual(parallel_tests, args) 78 self.assertEqual(tests, args)
82 self.assertEqual(serial_tests, [])
83 79
84 def test_coverage_works(self): 80 def test_coverage_works(self):
85 # This is awkward; by design, running test-webkitpy -c will 81 # This is awkward; by design, running test-webkitpy -c will
86 # create a .coverage file in Tools/Scripts, so we need to be 82 # create a .coverage file in Tools/Scripts, so we need to be
87 # careful not to clobber an existing one, and to clean up. 83 # careful not to clobber an existing one, and to clean up.
88 # FIXME: This design needs to change since it means we can't actually 84 # FIXME: This design needs to change since it means we can't actually
89 # run this method itself under coverage properly. 85 # run this method itself under coverage properly.
90 filesystem = FileSystem() 86 filesystem = FileSystem()
91 executive = Executive() 87 executive = Executive()
92 module_path = filesystem.path_to_module(self.__module__) 88 module_path = filesystem.path_to_module(self.__module__)
93 script_dir = module_path[0:module_path.find('webkitpy') - 1] 89 script_dir = module_path[0:module_path.find('webkitpy') - 1]
94 coverage_file = filesystem.join(script_dir, '.coverage') 90 coverage_file = filesystem.join(script_dir, '.coverage')
95 coverage_file_orig = None 91 coverage_file_orig = None
96 if filesystem.exists(coverage_file): 92 if filesystem.exists(coverage_file):
97 coverage_file_orig = coverage_file + '.orig' 93 coverage_file_orig = coverage_file + '.orig'
98 filesystem.move(coverage_file, coverage_file_orig) 94 filesystem.move(coverage_file, coverage_file_orig)
99 95
100 try: 96 try:
101 proc = executive.popen([sys.executable, filesystem.join(script_dir, 'test-webkitpy'), '-c', STUBS_CLASS + '.test_empty'], 97 proc = executive.popen([sys.executable, filesystem.join(script_dir, 'test-webkitpy'), '-c', STUBS_CLASS + '.test_empty'],
102 stdout=executive.PIPE, stderr=executive.PIPE) 98 stdout=executive.PIPE, stderr=executive.PIPE)
103 out, _ = proc.communicate() 99 out, _ = proc.communicate()
104 retcode = proc.returncode 100 retcode = proc.returncode
105 self.assertEqual(retcode, 0) 101 self.assertEqual(retcode, 0)
106 self.assertIn('Cover', out) 102 self.assertIn('Cover', out)
107 finally: 103 finally:
108 if coverage_file_orig: 104 if coverage_file_orig:
109 filesystem.move(coverage_file_orig, coverage_file) 105 filesystem.move(coverage_file_orig, coverage_file)
110 elif filesystem.exists(coverage_file): 106 elif filesystem.exists(coverage_file):
111 filesystem.remove(coverage_file) 107 filesystem.remove(coverage_file)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698