Home | History | Annotate | Download | only in android
      1 # Copyright 2015 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 # Generates a script in the output bin directory which runs the test
      6 # target using the test runner script in build/android/pylib/test_runner.py.
      7 #
      8 # To use this, include this file in a gtest or instrumentation test target.
      9 # {
     10 #   'target_name': 'gtest',
     11 #   'type': 'none',
     12 #   'variables': {
     13 #     'test_type': 'gtest',  # string
     14 #     'test_suite_name': 'gtest_suite'  # string
     15 #     'isolate_file': 'path/to/gtest.isolate'  # string
     16 #   },
     17 #   'includes': ['path/to/this/gypi/file'],
     18 # }
     19 #
     20 # {
     21 #   'target_name': 'instrumentation_apk',
     22 #   'type': 'none',
     23 #   'variables': {
     24 #     'test_type': 'instrumentation',  # string
     25 #     'apk_name': 'TestApk'  # string
     26 #     'isolate_file': 'path/to/instrumentation_test.isolate'  # string
     27 #   },
     28 #   'includes': ['path/to/this/gypi/file'],
     29 # }
     30 #
     31 # {
     32 #   'target_name': 'junit_test',
     33 #   'type': 'none',
     34 #   'variables': {
     35 #     'test_type': 'junit',  # string
     36 #   },
     37 #   'includes': ['path/to/this/gypi/file'],
     38 # }
     39 #
     40 
     41 {
     42   'variables': {
     43     'variables': {
     44       'additional_apks%': [],
     45       'isolate_file%': '',
     46       'shard_timeout%': '',
     47       'test_runner_path%': '',
     48     },
     49     'test_runner_args': ['--output-directory', '<(PRODUCT_DIR)'],
     50     'conditions': [
     51       ['test_type == "gtest"', {
     52         'test_runner_args': ['--suite', '<(test_suite_name)'],
     53         'script_name': 'run_<(test_suite_name)',
     54       }],
     55       ['test_type == "instrumentation"', {
     56         'test_runner_args': [
     57           '--apk-under-test', '>(tested_apk_path)',
     58           '--test-apk', '>(final_apk_path)',
     59         ],
     60         'script_name': 'run_<(_target_name)',
     61         'conditions': [
     62           ['emma_instrument != 0', {
     63             'test_runner_args': [
     64               '--coverage-dir', '<(PRODUCT_DIR)/coverage',
     65             ],
     66           }],
     67         ],
     68       }],
     69       ['test_type == "junit"', {
     70         'test_runner_args': ['--test-suite', '<(_target_name)'],
     71         'script_name': 'run_<(_target_name)',
     72       }],
     73       ['additional_apks != []', {
     74         'test_runner_args': ['--additional-apk-list', '>(additional_apks)'],
     75       }],
     76       ['isolate_file != ""', {
     77         'test_runner_args': ['--isolate-file-path', '<(isolate_file)']
     78       }],
     79       ['shard_timeout != ""', {
     80         'test_runner_args': ['--shard-timeout', '<(shard_timeout)']
     81       }],
     82       ['test_runner_path != ""', {
     83         'test_runner_args': ['--test-runner-path', '<(test_runner_path)']
     84       }],
     85     ],
     86   },
     87   'actions': [
     88     {
     89       'action_name': 'create_test_runner_script_<(script_name)',
     90       'message': 'Creating test runner script <(script_name)',
     91       'variables': {
     92         'script_output_path': '<(PRODUCT_DIR)/bin/<(script_name)',
     93       },
     94       'inputs': [
     95         '<(DEPTH)/build/android/gyp/create_test_runner_script.py',
     96       ],
     97       'outputs': [
     98         '<(script_output_path)'
     99       ],
    100       'action': [
    101         'python', '<(DEPTH)/build/android/gyp/create_test_runner_script.py',
    102         '--script-output-path=<(script_output_path)',
    103         '<(test_type)', '<@(test_runner_args)',
    104       ],
    105     },
    106   ],
    107 }
    108