summaryrefslogtreecommitdiff
path: root/test/test_cerbero_ide_pkgconfig.py
blob: b484789a2fd715305b52b077ce31f9860d5c456f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3
# cerbero - a multi-platform build system for Open Source software
# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

import unittest
import os

from cerbero.ide.pkgconfig import PkgConfig


class TestPkgConfig(unittest.TestCase):
    def setUp(self):
        pc_path = os.path.join(os.path.dirname(__file__), 'pkgconfig')
        os.environ['PKG_CONFIG_LIBDIR'] = pc_path
        os.environ['PKG_CONFIG_PATH'] = pc_path
        self.pkgconfig = PkgConfig('gstreamer-0.10')
        self.pkgconfig2 = PkgConfig('gstreamer-0.10', False)

    def testListAll(self):
        expected = [
            'gobject-2.0',
            'gmodule-2.0',
            'libxml-2.0',
            'gthread-2.0',
            'glib-2.0',
            'gmodule-no-export-2.0',
            'gstreamer-0.10',
        ]
        self.assertEqual(sorted(PkgConfig.list_all()), sorted(expected))

    def testIncludeDirs(self):
        expected = [
            '/usr/include/gstreamer-0.10',
            '/usr/include/glib-2.0',
            '/usr/lib/glib-2.0/include',
            '/usr/include/libxml2',
        ]
        self.assertEqual(self.pkgconfig.include_dirs(), expected)
        expected = ['/usr/include/gstreamer-0.10']
        self.assertEqual(self.pkgconfig2.include_dirs(), expected)

    def testCFlags(self):
        expected = ['-pthread']
        self.assertEqual(self.pkgconfig.cflags(), expected)
        expected = []
        self.assertEqual(self.pkgconfig2.cflags(), expected)

    def testLibrariesDir(self):
        expected = []
        self.assertEqual(self.pkgconfig.libraries_dirs(), expected)
        expected = []
        self.assertEqual(self.pkgconfig2.libraries_dirs(), expected)

    def testLibraries(self):
        expected = ['gstreamer-0.10', 'gobject-2.0', 'gmodule-2.0', 'xml2', 'gthread-2.0', 'rt', 'glib-2.0']
        self.assertEqual(self.pkgconfig.libraries(), expected)
        expected = ['gstreamer-0.10']
        self.assertEqual(self.pkgconfig2.libraries(), expected)

    def testRequires(self):
        expected = ['glib-2.0', 'gobject-2.0', 'gmodule-no-export-2.0', 'gthread-2.0', 'libxml-2.0']
        self.assertEqual(self.pkgconfig.requires(), expected)
        self.assertEqual(self.pkgconfig2.requires(), expected)

    def testPrefix(self):
        self.assertEqual(self.pkgconfig.prefix(), '/usr')
        self.assertEqual(self.pkgconfig2.prefix(), '/usr')