Flutter Engine
The Flutter Engine
PRESUBMIT_test.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright 2023 Google Inc.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import io
7import os.path
8import subprocess
9import textwrap
10import unittest
11
12import PRESUBMIT
13
14from PRESUBMIT_test_mocks import MockFile, MockAffectedFile
15from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi
16
17
18class ReleaseNotesTest(unittest.TestCase):
20 mock_input_api = MockInputApi()
21 mock_input_api.files = [
22 MockFile('README.chromium', ''),
23 ]
24
25 mock_output_api = MockOutputApi()
27 mock_input_api, mock_output_api)
28
29 self.assertEqual(0, len(results))
30
32 mock_input_api = MockInputApi()
33 mock_input_api.files = [
34 MockFile('RELEASE_NOTES.md', ''),
35 ]
36
37 mock_output_api = MockOutputApi()
39 mock_input_api, mock_output_api)
40
41 self.assertEqual(1, len(results))
42 self.assertIsInstance(
43 results[0], mock_output_api.PresubmitPromptWarning, 'Not a warning')
44 self.assertTrue(results[0].message.startswith(
45 'Do not edit RELEASE_NOTES.md'))
46
48 mock_input_api = MockInputApi()
49 mock_input_api.files = [
50 MockFile('RELEASE_NOTES.md', ''),
51 MockFile('relnotes/deleted_note.md', ''),
52 ]
53
54 mock_output_api = MockOutputApi()
56 mock_input_api, mock_output_api)
57
58 self.assertEqual(0, len(results))
59
61 mock_input_api = MockInputApi()
62 mock_input_api.files = [
63 MockFile('include/core/SkDrawable.h', ''),
64 ]
65
66 mock_output_api = MockOutputApi()
68 mock_input_api, mock_output_api)
69
70 self.assertEqual(1, len(results))
71 self.assertIsInstance(
72 results[0], mock_output_api.PresubmitPromptWarning, 'Not a warning')
73
75 mock_input_api = MockInputApi()
76 mock_input_api.files = [
77 MockFile('include/core/SkDrawable.h', ''),
78 MockFile('relnotes/new_note.md', ''),
79 ]
80
81 mock_output_api = MockOutputApi()
83 mock_input_api, mock_output_api)
84
85 self.assertEqual(0, len(results))
86
87
88if __name__ == '__main__':
89 unittest.main()
def testUpdateTopReleaseNotesIssuesWarning(self)
def testUpdatePublicHeaderAndReleaseNoteGeneratesNoWarning(self)
def testUpdatePublicHeaderAndNoReleaseNoteGeneratesWarning(self)
def _CheckReleaseNotesForPublicAPI(input_api, output_api)
Definition: PRESUBMIT.py:604
def _CheckTopReleaseNotesChanged(input_api, output_api)
Definition: PRESUBMIT.py:629