Commit 7d6c5197 authored by Jeff Yoon's avatar Jeff Yoon Committed by Commit Bot

Enable iOS test runner unit tests as part of presubmit

Run iOS test runner unit tests as part of presubmit. Keeping scope to
functional tests, and will have separate CLs for the remaining files
that require further fixes.

* PRESUBMIT.py - include unit test execution for ios/build/bots/scripts
* run.py - unit tests caught logic incorrectness. Running the json
   parsing first, before validation.
* wpr_runner_test.py - remove install xcode mock, fixed broken tests
* test_apps_test.py and xcode_log_parser_test.py - include main call
   to unittest.

Bug: 1056457
Change-Id: Ifc233695ba8f6120f862586a497df61e96d4954f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2076765Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Jeff Yoon <jeffyoon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746102}
parent 05fc8d13
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Presubmit script for ios test runner scripts.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into depot_tools.
"""
def _RunTestRunnerUnitTests(input_api, output_api):
""" Runs iOS test runner unit tests """
# TODO(crbug.com/1056457): Replace whitelist with regex ".*_test.py" once
# all test files are fixed.
files = [
'coverage_util_test.py',
# 'iossim_util_test.py',
'run_test.py',
'shard_util_test.py',
'test_apps_test.py',
# 'test_runner_test.py',
'wpr_runner_test.py',
# 'xcode_log_parser_test.py',
# 'xcodebuild_runner_test.py',
]
return input_api.canned_checks.RunUnitTestsInDirectory(
input_api, output_api, '.', whitelist=files)
def CheckChange(input_api, output_api):
results = []
results.extend(_RunTestRunnerUnitTests(input_api, output_api))
return results
def CheckChangeOnCommit(input_api, output_api):
return CheckChange(input_api, output_api)
def CheckChangeOnUpload(input_api, output_api):
return CheckChange(input_api, output_api)
...@@ -436,8 +436,8 @@ class Runner(): ...@@ -436,8 +436,8 @@ class Runner():
'both -p/--platform and -v/--version') 'both -p/--platform and -v/--version')
args, test_args = parser.parse_known_args(args) args, test_args = parser.parse_known_args(args)
validate(args)
load_from_json(args) load_from_json(args)
validate(args)
self.args = args self.args = args
self.test_args = test_args self.test_args = test_args
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
# found in the LICENSE file. # found in the LICENSE file.
"""Unittests for test_apps.py.""" """Unittests for test_apps.py."""
import unittest
import test_apps import test_apps
import test_runner_test import test_runner_test
...@@ -54,3 +56,7 @@ class GetGTestFilterTest(test_runner_test.TestCase): ...@@ -54,3 +56,7 @@ class GetGTestFilterTest(test_runner_test.TestCase):
expected = '-test.1:test.2' expected = '-test.1:test.2'
self.assertEqual(test_apps.get_gtest_filter(tests, invert=True), expected) self.assertEqual(test_apps.get_gtest_filter(tests, invert=True), expected)
if __name__ == '__main__':
unittest.main()
\ No newline at end of file
...@@ -21,12 +21,8 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase): ...@@ -21,12 +21,8 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase):
def setUp(self): def setUp(self):
super(WprProxySimulatorTestRunnerTest, self).setUp() super(WprProxySimulatorTestRunnerTest, self).setUp()
def install_xcode(build, mac_toolchain_cmd, xcode_app_path):
return True
self.mock(test_runner, 'get_current_xcode_info', lambda: { self.mock(test_runner, 'get_current_xcode_info', lambda: {
'version': 'test version', 'build': 'test build', 'path': 'test/path'}) 'version': 'test version', 'build': 'test build', 'path': 'test/path'})
self.mock(test_runner, 'install_xcode', install_xcode)
self.mock(test_runner.subprocess, 'check_output', self.mock(test_runner.subprocess, 'check_output',
lambda _: 'fake-bundle-id') lambda _: 'fake-bundle-id')
self.mock(os.path, 'abspath', lambda path: '/abs/path/to/%s' % path) self.mock(os.path, 'abspath', lambda path: '/abs/path/to/%s' % path)
...@@ -56,8 +52,6 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase): ...@@ -56,8 +52,6 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase):
'platform', 'platform',
'os', 'os',
'wpr-tools-path', 'wpr-tools-path',
'xcode-version',
'xcode-build',
'out-dir', 'out-dir',
) )
...@@ -75,8 +69,6 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase): ...@@ -75,8 +69,6 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase):
'platform', 'platform',
'os', 'os',
'wpr-tools-path', 'wpr-tools-path',
'xcode-version',
'xcode-build',
'out-dir', 'out-dir',
) )
...@@ -94,8 +86,6 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase): ...@@ -94,8 +86,6 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase):
'platform', 'platform',
'os', 'os',
'bad-tools-path', 'bad-tools-path',
'xcode-version',
'xcode-build',
'out-dir', 'out-dir',
) )
...@@ -109,8 +99,6 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase): ...@@ -109,8 +99,6 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase):
'platform', 'platform',
'os', 'os',
'wpr-tools-path', 'wpr-tools-path',
'xcode-version',
'xcode-build',
'out-dir', 'out-dir',
) )
...@@ -165,8 +153,6 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase): ...@@ -165,8 +153,6 @@ class WprProxySimulatorTestRunnerTest(test_runner_test.TestCase):
'platform', 'platform',
'os', 'os',
'wpr-tools-path', 'wpr-tools-path',
'xcode-version',
'xcode-build',
'out-dir', 'out-dir',
) )
self.mock(wpr_runner.WprProxySimulatorTestRunner, 'wprgo_start', self.mock(wpr_runner.WprProxySimulatorTestRunner, 'wprgo_start',
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import json import json
import mock import mock
import os import os
import unittest
import test_runner import test_runner
import test_runner_test import test_runner_test
...@@ -269,3 +270,7 @@ class XCode11LogParserTest(test_runner_test.TestCase): ...@@ -269,3 +270,7 @@ class XCode11LogParserTest(test_runner_test.TestCase):
res['failed']['BUILD_INTERRUPTED']) res['failed']['BUILD_INTERRUPTED'])
self.assertEqual(['TestCase1/method1', 'TestCase2/method1'], self.assertEqual(['TestCase1/method1', 'TestCase2/method1'],
res['passed']) res['passed'])
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment