================
@@ -0,0 +1,319 @@
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+# To run these tests:
+# python3 check_alphabetical_order_test.py -v
+
+import io
+import os
+import tempfile
+import unittest
+from contextlib import redirect_stderr
+from typing import cast
+
+
+import check_alphabetical_order as _mod
+
+
+class TestAlphabeticalOrderCheck(unittest.TestCase):
+ def test_normalize_list_rst_sorts_rows(self):
+ input_lines = [
+ ".. csv-table:: Clang-Tidy checks\n",
+ ' :header: "Name", "Offers fixes"\n',
+ "\n",
+ ' :doc:`bugprone-virtual-near-miss
<bugprone/virtual-near-miss>`, "Yes"\n',
+ " :doc:`cert-flp30-c <cert/flp30-c>`,\n",
+ ' :doc:`abseil-cleanup-ctad <abseil/cleanup-ctad>`, "Yes"\n',
+ " A non-doc row that should stay after docs\n",
+ ]
+
+ expected_lines = [
+ ".. csv-table:: Clang-Tidy checks\n",
+ ' :header: "Name", "Offers fixes"\n',
+ "\n",
+ ' :doc:`abseil-cleanup-ctad <abseil/cleanup-ctad>`, "Yes"\n',
+ ' :doc:`bugprone-virtual-near-miss
<bugprone/virtual-near-miss>`, "Yes"\n',
+ " :doc:`cert-flp30-c <cert/flp30-c>`,\n",
+ " A non-doc row that should stay after docs\n",
+ ]
+
+ out_str = _mod.normalize_list_rst("".join(input_lines))
+ self.assertEqual(out_str, "".join(expected_lines))
+
+ out_lines = _mod.normalize_list_rst(input_lines)
+ self.assertEqual(out_lines, expected_lines)
+
+ def test_find_heading(self):
+ lines = [
+ "- Deprecated the :program:`clang-tidy` ``zircon`` module. All
checks have been\n",
+ " moved to the ``fuchsia`` module instead. The ``zircon`` module
will be removed\n",
+ " in the 24th release.\n",
+ "\n",
+ "New checks\n",
+ "^^^^^^^^^^\n",
+ "- New :doc:`bugprone-derived-method-shadowing-base-method\n",
+ "
<clang-tidy/checks/bugprone/derived-method-shadowing-base-method>` check.\n",
+ ]
+ idx = _mod.find_heading(lines, "New checks")
+ self.assertEqual(idx, 4)
+
+ def test_duplicate_detection_and_report(self):
+ # Ensure duplicate detection works properly when sorting is incorrect.
+ lines = [
+ "Changes in existing checks\n",
----------------
vbvictor wrote:
Test that we handle correctly:
```
- Improved :doc:`llvm-prefer-isa-or-dyn-cast-in-conditionals
<clang-tidy/checks/llvm/prefer-isa-or-dyn-cast-in-conditionals>` check:
- Fix-it handles callees with nested-name-specifier correctly.
- ``if`` statements with init-statement (``if (auto X = ...; ...)``) are
handled correctly.
- ``for`` loops are supported.
```
With nested `-` inside text
https://github.com/llvm/llvm-project/pull/166072
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits