Salome HOME
Add test for the compilation commands
[tools/sat.git] / test / compilation / test_make.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3 #  Copyright (C) 2010-2012  CEA/DEN
4 #
5 #  This library is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU Lesser General Public
7 #  License as published by the Free Software Foundation; either
8 #  version 2.1 of the License.
9 #
10 #  This library is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 #  Lesser General Public License for more details.
14 #
15 #  You should have received a copy of the GNU Lesser General Public
16 #  License along with this library; if not, write to the Free Software
17 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18
19 import unittest
20 import os
21 import sys
22
23 # get execution path
24 testdir = os.path.dirname(os.path.realpath(__file__))
25 sys.path.append(os.path.join(testdir, '..', '..'))
26 sys.path.append(os.path.join(testdir, '..', '_testTools'))
27 sys.path.append(os.path.join(testdir, '..', '..','commands'))
28
29 import src.product
30
31 from salomeTools import Sat
32 import HTMLTestRunner
33
34 class TestMake(unittest.TestCase):
35     '''Test of the make command
36     '''
37
38     def test_make(self):
39         '''Test the configure command without any option
40         '''
41         OK = 'KO'
42
43         appli = 'appli-test'
44         product_name = 'PRODUCT_GIT'
45
46         sat = Sat()
47                             
48         sat.prepare(appli + ' --product ' + product_name)
49         expected_build_dir = src.product.get_product_config(sat.cfg, product_name).build_dir
50         expected_file_path = os.path.join(expected_build_dir, 'hello')
51        
52         sat.configure(appli + ' --product ' + product_name)
53         
54         sat.make(appli + ' --product ' + product_name)
55         
56         if os.path.exists(os.path.join(expected_build_dir, expected_file_path)):
57             OK = 'OK'         
58         # pyunit method to compare 2 str
59         self.assertEqual(OK, 'OK')
60
61     def test_make_option(self):
62         '''Test the make command with an option
63         '''
64         OK = 'KO'
65
66         appli = 'appli-test'
67         product_name = 'PRODUCT_GIT'
68
69         sat = Sat()
70                             
71         sat.prepare(appli + ' --product ' + product_name)
72         expected_build_dir = src.product.get_product_config(sat.cfg, product_name).build_dir
73         expected_file_path = os.path.join(expected_build_dir, 'hello')
74        
75         sat.configure(appli + ' --product ' + product_name)
76         
77         sat.make(appli + ' --product ' + product_name + ' --option -j3')
78         
79         if os.path.exists(os.path.join(expected_build_dir, expected_file_path)):
80             OK = 'OK'         
81         # pyunit method to compare 2 str
82         self.assertEqual(OK, 'OK')
83
84     def test_make_script(self):
85         '''Test the make command with a product in script mode
86         '''
87         OK = 'KO'
88
89         appli = 'appli-test'
90         product_name = 'Python'
91
92         sat = Sat()
93                             
94         sat.prepare(appli + ' --product ' + product_name)
95         expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
96         expected_file = "bin/python2.7"
97         
98         sat.make(appli + ' --product ' + product_name)
99         
100         if os.path.exists(os.path.join(expected_install_dir, expected_file)):
101             OK = 'OK'         
102         # pyunit method to compare 2 str
103         self.assertEqual(OK, 'OK')
104
105     def test_description(self):
106         '''Test the sat -h make
107         '''        
108
109         OK = "KO"
110
111         import make
112         
113         if "The make command executes the \"make\" command" in make.description():
114             OK = "OK"
115
116         # pyunit method to compare 2 str
117         self.assertEqual(OK, "OK")
118
119 # test launch
120 if __name__ == '__main__':
121     HTMLTestRunner.main()