blob: 1da629255266924cd949bdce37a2a63f75c5f0cf [file] [log] [blame]
smut64cb9422016-05-07 00:24:201#!/usr/bin/python
2# Copyright 2016 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""Unittests for test_runner.py."""
7
8import collections
Eric Aleshire97b368c92018-10-12 18:09:099import glob
smut64cb9422016-05-07 00:24:2010import os
Eric Aleshire97b368c92018-10-12 18:09:0911import subprocess
smut64cb9422016-05-07 00:24:2012import unittest
13
14import test_runner
15
16
17class TestCase(unittest.TestCase):
18 """Test case which supports installing mocks. Uninstalls on tear down."""
19
20 def __init__(self, *args, **kwargs):
21 """Initializes a new instance of this class."""
22 super(TestCase, self).__init__(*args, **kwargs)
23
24 # Maps object to a dict which maps names of mocked members to their
25 # original values.
26 self._mocks = collections.OrderedDict()
27
28 def mock(self, obj, member, mock):
29 """Installs mock in place of the named member of the given obj.
30
31 Args:
32 obj: Any object.
33 member: String naming the attribute of the object to mock.
34 mock: The mock to install.
35 """
36 self._mocks.setdefault(obj, collections.OrderedDict()).setdefault(
37 member, getattr(obj, member))
38 setattr(obj, member, mock)
39
40 def tearDown(self, *args, **kwargs):
41 """Uninstalls mocks."""
42 super(TestCase, self).tearDown(*args, **kwargs)
43
44 for obj in self._mocks:
45 for member, original_value in self._mocks[obj].iteritems():
46 setattr(obj, member, original_value)
47
48
49class GetKIFTestFilterTest(TestCase):
50 """Tests for test_runner.get_kif_test_filter."""
51
52 def test_correct(self):
53 """Ensures correctness of filter."""
54 tests = [
55 'KIF.test1',
56 'KIF.test2',
57 ]
58 expected = 'NAME:test1|test2'
59
60 self.assertEqual(test_runner.get_kif_test_filter(tests), expected)
61
62 def test_correct_inverted(self):
63 """Ensures correctness of inverted filter."""
64 tests = [
65 'KIF.test1',
66 'KIF.test2',
67 ]
68 expected = '-NAME:test1|test2'
69
70 self.assertEqual(
71 test_runner.get_kif_test_filter(tests, invert=True), expected)
72
73
74class GetGTestFilterTest(TestCase):
75 """Tests for test_runner.get_gtest_filter."""
76
77 def test_correct(self):
78 """Ensures correctness of filter."""
79 tests = [
80 'test.1',
81 'test.2',
82 ]
83 expected = 'test.1:test.2'
84
85 self.assertEqual(test_runner.get_gtest_filter(tests), expected)
86
87 def test_correct_inverted(self):
88 """Ensures correctness of inverted filter."""
89 tests = [
90 'test.1',
91 'test.2',
92 ]
93 expected = '-test.1:test.2'
94
95 self.assertEqual(
96 test_runner.get_gtest_filter(tests, invert=True), expected)
97
98
Sergey Berezin1f457882017-11-20 21:05:3999class InstallXcodeTest(TestCase):
100 """Tests install_xcode."""
101
102 def setUp(self):
103 super(InstallXcodeTest, self).setUp()
104 self.mock(test_runner, 'xcode_select', lambda _: None)
105 self.mock(os.path, 'exists', lambda _: True)
106
107 def test_success(self):
108 self.assertTrue(test_runner.install_xcode('test_build', 'true', 'path'))
109
110 def test_failure(self):
111 self.assertFalse(test_runner.install_xcode('test_build', 'false', 'path'))
112
113
smut64cb9422016-05-07 00:24:20114class SimulatorTestRunnerTest(TestCase):
115 """Tests for test_runner.SimulatorTestRunner."""
116
Sergey Berezin1f457882017-11-20 21:05:39117 def setUp(self):
118 super(SimulatorTestRunnerTest, self).setUp()
119
120 def install_xcode(build, mac_toolchain_cmd, xcode_app_path):
smut64cb9422016-05-07 00:24:20121 return True
122
Sergey Berezin7f9b4bf2018-05-21 19:49:07123 self.mock(test_runner, 'get_current_xcode_info', lambda: {
Sergey Berezin8263e5f2017-11-29 22:51:36124 'version': 'test version', 'build': 'test build', 'path': 'test/path'})
Sergey Berezin1f457882017-11-20 21:05:39125 self.mock(test_runner, 'install_xcode', install_xcode)
126 self.mock(test_runner.subprocess, 'check_output',
127 lambda _: 'fake-bundle-id')
128 self.mock(os.path, 'abspath', lambda path: '/abs/path/to/%s' % path)
129 self.mock(os.path, 'exists', lambda _: True)
Eric Aleshiref22c7efb2019-02-04 23:41:26130 self.mock(test_runner.TestRunner, 'set_sigterm_handler',
131 lambda self, handler: 0)
smut64cb9422016-05-07 00:24:20132
Sergey Berezin1f457882017-11-20 21:05:39133 def test_app_not_found(self):
134 """Ensures AppNotFoundError is raised."""
smut64cb9422016-05-07 00:24:20135
Sergey Berezin1f457882017-11-20 21:05:39136 self.mock(os.path, 'exists', lambda p: not p.endswith('fake-app'))
smut64cb9422016-05-07 00:24:20137
Sergey Berezin1f457882017-11-20 21:05:39138 with self.assertRaises(test_runner.AppNotFoundError):
139 test_runner.SimulatorTestRunner(
smut64cb9422016-05-07 00:24:20140 'fake-app',
141 'fake-iossim',
142 'platform',
143 'os',
144 'xcode-version',
Sergey Berezin1f457882017-11-20 21:05:39145 '', # Empty xcode-build
smut64cb9422016-05-07 00:24:20146 'out-dir',
Sergey Berezin1f457882017-11-20 21:05:39147 )
smut64cb9422016-05-07 00:24:20148
149 def test_iossim_not_found(self):
150 """Ensures SimulatorNotFoundError is raised."""
Sergey Berezin1f457882017-11-20 21:05:39151 self.mock(os.path, 'exists', lambda p: not p.endswith('fake-iossim'))
smut64cb9422016-05-07 00:24:20152
Sergey Berezin1f457882017-11-20 21:05:39153 with self.assertRaises(test_runner.SimulatorNotFoundError):
154 test_runner.SimulatorTestRunner(
smut64cb9422016-05-07 00:24:20155 'fake-app',
156 'fake-iossim',
157 'platform',
158 'os',
159 'xcode-version',
Sergey Berezin1f457882017-11-20 21:05:39160 'xcode-build',
smut64cb9422016-05-07 00:24:20161 'out-dir',
Sergey Berezin1f457882017-11-20 21:05:39162 )
smut64cb9422016-05-07 00:24:20163
164 def test_init(self):
165 """Ensures instance is created."""
smut64cb9422016-05-07 00:24:20166 tr = test_runner.SimulatorTestRunner(
167 'fake-app',
168 'fake-iossim',
169 'platform',
170 'os',
171 'xcode-version',
Sergey Berezin1f457882017-11-20 21:05:39172 'xcode-build',
smut64cb9422016-05-07 00:24:20173 'out-dir',
174 )
175
Sergey Berezin1f457882017-11-20 21:05:39176 self.assertTrue(tr)
smut64cb9422016-05-07 00:24:20177
178 def test_startup_crash(self):
179 """Ensures test is relaunched once on startup crash."""
smut64cb9422016-05-07 00:24:20180 def set_up(self):
181 return
182
183 @staticmethod
Menglu Huang89909a8e2018-02-21 00:06:42184 def _run(cmd, shards=None):
smut64cb9422016-05-07 00:24:20185 return collections.namedtuple('result', ['crashed', 'crashed_test'])(
186 crashed=True, crashed_test=None)
187
188 def tear_down(self):
189 return
190
smut64cb9422016-05-07 00:24:20191 self.mock(test_runner.SimulatorTestRunner, 'set_up', set_up)
192 self.mock(test_runner.TestRunner, '_run', _run)
193 self.mock(test_runner.SimulatorTestRunner, 'tear_down', tear_down)
194
195 tr = test_runner.SimulatorTestRunner(
196 'fake-app',
197 'fake-iossim',
198 'platform',
199 'os',
200 'xcode-version',
Sergey Berezin1f457882017-11-20 21:05:39201 'xcode-build',
smut64cb9422016-05-07 00:24:20202 'out-dir',
203 )
Sergey Berezin1f457882017-11-20 21:05:39204 with self.assertRaises(test_runner.AppLaunchError):
205 tr.launch()
smut64cb9422016-05-07 00:24:20206
Menglu Huang89909a8e2018-02-21 00:06:42207 def test_run(self):
208 """Ensures the _run method is correct with test sharding."""
209 def shard_xctest(object_path, shards, test_cases=None):
210 return [['a/1', 'b/2'], ['c/3', 'd/4'], ['e/5']]
211
212 def run_tests(self, test_shard=None):
213 out = []
214 for test in test_shard:
215 testname = test.split('/')
216 out.append('Test Case \'-[%s %s]\' started.' %
217 (testname[0], testname[1]))
218 out.append('Test Case \'-[%s %s]\' passed (0.1 seconds)' %
219 (testname[0], testname[1]))
220 return (out, 0, 0)
221
222 tr = test_runner.SimulatorTestRunner(
223 'fake-app',
224 'fake-iossim',
225 'platform',
226 'os',
227 'xcode-version',
228 'xcode-build',
229 'out-dir',
230 )
231 self.mock(test_runner, 'shard_xctest', shard_xctest)
232 self.mock(test_runner.SimulatorTestRunner, 'run_tests', run_tests)
233
234 tr.xctest_path = 'fake.xctest'
235 cmd = tr.get_launch_command()
236 result = tr._run(cmd=cmd, shards=3)
237 self.assertIn('a/1', result.passed_tests)
238 self.assertIn('b/2', result.passed_tests)
239 self.assertIn('c/3', result.passed_tests)
240 self.assertIn('d/4', result.passed_tests)
241 self.assertIn('e/5', result.passed_tests)
242
Menglu Huangeb4d7572018-05-21 18:37:58243 def test_run_with_system_alert(self):
244 """Ensures SystemAlertPresentError is raised when warning 'System alert
245 view is present, so skipping all tests' is in the output."""
246 with self.assertRaises(test_runner.SystemAlertPresentError):
247 tr = test_runner.SimulatorTestRunner(
248 'fake-app',
249 'fake-iossim',
250 'platform',
251 'os',
252 'xcode-version',
253 'xcode-build',
254 'out-dir',
255 )
256 tr.xctest_path = 'fake.xctest'
257 cmd = ['echo', 'System alert view is present, so skipping all tests!']
258 result = tr._run(cmd=cmd)
259
Menglu Huang0f569612017-12-08 06:35:07260 def test_get_launch_command(self):
Menglu Huang89909a8e2018-02-21 00:06:42261 """Ensures launch command is correct with test_filters, test sharding and
262 test_cases."""
Menglu Huang0f569612017-12-08 06:35:07263 tr = test_runner.SimulatorTestRunner(
264 'fake-app',
265 'fake-iossim',
266 'platform',
267 'os',
268 'xcode-version',
269 'xcode-build',
270 'out-dir',
271 )
272 tr.xctest_path = 'fake.xctest'
273 # Cases test_filter is not empty, with empty/non-empty self.test_cases.
274 tr.test_cases = []
275 cmd = tr.get_launch_command(['a'], invert=False)
276 self.assertIn('-t', cmd)
277 self.assertIn('a', cmd)
278
279 tr.test_cases = ['a', 'b']
280 cmd = tr.get_launch_command(['a'], invert=False)
281 self.assertIn('-t', cmd)
282 self.assertIn('a', cmd)
283 self.assertNotIn('b', cmd)
284
285 # Cases test_filter is empty, with empty/non-empty self.test_cases.
286 tr.test_cases = []
287 cmd = tr.get_launch_command(test_filter=None, invert=False)
288 self.assertNotIn('-t', cmd)
289
290 tr.test_cases = ['a', 'b']
291 cmd = tr.get_launch_command(test_filter=None, invert=False)
292 self.assertIn('-t', cmd)
293 self.assertIn('a', cmd)
294 self.assertIn('b', cmd)
295
smut64cb9422016-05-07 00:24:20296 def test_relaunch(self):
297 """Ensures test is relaunched on test crash until tests complete."""
smut64cb9422016-05-07 00:24:20298 def set_up(self):
299 return
300
301 @staticmethod
Menglu Huang89909a8e2018-02-21 00:06:42302 def _run(cmd, shards=None):
smut64cb9422016-05-07 00:24:20303 result = collections.namedtuple(
304 'result', [
305 'crashed',
306 'crashed_test',
307 'failed_tests',
308 'flaked_tests',
309 'passed_tests',
310 ],
311 )
Menglu Huang89909a8e2018-02-21 00:06:42312 if '-e' not in cmd:
smut64cb9422016-05-07 00:24:20313 # First run, has no test filter supplied. Mock a crash.
314 return result(
315 crashed=True,
316 crashed_test='c',
317 failed_tests={'b': ['b-out'], 'c': ['Did not complete.']},
318 flaked_tests={'d': ['d-out']},
319 passed_tests=['a'],
320 )
321 else:
322 return result(
323 crashed=False,
324 crashed_test=None,
325 failed_tests={},
326 flaked_tests={},
327 passed_tests=[],
328 )
329
330 def tear_down(self):
331 return
332
smut64cb9422016-05-07 00:24:20333 self.mock(test_runner.SimulatorTestRunner, 'set_up', set_up)
334 self.mock(test_runner.TestRunner, '_run', _run)
335 self.mock(test_runner.SimulatorTestRunner, 'tear_down', tear_down)
336
337 tr = test_runner.SimulatorTestRunner(
338 'fake-app',
339 'fake-iossim',
340 'platform',
341 'os',
342 'xcode-version',
Sergey Berezin1f457882017-11-20 21:05:39343 'xcode-build',
smut64cb9422016-05-07 00:24:20344 'out-dir',
345 )
346 tr.launch()
Sergey Berezin1f457882017-11-20 21:05:39347 self.assertTrue(tr.logs)
smut64cb9422016-05-07 00:24:20348
349
Eric Aleshire97b368c92018-10-12 18:09:09350class WprProxySimulatorTestRunnerTest(TestCase):
351 """Tests for test_runner.WprProxySimulatorTestRunner."""
352
353 def setUp(self):
354 super(WprProxySimulatorTestRunnerTest, self).setUp()
355
356 def install_xcode(build, mac_toolchain_cmd, xcode_app_path):
357 return True
358
359 self.mock(test_runner, 'get_current_xcode_info', lambda: {
360 'version': 'test version', 'build': 'test build', 'path': 'test/path'})
361 self.mock(test_runner, 'install_xcode', install_xcode)
362 self.mock(test_runner.subprocess, 'check_output',
363 lambda _: 'fake-bundle-id')
364 self.mock(os.path, 'abspath', lambda path: '/abs/path/to/%s' % path)
365 self.mock(os.path, 'exists', lambda _: True)
Eric Aleshiref22c7efb2019-02-04 23:41:26366 self.mock(test_runner.TestRunner, 'set_sigterm_handler',
367 lambda self, handler: 0)
368 self.mock(test_runner.SimulatorTestRunner, 'getSimulator',
369 lambda _: 'fake-id')
370 self.mock(test_runner.SimulatorTestRunner, 'deleteSimulator',
371 lambda a, b: True)
372 self.mock(test_runner.WprProxySimulatorTestRunner,
373 'copy_trusted_certificate', lambda a, b: True)
Eric Aleshire97b368c92018-10-12 18:09:09374
375 def test_replay_path_not_found(self):
376 """Ensures ReplayPathNotFoundError is raised."""
377
378 self.mock(os.path, 'exists', lambda p: not p.endswith('bad-replay-path'))
379
380 with self.assertRaises(test_runner.ReplayPathNotFoundError):
381 test_runner.WprProxySimulatorTestRunner(
382 'fake-app',
383 'fake-iossim',
384 'bad-replay-path',
385 'platform',
386 'os',
387 'wpr-tools-path',
388 'xcode-version',
389 'xcode-build',
390 'out-dir',
391 )
392
393 def test_wpr_tools_not_found(self):
394 """Ensures WprToolsNotFoundError is raised."""
395
396 self.mock(os.path, 'exists', lambda p: not p.endswith('bad-tools-path'))
397
398 with self.assertRaises(test_runner.WprToolsNotFoundError):
399 test_runner.WprProxySimulatorTestRunner(
400 'fake-app',
401 'fake-iossim',
402 'replay-path',
403 'platform',
404 'os',
405 'bad-tools-path',
406 'xcode-version',
407 'xcode-build',
408 'out-dir',
409 )
410
411 def test_init(self):
412 """Ensures instance is created."""
413 tr = test_runner.WprProxySimulatorTestRunner(
414 'fake-app',
415 'fake-iossim',
416 'replay-path',
417 'platform',
418 'os',
419 'wpr-tools-path',
420 'xcode-version',
421 'xcode-build',
422 'out-dir',
423 )
424
425 self.assertTrue(tr)
426
Eric Aleshire3f8c9952018-12-12 21:57:43427 def run_wpr_test(self, test_filter=[], invert=False):
428 """Wrapper that mocks the _run method and returns its result."""
Eric Aleshire97b368c92018-10-12 18:09:09429 class FakeStdout:
430 def __init__(self):
431 self.line_index = 0
432 self.lines = [
433 'Test Case \'-[a 1]\' started.',
434 'Test Case \'-[a 1]\' has uninteresting logs.',
435 'Test Case \'-[a 1]\' passed (0.1 seconds)',
436 'Test Case \'-[b 2]\' started.',
437 'Test Case \'-[b 2]\' passed (0.1 seconds)',
438 'Test Case \'-[c 3]\' started.',
439 'Test Case \'-[c 3]\' has interesting failure info.',
440 'Test Case \'-[c 3]\' failed (0.1 seconds)',
441 ]
442
443 def readline(self):
444 if self.line_index < len(self.lines):
445 return_line = self.lines[self.line_index]
446 self.line_index += 1
447 return return_line
448 else:
449 return None
450
451 class FakeProcess:
452 def __init__(self):
453 self.stdout = FakeStdout()
454 self.returncode = 0
455
456 def stdout(self):
457 return self.stdout
458
459 def wait(self):
460 return
461
462 def popen(recipe_cmd, env, stdout, stderr):
463 return FakeProcess()
464
465 tr = test_runner.WprProxySimulatorTestRunner(
466 'fake-app',
467 'fake-iossim',
468 'replay-path',
469 'platform',
470 'os',
471 'wpr-tools-path',
472 'xcode-version',
473 'xcode-build',
474 'out-dir',
475 )
Eric Aleshiref22c7efb2019-02-04 23:41:26476 self.mock(test_runner.WprProxySimulatorTestRunner, 'wprgo_start',
477 lambda a,b: None)
478 self.mock(test_runner.WprProxySimulatorTestRunner, 'wprgo_stop',
479 lambda _: None)
Eric Aleshire97b368c92018-10-12 18:09:09480
481 self.mock(os.path, 'isfile', lambda _: True)
482 self.mock(glob, 'glob', lambda _: ["file1", "file2"])
483 self.mock(subprocess, 'Popen', popen)
484
485 tr.xctest_path = 'fake.xctest'
Eric Aleshire3f8c9952018-12-12 21:57:43486 cmd = tr.get_launch_command(test_filter=test_filter, invert=invert)
487 return tr._run(cmd=cmd, shards=1)
488
489 def test_run_no_filter(self):
490 """Ensures the _run method can handle passed and failed tests."""
491 result = self.run_wpr_test()
Eric Aleshire97b368c92018-10-12 18:09:09492 self.assertIn('file1.a/1', result.passed_tests)
493 self.assertIn('file1.b/2', result.passed_tests)
494 self.assertIn('file1.c/3', result.failed_tests)
495 self.assertIn('file2.a/1', result.passed_tests)
496 self.assertIn('file2.b/2', result.passed_tests)
497 self.assertIn('file2.c/3', result.failed_tests)
498
Eric Aleshire3f8c9952018-12-12 21:57:43499 def test_run_with_filter(self):
500 """Ensures the _run method works with a filter."""
501 result = self.run_wpr_test(test_filter=["file1"], invert=False)
502 self.assertIn('file1.a/1', result.passed_tests)
503 self.assertIn('file1.b/2', result.passed_tests)
504 self.assertIn('file1.c/3', result.failed_tests)
505 self.assertNotIn('file2.a/1', result.passed_tests)
506 self.assertNotIn('file2.b/2', result.passed_tests)
507 self.assertNotIn('file2.c/3', result.failed_tests)
508
509 def test_run_with_inverted_filter(self):
510 """Ensures the _run method works with an inverted filter."""
511 result = self.run_wpr_test(test_filter=["file1"], invert=True)
512 self.assertNotIn('file1.a/1', result.passed_tests)
513 self.assertNotIn('file1.b/2', result.passed_tests)
514 self.assertNotIn('file1.c/3', result.failed_tests)
515 self.assertIn('file2.a/1', result.passed_tests)
516 self.assertIn('file2.b/2', result.passed_tests)
517 self.assertIn('file2.c/3', result.failed_tests)
Eric Aleshire97b368c92018-10-12 18:09:09518
Menglu Huang0f569612017-12-08 06:35:07519class DeviceTestRunnerTest(TestCase):
520 def setUp(self):
521 super(DeviceTestRunnerTest, self).setUp()
522
523 def install_xcode(build, mac_toolchain_cmd, xcode_app_path):
524 return True
525
Sergey Berezin7f9b4bf2018-05-21 19:49:07526 self.mock(test_runner, 'get_current_xcode_info', lambda: {
Menglu Huang0f569612017-12-08 06:35:07527 'version': 'test version', 'build': 'test build', 'path': 'test/path'})
528 self.mock(test_runner, 'install_xcode', install_xcode)
529 self.mock(test_runner.subprocess, 'check_output',
530 lambda _: 'fake-bundle-id')
531 self.mock(os.path, 'abspath', lambda path: '/abs/path/to/%s' % path)
532 self.mock(os.path, 'exists', lambda _: True)
533
534 self.tr = test_runner.DeviceTestRunner(
535 'fake-app',
536 'xcode-version',
537 'xcode-build',
538 'out-dir',
539 )
540 self.tr.xctestrun_data = {'TestTargetName':{}}
541
542 def test_with_test_filter_without_test_cases(self):
543 """Ensures tests in the run with test_filter and no test_cases."""
544 self.tr.set_xctest_filters(['a', 'b'], invert=False)
545 self.assertEqual(
546 self.tr.xctestrun_data['TestTargetName']['OnlyTestIdentifiers'],
547 ['a', 'b']
548 )
549
550 def test_invert_with_test_filter_without_test_cases(self):
551 """Ensures tests in the run invert with test_filter and no test_cases."""
552 self.tr.set_xctest_filters(['a', 'b'], invert=True)
553 self.assertEqual(
554 self.tr.xctestrun_data['TestTargetName']['SkipTestIdentifiers'],
555 ['a', 'b']
556 )
557
558 def test_with_test_filter_with_test_cases(self):
559 """Ensures tests in the run with test_filter and test_cases."""
560 self.tr.test_cases = ['a', 'b', 'c', 'd']
561 self.tr.set_xctest_filters(['a', 'b', 'irrelevant test'], invert=False)
562 self.assertEqual(
563 self.tr.xctestrun_data['TestTargetName']['OnlyTestIdentifiers'],
564 ['a', 'b']
565 )
566
567 def test_invert_with_test_filter_with_test_cases(self):
568 """Ensures tests in the run invert with test_filter and test_cases."""
569 self.tr.test_cases = ['a', 'b', 'c', 'd']
570 self.tr.set_xctest_filters(['a', 'b', 'irrelevant test'], invert=True)
571 self.assertEqual(
572 self.tr.xctestrun_data['TestTargetName']['OnlyTestIdentifiers'],
573 ['c', 'd']
574 )
575
576 def test_without_test_filter_without_test_cases(self):
577 """Ensures tests in the run with no test_filter and no test_cases."""
578 self.tr.set_xctest_filters(test_filter=None, invert=False)
579 self.assertIsNone(
580 self.tr.xctestrun_data['TestTargetName'].get('OnlyTestIdentifiers'))
581
582 def test_invert_without_test_filter_without_test_cases(self):
583 """Ensures tests in the run invert with no test_filter and no test_cases."""
584 self.tr.set_xctest_filters(test_filter=None, invert=True)
585 self.assertIsNone(
586 self.tr.xctestrun_data['TestTargetName'].get('OnlyTestIdentifiers'))
587
588 def test_without_test_filter_with_test_cases(self):
589 """Ensures tests in the run with no test_filter but test_cases."""
590 self.tr.test_cases = ['a', 'b', 'c', 'd']
591 self.tr.set_xctest_filters(test_filter=None, invert=False)
592 self.assertEqual(
593 self.tr.xctestrun_data['TestTargetName']['OnlyTestIdentifiers'],
594 ['a', 'b', 'c', 'd']
595 )
596
597 def test_invert_without_test_filter_with_test_cases(self):
598 """Ensures tests in the run invert with no test_filter but test_cases."""
599 self.tr.test_cases = ['a', 'b', 'c', 'd']
600 self.tr.set_xctest_filters(test_filter=None, invert=True)
601 self.assertEqual(
602 self.tr.xctestrun_data['TestTargetName']['OnlyTestIdentifiers'],
603 ['a', 'b', 'c', 'd']
604 )
605
606
smut64cb9422016-05-07 00:24:20607if __name__ == '__main__':
608 unittest.main()