test_std_suppress.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_basic(self):
  23. runner = tests.common.ToolRunner('collect', ['--std.suppress',
  24. '--std.code.complexity.cyclomatic',
  25. '--std.code.length.total',
  26. '--std.general.size'])
  27. self.assertExec(runner.run())
  28. runner = tests.common.ToolRunner('view')
  29. self.assertExec(runner.run())
  30. runner = tests.common.ToolRunner('limit',
  31. ['--max-limit=std.code.complexity:cyclomatic:0'],
  32. exit_code=1,
  33. prefix='1')
  34. self.assertExec(runner.run())
  35. runner = tests.common.ToolRunner('limit',
  36. ['--max-limit=std.code.complexity:cyclomatic:0', '--disable-suppressions'],
  37. exit_code=8,
  38. prefix='2')
  39. self.assertExec(runner.run())
  40. runner = tests.common.ToolRunner('limit',
  41. ['--max-limit=std.code.length:total:0'],
  42. exit_code=7,
  43. prefix='3')
  44. self.assertExec(runner.run())
  45. runner = tests.common.ToolRunner('limit',
  46. ['--max-limit=std.code.length:total:0', '--disable-suppressions'],
  47. exit_code=26,
  48. prefix='4')
  49. self.assertExec(runner.run())
  50. runner = tests.common.ToolRunner('limit',
  51. ['--max-limit=std.code.complexity:cyclomatic:0', '--max-limit=std.code.length:total:0'],
  52. exit_code=8,
  53. prefix='5')
  54. self.assertExec(runner.run())
  55. runner = tests.common.ToolRunner('limit',
  56. ['--max-limit=std.general:size:0'],
  57. exit_code=0,
  58. prefix='size')
  59. self.assertExec(runner.run())
  60. runner = tests.common.ToolRunner('limit',
  61. ['--max-limit=std.general:size:0', '--disable-suppressions'],
  62. exit_code=1,
  63. prefix='size_nosup')
  64. self.assertExec(runner.run())
  65. if __name__ == '__main__':
  66. unittest.main()