blob: 04414a85b82815b23c4aad465fd215c509953e0a [file] [log] [blame]
Laszlo Nagybc687582016-01-12 22:38:41 +00001# -*- 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
Laszlo Nagy8bd63e52016-04-19 12:03:03 +00007import libear
Laszlo Nagybc687582016-01-12 22:38:41 +00008import libscanbuild.clang as sut
Laszlo Nagy8bd63e52016-04-19 12:03:03 +00009import unittest
Laszlo Nagybc687582016-01-12 22:38:41 +000010import os.path
11
12
Laszlo Nagy8bd63e52016-04-19 12:03:03 +000013class GetClangArgumentsTest(unittest.TestCase):
Laszlo Nagybc687582016-01-12 22:38:41 +000014 def test_get_clang_arguments(self):
Laszlo Nagy8bd63e52016-04-19 12:03:03 +000015 with libear.TemporaryDirectory() as tmpdir:
Laszlo Nagybc687582016-01-12 22:38:41 +000016 filename = os.path.join(tmpdir, 'test.c')
17 with open(filename, 'w') as handle:
18 handle.write('')
19
20 result = sut.get_arguments(
21 ['clang', '-c', filename, '-DNDEBUG', '-Dvar="this is it"'],
22 tmpdir)
23
Laszlo Nagy8bd63e52016-04-19 12:03:03 +000024 self.assertTrue('NDEBUG' in result)
25 self.assertTrue('var="this is it"' in result)
Laszlo Nagybc687582016-01-12 22:38:41 +000026
27 def test_get_clang_arguments_fails(self):
28 self.assertRaises(
29 Exception, sut.get_arguments,
30 ['clang', '-###', '-fsyntax-only', '-x', 'c', 'notexist.c'], '.')
31
32
Laszlo Nagy8bd63e52016-04-19 12:03:03 +000033class GetCheckersTest(unittest.TestCase):
Laszlo Nagybc687582016-01-12 22:38:41 +000034 def test_get_checkers(self):
35 # this test is only to see is not crashing
36 result = sut.get_checkers('clang', [])
37 self.assertTrue(len(result))
38
39 def test_get_active_checkers(self):
40 # this test is only to see is not crashing
41 result = sut.get_active_checkers('clang', [])
42 self.assertTrue(len(result))