summaryrefslogtreecommitdiff
path: root/xnt/tests/maketests.py
blob: ccdd4632eb3726c218a8b866a36b46c954411dc5 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env python
"""Make (make/ant/nant) Tests Module"""

#   Xnt -- A Wrapper Build Tool
#   Copyright (C) 2013  Kenny Ballou

#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.

#   This program 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 General Public License for more details.

#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

from xnt.tests import assert_basic_assumptions
from xnt.tasks.build.make import __make__
from xnt.tasks.build.make import __ant__
from xnt.tasks.build.make import __nant__
import unittest

# pylint: disable=R0904
class AntTests(unittest.TestCase):
    """Test Case for Ant Build"""

    def test_default_build(self):
        """Test the default target of ant"""
        result = __ant__(target="test")
        assert_basic_assumptions(self, result)
        self.assertIn('target', result[0][1])
        self.assertEqual('test', result[0][1]['target'])

    def test_ant_when_given_path(self):
        """Test ant when passing given a path"""
        result = __ant__(target="test", path="some/other/path/build.xml")
        assert_basic_assumptions(self, result)
        self.assertIn('path', result[0][1])
        self.assertEqual('some/other/path/build.xml', result[0][1]['path'])

    def test_ant_when_given_flags(self):
        """Test passing flags to ant"""
        result = __ant__(target='test', flags=['-verbose'])
        assert_basic_assumptions(self, result)
        self.assertIn('flags', result[0][1])
        self.assertEqual(1, len(result[0][1]['flags']))
        self.assertEqual('-verbose', result[0][1]['flags'][0])

    def test_ant_when_given_vars(self):
        """Test passing variables to ant"""
        result = __ant__(target="test",
                         pkeys=["test_var"],
                         pvalues=["testing"])
        assert_basic_assumptions(self, result)
        self.assertIn('pkeys', result[0][1])
        self.assertIn('pvalues', result[0][1])
        self.assertEqual(1, len(result[0][1]['pkeys']))
        self.assertEqual(1, len(result[0][1]['pvalues']))
        self.assertEqual('test_var', result[0][1]['pkeys'][0])
        self.assertEqual('testing', result[0][1]['pvalues'][0])

# pylint: disable=R0904
class MakeTests(unittest.TestCase):
    """GNU Make Tests"""

    def test_default_make(self):
        """Test Default make"""
        result = __make__(target="build")
        assert_basic_assumptions(self, result)
        self.assertIn('target', result[0][1])
        self.assertEqual('build', result[0][1]['target'])

    def test_make_with_path(self):
        '''Test make given a path'''
        result = __make__(target="build", path="some/other/path/Makefile")
        assert_basic_assumptions(self, result)
        self.assertIn('path', result[0][1])
        self.assertEqual('some/other/path/Makefile', result[0][1]['path'])

    def test_passing_vars(self):
        """Test Parameter Passing with Make"""
        result = __make__(target='build',
                          pkeys=["test_var"],
                          pvalues=["testing"])
        assert_basic_assumptions(self, result)
        self.assertIn('pkeys', result[0][1])
        self.assertIn('pvalues', result[0][1])
        self.assertEqual(1, len(result[0][1]['pkeys']))
        self.assertEqual(1, len(result[0][1]['pvalues']))
        self.assertEqual('test_var', result[0][1]['pkeys'][0])
        self.assertEqual('testing', result[0][1]['pvalues'][0])

    def test_passing_flags(self):
        """Test Flag Passing with Make"""
        result = __make__(target='build', flags=['-B'])
        assert_basic_assumptions(self, result)
        self.assertIn('flags', result[0][1])
        self.assertEqual(1, len(result[0][1]['flags']))
        self.assertEqual('-B', result[0][1]['flags'][0])

# pylint: disable=R0904
class NAntTests(unittest.TestCase):
    """.NET Ant Tests"""

    def test_nant_with_target(self):
        """Test Deault nant"""
        result = __nant__(target='test')
        assert_basic_assumptions(self, result)
        self.assertIn('target', result[0][1])
        self.assertEqual('test', result[0][1]['target'])

    def test_nant_with_path(self):
        '''Test NAnt with path'''
        result = __nant__(target='test', path='some/other/path/build.xml')
        assert_basic_assumptions(self, result)
        self.assertIn('path', result[0][1])
        self.assertEqual('some/other/path/build.xml', result[0][1]['path'])

    def test_nant_with_parameters(self):
        '''Test NAnt with parameters'''
        result = __nant__(target="test",
                          pkeys=["test_var"],
                          pvalues=["testing"])
        assert_basic_assumptions(self, result)
        self.assertIn('pkeys', result[0][1])
        self.assertIn('pvalues', result[0][1])
        self.assertEqual(1, len(result[0][1]['pkeys']))
        self.assertEqual(1, len(result[0][1]['pvalues']))
        self.assertEqual('test_var', result[0][1]['pkeys'][0])

    def test_nant_with_flags(self):
        '''Test NAnt with flags'''
        result = __nant__(target="test", flags=["-v"])
        assert_basic_assumptions(self, result)
        self.assertIn('flags', result[0][1])
        self.assertEqual(1, len(result[0][1]['flags']))
        self.assertEqual('-v', result[0][1]['flags'][0])

if __name__ == '__main__':
    unittest.main()