test_std_suppress.py 3.4 KB

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