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