File: command_db_test.py

package info (click to toggle)
cmake-format 0.6.13-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,436 kB
  • sloc: python: 16,990; makefile: 14
file content (40 lines) | stat: -rw-r--r-- 918 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

import unittest
import subprocess

from cmakelang.parse.funs import get_parse_db

IGNORE_LIST = [
    "endforeach",
    "endfunction",
    "endmacro"
]


class TestCommandDatabase(unittest.TestCase):
  """
  Execute cmake and ensure that all cmake commands are in the database
  """

  def test_all_commands_in_db(self):
    missing_commands = []
    proc = subprocess.Popen(
        ["cmake", "--help-command-list"],
        stdout=subprocess.PIPE)

    parse_db = get_parse_db()

    ignore = IGNORE_LIST
    with proc.stdout as infile:
      for line in infile:
        command = line.strip().decode("utf-8")
        if command not in parse_db and command not in ignore:
          missing_commands.append(command)
    proc.wait()

    message = "Missing commands:\n  " + "\n  ".join(sorted(missing_commands))
    self.assertFalse(bool(missing_commands), msg=message)


if __name__ == "__main__":
  unittest.main()