Bug 1874684 - Part 17: Fix uninitialised variable warnings from clang-tidy. r=allstarschh
[gecko.git] / tools / lint / test / test_manifest_toml.py
blobf205a1cd1f9df7bfa839c099f3aeadb12ffefc86
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 import mozunit
6 LINTER = "test-manifest-toml"
7 fixed = 0
10 def test_valid(lint, paths):
11 results = lint(paths("valid.toml"))
12 assert len(results) == 0
15 def test_invalid(lint, paths):
16 results = lint(paths("invalid.toml"))
17 assert len(results) == 1
18 assert results[0].message == "The manifest is not valid TOML."
21 def test_no_default(lint, paths):
22 """Test verifying [DEFAULT] section."""
23 results = lint(paths("no-default.toml"))
24 assert len(results) == 1
25 assert results[0].message == "The manifest does not start with a [DEFAULT] section."
28 def test_no_default_fix(lint, paths, create_temp_file):
29 """Test fixing missing [DEFAULT] section."""
30 contents = "# this Manifest has no DEFAULT section\n"
31 path = create_temp_file(contents, "no-default.toml")
32 results = lint([path], fix=True)
33 assert len(results) == 1
34 assert results[0].message == "The manifest does not start with a [DEFAULT] section."
35 assert fixed == 1
38 def test_non_double_quote_sections(lint, paths):
39 """Test verifying [DEFAULT] section."""
40 results = lint(paths("non-double-quote-sections.toml"))
41 assert len(results) == 2
42 assert results[0].message.startswith("The section name must be double quoted:")
45 def test_unsorted(lint, paths):
46 """Test sections in alpha order."""
47 results = lint(paths("unsorted.toml"))
48 assert len(results) == 1
49 assert results[0].message == "The manifest sections are not in alphabetical order."
52 def test_comment_section(lint, paths):
53 """Test for commented sections."""
54 results = lint(paths("comment-section.toml"))
55 assert len(results) == 2
56 assert results[0].message.startswith(
57 "Use 'disabled = \"<reason>\"' to disable a test instead of a comment:"
61 def test_skip_if_not_array(lint, paths):
62 """Test for non-array skip-if value."""
63 results = lint(paths("skip-if-not-array.toml"))
64 assert len(results) == 1
65 assert results[0].message.startswith("Value for conditional must be an array:")
68 def test_skip_if_explicit_or(lint, paths):
69 """Test for explicit || in skip-if."""
70 results = lint(paths("skip-if-explicit-or.toml"))
71 assert len(results) == 1
72 assert results[0].message.startswith(
73 "Value for conditional must not include explicit ||, instead put on multiple lines:"
77 if __name__ == "__main__":
78 mozunit.main()