Salome HOME
Merge branch 'BR_8_3' of https://codev-tuleap.cea.fr/plugins/git/spns/SAT into BR_8_3
[tools/sat.git] / test / compilation / test_configure.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 TestConfigure(unittest.TestCase):
35     '''Test of the configure command
36     '''
37
38     def test_configure_cmake(self):
39         '''Test the configure command with a product in cmake
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, 'CMakeCache.txt')
51        
52         sat.configure(appli + ' --product ' + product_name)
53         
54         if os.path.exists(os.path.join(expected_build_dir, expected_file_path)):
55             OK = 'OK'         
56         # pyunit method to compare 2 str
57         self.assertEqual(OK, 'OK')
58
59     def test_configure_autotools(self):
60         '''Test the configure command with a product in autotools
61         '''
62         OK = 'KO'
63
64         appli = 'appli-test'
65         product_name = 'PRODUCT_CVS'
66
67         sat = Sat()
68                             
69         sat.prepare(appli + ' --product ' + product_name)
70         expected_build_dir = src.product.get_product_config(sat.cfg, product_name).build_dir
71         expected_file_path = os.path.join(expected_build_dir, 'config.log')
72        
73         sat.configure(appli + ' --product ' + product_name)
74         
75         if os.path.exists(os.path.join(expected_build_dir, expected_file_path)):
76             OK = 'OK'         
77         # pyunit method to compare 2 str
78         self.assertEqual(OK, 'OK')
79
80     def test_configure_script(self):
81         '''Test the configure command with a product in script mode
82         '''
83         OK = 'KO'
84
85         appli = 'appli-test'
86         product_name = 'Python'
87
88         sat = Sat()
89                             
90         sat.prepare(appli + ' --product ' + product_name)
91         expected_build_dir = src.product.get_product_config(sat.cfg, product_name).build_dir
92       
93         sat.configure(appli + ' --product ' + product_name)
94         
95         if os.path.exists(expected_build_dir):
96             OK = 'OK'         
97         # pyunit method to compare 2 str
98         self.assertEqual(OK, 'OK')
99
100     def test_description(self):
101         '''Test the sat -h configure
102         '''        
103
104         OK = "KO"
105
106         import configure
107         
108         if "The configure command executes in the build directory" in configure.description():
109             OK = "OK"
110
111         # pyunit method to compare 2 str
112         self.assertEqual(OK, "OK")
113
114 # test launch
115 if __name__ == '__main__':
116     HTMLTestRunner.main()