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
28 class TestCase(unittest.TestCase):
29 """Test of the compile command"""
32 # Test the compile command with '--products' option
36 product_name = "PRODUCT_GIT"
40 sat.prepare(appli + " --product " + product_name)
41 expected_install_dir = src.product.get_product_config(
44 expected_file_path = os.path.join(expected_install_dir, "bin/hello")
46 sat.clean(appli + " --build --install --product " + product_name, batch=True)
47 sat.compile(appli + " --product " + product_name)
49 if os.path.exists(expected_file_path):
51 # pyunit method to compare 2 str
52 self.assertEqual(OK, "OK")
55 # Test the configure command with '--fathers' option
59 product_name = "PRODUCT_GIT"
60 product_name2 = "PRODUCT_ARCHIVE"
64 sat.prepare(appli + " --product " + product_name + "," + product_name2)
65 expected_install_dir = src.product.get_product_config(
68 expected_file_path = os.path.join(expected_install_dir, "bin/hello")
69 expected_install_dir2 = src.product.get_product_config(
70 sat.cfg, product_name2
72 expected_file_path2 = os.path.join(expected_install_dir2, "bin/hello-archive")
76 + " --build --install --product "
82 sat.compile(appli + " --with_fathers --product " + product_name)
84 if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
86 # pyunit method to compare 2 str
87 self.assertEqual(OK, "OK")
90 # Test the configure command with '--children' option
94 product_name = "PRODUCT_GIT"
95 product_name2 = "PRODUCT_ARCHIVE"
99 sat.prepare(appli + " --product " + product_name + "," + product_name2)
100 expected_install_dir = src.product.get_product_config(
101 sat.cfg, product_name
103 expected_file_path = os.path.join(expected_install_dir, "bin/hello")
104 expected_install_dir2 = src.product.get_product_config(
105 sat.cfg, product_name2
107 expected_file_path2 = os.path.join(expected_install_dir2, "bin/hello-archive")
111 + " --build --install --product "
117 sat.compile(appli + " --with_children --product " + product_name2)
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_all' 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(
136 sat.cfg, product_name
138 expected_file_path = os.path.join(expected_install_dir, "bin/hello")
139 expected_install_dir2 = src.product.get_product_config(
140 sat.cfg, product_name2
142 expected_file_path2 = os.path.join(expected_install_dir2, "bin/hello-archive")
144 sat.compile(appli + " --with_children --product " + product_name2)
147 appli + " --clean_all --with_children --product " + product_name2,
151 if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
153 # pyunit method to compare 2 str
154 self.assertEqual(OK, "OK")
157 # Test the configure command with '--clean_install' option
161 product_name = "PRODUCT_GIT"
162 product_name2 = "PRODUCT_ARCHIVE"
166 sat.prepare(appli + " --product " + product_name + "," + product_name2)
167 expected_install_dir = src.product.get_product_config(
168 sat.cfg, product_name
170 expected_file_path = os.path.join(expected_install_dir, "bin/hello")
171 expected_install_dir2 = src.product.get_product_config(
172 sat.cfg, product_name2
174 expected_file_path2 = os.path.join(expected_install_dir2, "bin/hello-archive")
176 sat.compile(appli + " --with_children --product " + product_name2)
179 appli + " --clean_install --with_children --product " + product_name2,
183 if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
185 # pyunit method to compare 2 str
186 self.assertEqual(OK, "OK")
189 # Test the configure command with '--make_flags' option
193 product_name = "PRODUCT_GIT"
197 sat.prepare(appli + " --product " + product_name)
198 expected_install_dir = src.product.get_product_config(
199 sat.cfg, product_name
201 expected_file_path = os.path.join(expected_install_dir, "bin/hello")
203 sat.clean(appli + " --build --install --product " + product_name, batch=True)
204 sat.compile(appli + " --make_flags 3 --product " + product_name)
206 if os.path.exists(expected_file_path):
208 # pyunit method to compare 2 str
209 self.assertEqual(OK, "OK")
212 # Test the configure command with '--show' option
216 product_name = "PRODUCT_GIT"
220 sat.prepare(appli + " --product " + product_name)
221 expected_install_dir = src.product.get_product_config(
222 sat.cfg, product_name
224 expected_file_path = os.path.join(expected_install_dir, "bin/hello")
226 sat.clean(appli + " --build --install --product " + product_name, batch=True)
227 sat.compile(appli + " --show --product " + product_name)
229 if not (os.path.exists(expected_file_path)):
231 # pyunit method to compare 2 str
232 self.assertEqual(OK, "OK")
235 # Test the configure command with '--stop_first_fail' option
242 sat.prepare(appli + " --product PRODUCT_CVS,Python")
243 expected_install_dir = src.product.get_product_config(
244 sat.cfg, "PRODUCT_CVS"
247 sat.clean(appli + " --build --install --product PRODUCT_CVS", batch=True)
248 sat.compile(appli + " --stop_first_fail --product PRODUCT_CVS,Python")
250 if not (os.path.exists(expected_install_dir)):
252 # pyunit method to compare 2 str
253 self.assertEqual(OK, "OK")
256 # Test the 'sat -h compile' command to get description
262 if "The compile command constructs the products" in compile.description():
265 # pyunit method to compare 2 str
266 self.assertEqual(OK, "OK")
270 if __name__ == "__main__":