Specify the test files to be used as an argument to the instrumentation tests
This allows different test sets to use different test data, and in particular allows new test sets, needing new data files, to be written without modifying the core test system. BUG=162395 Review URL: https://chromiumcodereview.appspot.com/11348202 git-svn-id: http://src.chromium.org/svn/trunk/src/build@169306 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
a83234b05c
Коммит
06b2a01f02
|
@ -317,10 +317,12 @@ function bb_install_apk {
|
|||
# $1: APK to be installed.
|
||||
# $2: APK_PACKAGE for the APK to be installed.
|
||||
# $3: TEST_APK to run the tests against.
|
||||
# $4: TEST_DATA in format destination:source
|
||||
function bb_run_all_instrumentation_tests_for_apk {
|
||||
local APK=${1}
|
||||
local APK_PACKAGE=${2}
|
||||
local TEST_APK=${3}
|
||||
local TEST_DATA=${4}
|
||||
|
||||
# Install application APK.
|
||||
bb_install_apk ${APK} ${APK_PACKAGE}
|
||||
|
@ -328,21 +330,24 @@ function bb_run_all_instrumentation_tests_for_apk {
|
|||
# Run instrumentation tests. Using -I to install the test apk.
|
||||
echo "@@@BUILD_STEP Run instrumentation tests ${TEST_APK}@@@"
|
||||
bb_run_step python build/android/run_instrumentation_tests.py \
|
||||
-vvv --test-apk ${TEST_APK} -I
|
||||
-vvv --test-apk ${TEST_APK} -I --test_data ${TEST_DATA}
|
||||
}
|
||||
|
||||
# Run instrumentation tests for all relevant APKs on device.
|
||||
function bb_run_instrumentation_tests {
|
||||
bb_run_all_instrumentation_tests_for_apk "ContentShell.apk" \
|
||||
"org.chromium.content_shell" "ContentShellTest"
|
||||
"org.chromium.content_shell" "ContentShellTest" \
|
||||
"content:content/test/data/android/device_files"
|
||||
bb_run_all_instrumentation_tests_for_apk "ChromiumTestShell.apk" \
|
||||
"org.chromium.chrome.testshell" "ChromiumTestShellTest"
|
||||
"org.chromium.chrome.testshell" "ChromiumTestShellTest" \
|
||||
"chrome:chrome/test/data/android/device_files"
|
||||
}
|
||||
|
||||
# Run instrumentation tests for experimental APKs on device.
|
||||
function bb_run_experimental_instrumentation_tests {
|
||||
bb_run_all_instrumentation_tests_for_apk "AndroidWebView.apk" \
|
||||
"org.chromium.android_webview" "AndroidWebViewTest"
|
||||
"org.chromium.android_webview" "AndroidWebViewTest" \
|
||||
"webview:android_webview/test/data/device_files"
|
||||
}
|
||||
|
||||
# Zip and archive a build.
|
||||
|
|
|
@ -118,6 +118,7 @@ class TestRunner(BaseTestRunner):
|
|||
|
||||
self.build_type = options.build_type
|
||||
self.install_apk = options.install_apk
|
||||
self.test_data = options.test_data
|
||||
self.save_perf_json = options.save_perf_json
|
||||
self.screenshot_failures = options.screenshot_failures
|
||||
self.wait_for_debugger = options.wait_for_debugger
|
||||
|
@ -162,12 +163,10 @@ class TestRunner(BaseTestRunner):
|
|||
logging.warning('Already copied test files to device %s, skipping.',
|
||||
self.device)
|
||||
return
|
||||
host_test_files = [
|
||||
('android_webview/test/data/device_files', 'webview'),
|
||||
('content/test/data/android/device_files', 'content'),
|
||||
('chrome/test/data/android/device_files', 'chrome')
|
||||
]
|
||||
for (host_src, dst_layer) in host_test_files:
|
||||
for dest_host_pair in self.test_data:
|
||||
dst_src = dest_host_pair.split(':',1)
|
||||
dst_layer = dst_src[0]
|
||||
host_src = dst_src[1]
|
||||
host_test_files_path = constants.CHROME_DIR + '/' + host_src
|
||||
if os.path.exists(host_test_files_path):
|
||||
self.adb.PushIfNeeded(host_test_files_path,
|
||||
|
|
|
@ -137,7 +137,14 @@ def AddInstrumentationOptions(option_parser):
|
|||
'when test(s) fail.'))
|
||||
option_parser.add_option('--disable_assertions', action='store_true',
|
||||
help='Run with java assertions disabled.')
|
||||
|
||||
option_parser.add_option('--test_data', action='append',
|
||||
help=('Each instance defines a directory of test '
|
||||
'data that should be copied to the target(s) '
|
||||
'before running the tests. The argument '
|
||||
'should be of the form <target>:<source>, '
|
||||
'<target> is relative to the device data'
|
||||
'directory, and <source> is relative to the '
|
||||
'chromium build directory.'))
|
||||
|
||||
def ValidateInstrumentationOptions(option_parser, options, args):
|
||||
"""Validate options/arguments and populate options with defaults."""
|
||||
|
|
Загрузка…
Ссылка в новой задаче