123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #
- # Metrix++, Copyright 2009-2019, Metrix++ Project
- # Link: https://github.com/metrixplusplus/metrixplusplus
- #
- # This file is a part of Metrix++ Tool.
- #
- import unittest
- import os
- import tests.common
- class Test(tests.common.TestCase):
-
- def setUp(self):
- tests.common.TestCase.setUp(self)
- self.METRIXPLUSPLUS_PATH = None
- if 'METRIXPLUSPLUS_PATH' in list(os.environ.keys()):
- self.METRIXPLUSPLUS_PATH = os.environ['METRIXPLUSPLUS_PATH']
-
- def tearDown(self):
- if self.METRIXPLUSPLUS_PATH != None:
- os.environ['METRIXPLUSPLUS_PATH'] = self.METRIXPLUSPLUS_PATH
- else:
- del os.environ['METRIXPLUSPLUS_PATH']
- tests.common.TestCase.tearDown(self)
- def test_metric_plugin_api(self):
-
- #
- # WARNING:
- # files generated by this test are used by project documents page
- # so, if the test is changed, html docs should be updated accordingly
- #
-
- for step in range(9):
- opts = ['--log-level=INFO']
- if step > 1:
- opts.append('--myext.magic.numbers')
- if step > 7:
- opts.append('--myext.magic.numbers.simplier')
-
- os.environ['METRIXPLUSPLUS_PATH'] = os.path.join(os.path.dirname(os.path.abspath(__file__)),
- 'test_api_tutorial', 'ext', 'step' + str(step))
- runner = tests.common.ToolRunner('collect',
- opts,
- prefix='step' + str(step),
- check_stderr=[(0, -1)])
- self.assertExec(runner.run())
-
- if step < 4:
- continue
-
- runner = tests.common.ToolRunner('view',
- ['--log-level=INFO'],
- prefix='step' + str(step),
- check_stderr=[(0, -1)])
- self.assertExec(runner.run())
- def test_runable_plugin_api(self):
-
- #
- # WARNING:
- # files generated by this test are used by project documents page
- # so, if the test is changed, html docs should be updated accordingly
- #
- runner = tests.common.ToolRunner('collect',
- ['--std.code.lines.total',
- '--log-level=INFO'],
- check_stderr=[(0, -1)],
- save_prev=True)
- self.assertExec(runner.run())
-
- runner = tests.common.ToolRunner('collect',
- ['--std.code.lines.total',
- '--log-level=INFO'],
- check_stderr=[(0, -1)],
- prefix='second',
- cwd="sources_changed",
- use_prev=True)
- self.assertExec(runner.run())
-
- for step in range(3):
- step = step + 1
- os.environ['METRIXPLUSPLUS_PATH'] = os.path.join(os.path.dirname(os.path.abspath(__file__)),
- 'test_api_tutorial', 'ext', 'compare_step' + str(step))
- runner = tests.common.ToolRunner('compare',
- ['--log-level=INFO'],
- prefix='step' + str(step),
- check_stderr=[(0, -1)],
- use_prev=True)
- self.assertExec(runner.run())
- if __name__ == '__main__':
- unittest.main()
-
|