test_boost_parts.py 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #
  2. # Metrix++, Copyright 2009-2019, Metrix++ Project
  3. # Link: https://github.com/metrixplusplus/metrixplusplus
  4. #
  5. # This file is a part of Metrix++ Tool.
  6. #
  7. import unittest
  8. import tests.common
  9. class Test(tests.common.TestCase):
  10. def test_workflow(self):
  11. #
  12. # WARNING:
  13. # files generated by this test are used by project documents page
  14. # so, if the test is changed, html docs should be updated accordingly
  15. #
  16. runner = tests.common.ToolRunner('collect',
  17. ['--std.code.complexity.cyclomatic',
  18. '--std.code.lines.code',
  19. '--log-level=INFO'],
  20. check_stderr=[(0, -1)],
  21. save_prev=True)
  22. self.assertExec(runner.run())
  23. runner = tests.common.ToolRunner('collect',
  24. ['--std.code.complexity.cyclomatic',
  25. '--std.code.lines.code',
  26. '--log-level=INFO'],
  27. check_stderr=[(0, -1)],
  28. prefix='second',
  29. cwd="sources_changed",
  30. use_prev=True)
  31. self.assertExec(runner.run())
  32. runner = tests.common.ToolRunner('view',
  33. ['--log-level=INFO'],
  34. check_stderr=[(0, -1)])
  35. self.assertExec(runner.run())
  36. runner = tests.common.ToolRunner('view',
  37. ['--log-level=INFO', '--scope-mode=all'],
  38. check_stderr=[(0, -1)],
  39. prefix='second_all',
  40. use_prev=True)
  41. self.assertExec(runner.run())
  42. runner = tests.common.ToolRunner('view',
  43. ['--log-level=INFO', '--scope-mode=touched'],
  44. check_stderr=[(0, -1)],
  45. prefix='second_touched',
  46. use_prev=True)
  47. self.assertExec(runner.run())
  48. runner = tests.common.ToolRunner('view',
  49. ['--log-level=INFO', '--scope-mode=new'],
  50. check_stderr=[(0, -1)],
  51. prefix='second_new',
  52. use_prev=True)
  53. self.assertExec(runner.run())
  54. runner = tests.common.ToolRunner('view',
  55. ['--log-level=INFO'],
  56. check_stderr=[(0, -1)],
  57. prefix='second_per_file',
  58. dirs_list=['./interprocess/detail/managed_open_or_create_impl.hpp'],
  59. use_prev=True)
  60. self.assertExec(runner.run())
  61. runner = tests.common.ToolRunner('limit',
  62. ['--log-level=INFO',
  63. '--max-limit=std.code.complexity:cyclomatic:15',
  64. '--hotspots=3'],
  65. check_stderr=[(0, -1)],
  66. exit_code=3)
  67. self.assertExec(runner.run())
  68. runner = tests.common.ToolRunner('limit',
  69. ['--log-level=INFO',
  70. '--max-limit=std.code.complexity:cyclomatic:15',
  71. '--warn-mode=touched'],
  72. check_stderr=[(0, -1)],
  73. prefix='second_touched',
  74. exit_code=6,
  75. use_prev=True)
  76. self.assertExec(runner.run())
  77. runner = tests.common.ToolRunner('limit',
  78. ['--log-level=INFO',
  79. '--max-limit=std.code.complexity:cyclomatic:15',
  80. '--warn-mode=trend'],
  81. check_stderr=[(0, -1)],
  82. prefix='second_trend',
  83. exit_code=2,
  84. use_prev=True)
  85. self.assertExec(runner.run())
  86. runner = tests.common.ToolRunner('limit',
  87. ['--log-level=INFO',
  88. '--max-limit=std.code.complexity:cyclomatic:15',
  89. '--warn-mode=new'],
  90. check_stderr=[(0, -1)],
  91. prefix='second_new',
  92. exit_code=0,
  93. use_prev=True)
  94. self.assertExec(runner.run())
  95. runner = tests.common.ToolRunner('info',
  96. ['--log-level=INFO'],
  97. check_stderr=[(0, -1)],
  98. exit_code=0)
  99. self.assertExec(runner.run())
  100. runner = tests.common.ToolRunner('export',
  101. ['--log-level=INFO'],
  102. check_stderr=[(0, -1)],
  103. exit_code=0)
  104. self.assertExec(runner.run())
  105. def test_std_member_metrics(self):
  106. runner = tests.common.ToolRunner('collect',
  107. ['--std.code.member.fields',
  108. '--std.code.member.globals',
  109. '--std.code.member.classes',
  110. '--std.code.member.structs',
  111. '--std.code.member.interfaces',
  112. '--std.code.member.types',
  113. '--std.code.member.methods',
  114. '--std.code.member.namespaces'])
  115. self.assertExec(runner.run())
  116. runner = tests.common.ToolRunner('view',
  117. ['--nest-regions', '--format=txt'],
  118. prefix='nest_per_file',
  119. dirs_list=['./interprocess/detail/win32_api.hpp'])
  120. self.assertExec(runner.run())
  121. runner = tests.common.ToolRunner('view', ['--format=txt'], prefix='txt')
  122. self.assertExec(runner.run())
  123. if __name__ == '__main__':
  124. unittest.main()