• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2020 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""
6angle_presubmit_utils: Mock depot_tools class for ANGLE presubmit checks's unittests
7"""
8
9
10class Change_mock():
11
12    def __init__(self, description_text):
13        self.description_text = description_text
14
15    def DescriptionText(self):
16        return self.description_text
17
18
19class InputAPI_mock():
20
21    def __init__(self, description_text):
22        self.change = Change_mock(description_text)
23
24
25class _PresubmitResult(object):
26    """Base class for result objects."""
27    fatal = False
28    should_prompt = False
29
30    def __init__(self, message):
31        self._message = message
32
33    def __eq__(self, other):
34        return self.fatal == other.fatal and self.should_prompt == other.should_prompt \
35            and self._message == other._message
36
37
38# Top level object so multiprocessing can pickle
39# Public access through OutputApi object.
40class _PresubmitError(_PresubmitResult):
41    """A hard presubmit error."""
42    fatal = True
43
44
45# Top level object so multiprocessing can pickle
46# Public access through OutputApi object.
47class _PresubmitPromptWarning(_PresubmitResult):
48    """An warning that prompts the user if they want to continue."""
49    should_prompt = True
50
51
52# Top level object so multiprocessing can pickle
53# Public access through OutputApi object.
54class _PresubmitNotifyResult(_PresubmitResult):
55    """Just print something to the screen -- but it's not even a warning."""
56    pass
57
58
59class OutputAPI_mock():
60    PresubmitResult = _PresubmitResult
61    PresubmitError = _PresubmitError
62    PresubmitPromptWarning = _PresubmitPromptWarning
63    PresubmitNotifyResult = _PresubmitNotifyResult
64