blob: efb98a27b2d90a9f140b9e13d2a2a2bfe3b263fb [file] [log] [blame]
Rob Mohrd39ea9e2020-09-22 15:01:07 -07001# Copyright 2020 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7# https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15from recipe_engine import post_process, recipe_test_api
16
17
18class RollUtilTestApi(recipe_test_api.RecipeTestApi):
19
20 def commit(self, hash, message):
21 return ' '.join((hash, message))
22
23 def commit_data(self, *commits):
24 return self.step_data('roll message.git log',
25 stdout=self.m.raw_io.output('\0'.join(commits)))
26
27 def cancelled(self):
28 return self.post_process(post_process.MustRunRE, '.*cancelling roll.*')
29
30 def not_cancelled(self):
31 return self.post_process(post_process.DoesNotRunRE, '.*cancelling roll.*')
32
33 def rolls_forward(self, prefix='', name='check roll direction'):
34 return self.step_data(prefix + name, retcode=0)
35
36 def rolls_backward(self, prefix='', name='check roll direction'):
37 return self.step_data(prefix + name, retcode=1)