4 # Copyright (C) 2010-2018 CEA/DEN
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.
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.
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
25 from src.salomeTools import Sat
27 class TestCase(unittest.TestCase):
28 """Test of the compile command"""
31 # Test the compile command with '--products' option
35 product_name = 'PRODUCT_GIT'
39 sat.prepare(appli + ' --product ' + product_name)
40 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
41 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
43 sat.clean(appli + ' --build --install --product ' + product_name, batch=True)
44 sat.compile(appli + ' --product ' + product_name)
46 if os.path.exists(expected_file_path):
48 # pyunit method to compare 2 str
49 self.assertEqual(OK, 'OK')
52 # Test the configure command with '--fathers' option
56 product_name = 'PRODUCT_GIT'
57 product_name2 = 'PRODUCT_ARCHIVE'
61 sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
62 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
63 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
64 expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
65 expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
67 sat.clean(appli + ' --build --install --product ' + product_name +"," +product_name2, batch=True)
68 sat.compile(appli + ' --with_fathers --product ' + product_name)
70 if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
72 # pyunit method to compare 2 str
73 self.assertEqual(OK, 'OK')
76 # Test the configure command with '--children' option
80 product_name = 'PRODUCT_GIT'
81 product_name2 = 'PRODUCT_ARCHIVE'
85 sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
86 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
87 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
88 expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
89 expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
91 sat.clean(appli + ' --build --install --product ' + product_name +"," +product_name2, batch=True)
92 sat.compile(appli + ' --with_children --product ' + product_name2)
94 if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
96 # pyunit method to compare 2 str
97 self.assertEqual(OK, 'OK')
100 # Test the configure command with '--clean_all' option
104 product_name = 'PRODUCT_GIT'
105 product_name2 = 'PRODUCT_ARCHIVE'
109 sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
110 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
111 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
112 expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
113 expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
115 sat.compile(appli + ' --with_children --product ' + product_name2)
117 sat.compile(appli + ' --clean_all --with_children --product ' + product_name2, batch=True)
119 if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
121 # pyunit method to compare 2 str
122 self.assertEqual(OK, 'OK')
125 # Test the configure command with '--clean_install' option
129 product_name = 'PRODUCT_GIT'
130 product_name2 = 'PRODUCT_ARCHIVE'
134 sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
135 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
136 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
137 expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
138 expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
140 sat.compile(appli + ' --with_children --product ' + product_name2)
142 sat.compile(appli + ' --clean_install --with_children --product ' + product_name2, batch=True)
144 if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
146 # pyunit method to compare 2 str
147 self.assertEqual(OK, 'OK')
150 # Test the configure command with '--make_flags' option
154 product_name = 'PRODUCT_GIT'
158 sat.prepare(appli + ' --product ' + product_name)
159 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
160 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
162 sat.clean(appli + ' --build --install --product ' + product_name, batch=True)
163 sat.compile(appli + ' --make_flags 3 --product ' + product_name)
165 if os.path.exists(expected_file_path):
167 # pyunit method to compare 2 str
168 self.assertEqual(OK, 'OK')
171 # Test the configure command with '--show' option
175 product_name = 'PRODUCT_GIT'
179 sat.prepare(appli + ' --product ' + product_name)
180 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
181 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
183 sat.clean(appli + ' --build --install --product ' + product_name, batch=True)
184 sat.compile(appli + ' --show --product ' + product_name)
186 if not(os.path.exists(expected_file_path)):
188 # pyunit method to compare 2 str
189 self.assertEqual(OK, 'OK')
192 # Test the configure command with '--stop_first_fail' option
199 sat.prepare(appli + ' --product PRODUCT_CVS,Python')
200 expected_install_dir = src.product.get_product_config(sat.cfg, "PRODUCT_CVS").install_dir
202 sat.clean(appli + ' --build --install --product PRODUCT_CVS', batch=True)
203 sat.compile(appli + ' --stop_first_fail --product PRODUCT_CVS,Python')
205 if not(os.path.exists(expected_install_dir)):
207 # pyunit method to compare 2 str
208 self.assertEqual(OK, 'OK')
211 # Test the 'sat -h compile' command to get description
217 if "The compile command constructs the products" in compile.description():
220 # pyunit method to compare 2 str
221 self.assertEqual(OK, "OK")
224 if __name__ == '__main__':