Laszlo Nagy | bc68758 | 2016-01-12 22:38:41 +0000 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | # The LLVM Compiler Infrastructure |
| 3 | # |
| 4 | # This file is distributed under the University of Illinois Open Source |
| 5 | # License. See LICENSE.TXT for details. |
| 6 | |
| 7 | import libscanbuild.clang as sut |
| 8 | from . import fixtures |
| 9 | import os.path |
| 10 | |
| 11 | |
| 12 | class GetClangArgumentsTest(fixtures.TestCase): |
| 13 | def test_get_clang_arguments(self): |
| 14 | with fixtures.TempDir() as tmpdir: |
| 15 | filename = os.path.join(tmpdir, 'test.c') |
| 16 | with open(filename, 'w') as handle: |
| 17 | handle.write('') |
| 18 | |
| 19 | result = sut.get_arguments( |
| 20 | ['clang', '-c', filename, '-DNDEBUG', '-Dvar="this is it"'], |
| 21 | tmpdir) |
| 22 | |
| 23 | self.assertIn('NDEBUG', result) |
| 24 | self.assertIn('var="this is it"', result) |
| 25 | |
| 26 | def test_get_clang_arguments_fails(self): |
| 27 | self.assertRaises( |
| 28 | Exception, sut.get_arguments, |
| 29 | ['clang', '-###', '-fsyntax-only', '-x', 'c', 'notexist.c'], '.') |
| 30 | |
| 31 | |
| 32 | class GetCheckersTest(fixtures.TestCase): |
| 33 | def test_get_checkers(self): |
| 34 | # this test is only to see is not crashing |
| 35 | result = sut.get_checkers('clang', []) |
| 36 | self.assertTrue(len(result)) |
| 37 | |
| 38 | def test_get_active_checkers(self): |
| 39 | # this test is only to see is not crashing |
| 40 | result = sut.get_active_checkers('clang', []) |
| 41 | self.assertTrue(len(result)) |