1# Copyright 2018 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# Recipe which runs the PathKit tests using docker
6
7DEPS = [
8  'checkout',
9  'docker',
10  'env',
11  'flavor',
12  'gold_upload',
13  'infra',
14  'recipe_engine/file',
15  'recipe_engine/path',
16  'recipe_engine/properties',
17  'recipe_engine/python',
18  'recipe_engine/step',
19  'run',
20  'vars',
21]
22
23
24DOCKER_IMAGE = 'gcr.io/skia-public/gold-karma-chrome-tests:87.0.4280.88_v2'
25INNER_KARMA_SCRIPT = 'skia/infra/pathkit/test_pathkit.sh'
26
27
28def RunSteps(api):
29  api.vars.setup()
30  api.flavor.setup("dm")
31  checkout_root = api.path['start_dir']
32  out_dir = api.vars.swarming_out_dir
33
34  # The karma script is configured to look in ./npm-(asmjs|wasm)/bin/test/ for
35  # the test files to load, so we must copy them there (see Set up for docker).
36  copy_dest = checkout_root.join('skia', 'modules', 'pathkit',
37                                 'npm-wasm', 'bin', 'test')
38  if 'asmjs' in api.vars.builder_name:
39    copy_dest = checkout_root.join('skia', 'modules', 'pathkit',
40                                   'npm-asmjs', 'bin', 'test')
41
42  base_dir = api.vars.build_dir
43  bundle_name = 'pathkit.wasm'
44  if 'asmjs' in api.vars.builder_name:
45    # release mode has a .js.mem file that needs to come with.
46    # debug mode has an optional .map file, but we can omit that for tests
47    if 'Debug' in api.vars.builder_name:
48      bundle_name = ''
49    else:
50      bundle_name = 'pathkit.js.mem'
51
52  copies = {
53    base_dir.join('pathkit.js'): copy_dest.join('pathkit.js'),
54  }
55  if bundle_name:
56    copies[base_dir.join(bundle_name)] = copy_dest.join(bundle_name)
57  recursive_read = [checkout_root.join('skia')]
58
59  docker_args = None
60  if 'asmjs' in api.vars.builder_name:
61    docker_args = ['--env', 'ASM_JS=1']
62
63  args = [
64    '--builder',              api.vars.builder_name,
65    '--git_hash',             api.properties['revision'],
66    '--buildbucket_build_id', api.properties.get('buildbucket_build_id', ''),
67    '--browser',              'Chrome',
68    '--config',               api.vars.configuration,
69    '--source_type',          'pathkit',
70  ]
71  if 'asmjs' in api.vars.builder_name:
72    args.extend(['--compiled_language', 'asmjs']) # the default is wasm
73  if api.vars.is_trybot:
74    args.extend([
75      '--issue',         api.vars.issue,
76      '--patchset',      api.vars.patchset,
77    ])
78
79  api.docker.run(
80      name='Test PathKit with Docker',
81      docker_image=DOCKER_IMAGE,
82      src_dir=checkout_root,
83      out_dir=out_dir,
84      script=checkout_root.join(INNER_KARMA_SCRIPT),
85      args=args,
86      docker_args=docker_args,
87      copies=copies,
88      recursive_read=recursive_read,
89      attempts=3,
90  )
91
92  api.gold_upload.upload()
93
94
95def GenTests(api):
96  yield (
97      api.test('Test-Debian10-EMCC-GCE-CPU-AVX2-wasm-Debug-All-PathKit') +
98      api.properties(buildername=('Test-Debian10-EMCC-GCE-CPU-AVX2'
99                                  '-wasm-Debug-All-PathKit'),
100                     repository='https://skia.googlesource.com/skia.git',
101                     revision='abc123',
102                     gs_bucket='skia-infra-gm',
103                     path_config='kitchen',
104                     swarm_out_dir='[SWARM_OUT_DIR]')
105  )
106
107  yield (
108      api.test('Test-Debian10-EMCC-GCE-CPU-AVX2-asmjs-Debug-All-PathKit') +
109      api.properties(buildername=('Test-Debian10-EMCC-GCE-CPU-AVX2'
110                                  '-asmjs-Debug-All-PathKit'),
111                     repository='https://skia.googlesource.com/skia.git',
112                     revision='abc123',
113                     gs_bucket='skia-infra-gm',
114                     path_config='kitchen',
115                     swarm_out_dir='[SWARM_OUT_DIR]')
116  )
117
118  yield (
119      api.test('Test-Debian10-EMCC-GCE-CPU-AVX2-asmjs-Release-All-PathKit') +
120      api.properties(buildername=('Test-Debian10-EMCC-GCE-CPU-AVX2'
121                                  '-asmjs-Release-All-PathKit'),
122                     repository='https://skia.googlesource.com/skia.git',
123                     revision='abc123',
124                     gs_bucket='skia-infra-gm',
125                     path_config='kitchen',
126                     swarm_out_dir='[SWARM_OUT_DIR]')
127  )
128
129  yield (
130      api.test('pathkit_trybot') +
131      api.properties(buildername=('Test-Debian10-EMCC-GCE-CPU-AVX2'
132                                  '-wasm-Debug-All-PathKit'),
133                     repository='https://skia.googlesource.com/skia.git',
134                     revision='abc123',
135                     gs_bucket='skia-infra-gm',
136                     path_config='kitchen',
137                     swarm_out_dir='[SWARM_OUT_DIR]',
138                     patch_ref='89/456789/12',
139                     patch_repo='https://skia.googlesource.com/skia.git',
140                     patch_storage='gerrit',
141                     patch_set=7,
142                     patch_issue=1234,
143                     gerrit_project='skia',
144                     gerrit_url='https://skia-review.googlesource.com/')
145  )
146