aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/recipe_modules/builder_name_schema/examples/full.py
blob: f8eade8bcb8b11555cfeb873280f06d775d3d522 (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
90
91
92
93
# Copyright 2017 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.


DEPS = [
  'builder_name_schema',
]


def RunSteps(api):
  names = [
    'Build-Debian9-Clang-x64-Release-Android',
    'Upload-Test-Debian9-Clang-GCE-CPU-AVX2-x86_64-Debug-Shard_12-Coverage',
  ]
  for name in names:
    d = api.builder_name_schema.DictForBuilderName(name)
    got = api.builder_name_schema.MakeBuilderName(**d)
    assert got == name

  # Failures.
  try:
    api.builder_name_schema.MakeBuilderName(role='nope')
  except ValueError:
    pass

  try:
    api.builder_name_schema.MakeBuilderName(compiler='Build', os='ab')
  except ValueError:
    pass

  try:
    api.builder_name_schema.MakeBuilderName(role='Build', bogus='BOGUS')
  except ValueError:
    pass

  try:
    api.builder_name_schema.MakeBuilderName(
        role='Build',
        os='Debian9',
        compiler='Clang',
        target_arch='x64',
        configuration='Release',
        extra_config='A%sB' % api.builder_name_schema.BUILDER_NAME_SEP)
  except ValueError:
    pass

  try:
    api.builder_name_schema.DictForBuilderName('Build-')
  except ValueError:
    pass

  try:
    api.builder_name_schema.DictForBuilderName(
        'Build-Debian9-Clang-x64-Release-Android-Bogus')
  except ValueError:
    pass

  try:
    api.builder_name_schema.DictForBuilderName(
        'Bogus-Debian9-Clang-x64-Release-Android')
  except ValueError:
    pass

  try:
    api.builder_name_schema.MakeBuilderName(role='Upload')
  except ValueError:
    pass

  try:
    m = {
      'role': 'Upload',
      'sub-role-1': 'fake',
    }
    api.builder_name_schema.MakeBuilderName(**m)
  except ValueError:
    pass

  try:
    api.builder_name_schema.MakeBuilderName(
        role='Build',
        os='Debian9',
        compiler='Clang',
        target_arch='x64',
        configuration='Release',
        extra_config='Android',
        extra_extra_config='Bogus',
    )
  except ValueError:
    pass

def GenTests(api):
  yield api.test('test')