test_boost_parts.py 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #
  2. # Metrix++, Copyright 2009-2013, Metrix++ Project
  3. # Link: http://metrixplusplus.sourceforge.net
  4. #
  5. # This file is a part of Metrix++ Tool.
  6. #
  7. # Metrix++ is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, version 3 of the License.
  10. #
  11. # Metrix++ is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with Metrix++. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. import unittest
  20. import tests.common
  21. class Test(tests.common.TestCase):
  22. def test_workflow(self):
  23. #
  24. # WARNING:
  25. # files generated by this test are used by project documents page
  26. # so, if the test is changed, html docs should be updated accordingly
  27. #
  28. runner = tests.common.ToolRunner('collect',
  29. ['--std.code.complexity.cyclomatic',
  30. '--std.code.lines.code',
  31. '--log-level=INFO'],
  32. check_stderr=[(0, -1)],
  33. save_prev=True)
  34. self.assertExec(runner.run())
  35. runner = tests.common.ToolRunner('collect',
  36. ['--std.code.complexity.cyclomatic',
  37. '--std.code.lines.code',
  38. '--log-level=INFO'],
  39. check_stderr=[(0, -1)],
  40. prefix='second',
  41. cwd="sources_changed",
  42. use_prev=True)
  43. self.assertExec(runner.run())
  44. runner = tests.common.ToolRunner('view',
  45. ['--log-level=INFO'],
  46. check_stderr=[(0, -1)])
  47. self.assertExec(runner.run())
  48. runner = tests.common.ToolRunner('view',
  49. ['--log-level=INFO', '--scope-mode=all'],
  50. check_stderr=[(0, -1)],
  51. prefix='second_all',
  52. use_prev=True)
  53. self.assertExec(runner.run())
  54. runner = tests.common.ToolRunner('view',
  55. ['--log-level=INFO', '--scope-mode=touched'],
  56. check_stderr=[(0, -1)],
  57. prefix='second_touched',
  58. use_prev=True)
  59. self.assertExec(runner.run())
  60. runner = tests.common.ToolRunner('view',
  61. ['--log-level=INFO', '--scope-mode=new'],
  62. check_stderr=[(0, -1)],
  63. prefix='second_new',
  64. use_prev=True)
  65. self.assertExec(runner.run())
  66. runner = tests.common.ToolRunner('view',
  67. ['--log-level=INFO'],
  68. check_stderr=[(0, -1)],
  69. prefix='second_per_file',
  70. dirs_list=['./interprocess/detail/managed_open_or_create_impl.hpp'],
  71. use_prev=True)
  72. self.assertExec(runner.run())
  73. runner = tests.common.ToolRunner('limit',
  74. ['--log-level=INFO',
  75. '--max-limit=std.code.complexity:cyclomatic:15',
  76. '--hotspots=3'],
  77. check_stderr=[(0, -1)],
  78. exit_code=3)
  79. self.assertExec(runner.run())
  80. runner = tests.common.ToolRunner('limit',
  81. ['--log-level=INFO',
  82. '--max-limit=std.code.complexity:cyclomatic:15',
  83. '--warn-mode=touched'],
  84. check_stderr=[(0, -1)],
  85. prefix='second_touched',
  86. exit_code=6,
  87. use_prev=True)
  88. self.assertExec(runner.run())
  89. runner = tests.common.ToolRunner('limit',
  90. ['--log-level=INFO',
  91. '--max-limit=std.code.complexity:cyclomatic:15',
  92. '--warn-mode=trend'],
  93. check_stderr=[(0, -1)],
  94. prefix='second_trend',
  95. exit_code=2,
  96. use_prev=True)
  97. self.assertExec(runner.run())
  98. runner = tests.common.ToolRunner('limit',
  99. ['--log-level=INFO',
  100. '--max-limit=std.code.complexity:cyclomatic:15',
  101. '--warn-mode=new'],
  102. check_stderr=[(0, -1)],
  103. prefix='second_new',
  104. exit_code=0,
  105. use_prev=True)
  106. self.assertExec(runner.run())
  107. runner = tests.common.ToolRunner('info',
  108. ['--log-level=INFO'],
  109. check_stderr=[(0, -1)],
  110. exit_code=0)
  111. self.assertExec(runner.run())
  112. runner = tests.common.ToolRunner('export',
  113. ['--log-level=INFO'],
  114. check_stderr=[(0, -1)],
  115. exit_code=0)
  116. self.assertExec(runner.run())
  117. def test_std_member_metrics(self):
  118. runner = tests.common.ToolRunner('collect',
  119. ['--std.code.member.fields',
  120. '--std.code.member.globals',
  121. '--std.code.member.classes',
  122. '--std.code.member.structs',
  123. '--std.code.member.interfaces',
  124. '--std.code.member.types',
  125. '--std.code.member.methods',
  126. '--std.code.member.namespaces'])
  127. self.assertExec(runner.run())
  128. runner = tests.common.ToolRunner('view',
  129. ['--nest-regions', '--format=txt'],
  130. prefix='nest_per_file',
  131. dirs_list=['./interprocess/detail/win32_api.hpp'])
  132. self.assertExec(runner.run())
  133. runner = tests.common.ToolRunner('view', ['--format=txt'], prefix='txt')
  134. self.assertExec(runner.run())
  135. if __name__ == '__main__':
  136. unittest.main()