summaryrefslogtreecommitdiffstats
path: root/chrome/js_unittest_rules.gypi
blob: b3dff9cbce99f3a03f65ad94c58fbe33100a9250 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Copyright (c) 2011 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.

# This file defines rules that allow you to include JavaScript tests in
# your unittests target.

# To add JS unittests to an existing unittest target, first include
# 'js_unittest_vars.gypi' at the top of your GYP file to define the required
# variables:
#
#  'includes': [
#    '<(DEPTH)/chrome/js_unittest_vars.gypi',
#  ],
#
# Then include this rule file in each of your unittest targets:
#
#    {
#      'target_name': 'my_unittests',
#      ...
#      'includes': [
#        '<(DEPTH)/chrome/js_unittest_rules.gypi',
#      ],
#    }
#
# Note that when you run your TestSuite, you'll need to call
# chrome::RegisterPathProvider(). These path providers are required by
# src/chrome/test/base/v8_unit_test.cc to setup and run the tests.

{
    'dependencies': [
      # Used by rule js2unit below.
      '../v8/src/d8.gyp:d8#host',
    ],
  'rules': [
    {
      'rule_name': 'copyjs',
      'extension': 'js',
      'msvs_external_rule': 1,
      'inputs': [
        '<(DEPTH)/build/cp.py',
      ],
      'outputs': [
        '<(PRODUCT_DIR)/test_data/chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).<(_extension)',
      ],
      'action': [
        'python',
        '<@(_inputs)',
        '<(RULE_INPUT_PATH)',
        '<@(_outputs)',
      ],
    },
    {
      'rule_name': 'js2unit',
      'extension': 'gtestjs',
      'msvs_external_rule': 1,
      'variables': {
        'conditions': [
          ['v8_use_external_startup_data==1', {
            'external_v8': 'y',
          }, {
            'external_v8': 'n',
          }],
        ],
      },
      'inputs': [
        '<(gypv8sh)',
        '<(PRODUCT_DIR)/d8<(EXECUTABLE_SUFFIX)',
        '<(mock_js)',
        '<(test_api_js)',
        '<(js2gtest)',
      ],
      'outputs': [
        '<(INTERMEDIATE_DIR)/chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT)-gen.cc',
        '<(PRODUCT_DIR)/test_data/chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).<(_extension)',
      ],
      'process_outputs_as_sources': 1,
      'action': [
        'python',
        '<@(_inputs)',
        '--external', '<(external_v8)',
        'unit',
        '<(RULE_INPUT_PATH)',
        'chrome/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).<(_extension)',
        '<@(_outputs)',
      ],
    },
  ],
}