3 # Copyright (C) 2010-2012 CEA/DEN
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.
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.
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
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'))
31 from salomeTools import Sat
34 class TestCompile(unittest.TestCase):
35 '''Test of the compile command
38 def test_compile(self):
39 '''Test the compile command with --products option
44 product_name = 'PRODUCT_GIT'
48 sat.prepare(appli + ' --product ' + product_name)
49 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
50 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
52 sat.clean(appli + ' --build --install --product ' + product_name, batch=True)
53 sat.compile(appli + ' --product ' + product_name)
55 if os.path.exists(expected_file_path):
57 # pyunit method to compare 2 str
58 self.assertEqual(OK, 'OK')
60 def test_compile_fathers(self):
61 '''Test the configure command with --fathers option
66 product_name = 'PRODUCT_GIT'
67 product_name2 = 'PRODUCT_ARCHIVE'
71 sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
72 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
73 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
74 expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
75 expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
77 sat.clean(appli + ' --build --install --product ' + product_name +"," +product_name2, batch=True)
78 sat.compile(appli + ' --with_fathers --product ' + product_name)
80 if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
82 # pyunit method to compare 2 str
83 self.assertEqual(OK, 'OK')
85 def test_compile_children(self):
86 '''Test the configure command with --children option
91 product_name = 'PRODUCT_GIT'
92 product_name2 = 'PRODUCT_ARCHIVE'
96 sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
97 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
98 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
99 expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
100 expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
102 sat.clean(appli + ' --build --install --product ' + product_name +"," +product_name2, batch=True)
103 sat.compile(appli + ' --with_children --product ' + product_name2)
105 if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
107 # pyunit method to compare 2 str
108 self.assertEqual(OK, 'OK')
110 def test_compile_clean_all(self):
111 '''Test the configure command with --clean_all option
116 product_name = 'PRODUCT_GIT'
117 product_name2 = 'PRODUCT_ARCHIVE'
121 sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
122 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
123 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
124 expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
125 expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
127 sat.compile(appli + ' --with_children --product ' + product_name2)
129 sat.compile(appli + ' --clean_all --with_children --product ' + product_name2, batch=True)
131 if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
133 # pyunit method to compare 2 str
134 self.assertEqual(OK, 'OK')
136 def test_compile_clean_install(self):
137 '''Test the configure command with --clean_install option
142 product_name = 'PRODUCT_GIT'
143 product_name2 = 'PRODUCT_ARCHIVE'
147 sat.prepare(appli + ' --product ' + product_name +"," +product_name2)
148 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
149 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
150 expected_install_dir2 = src.product.get_product_config(sat.cfg, product_name2).install_dir
151 expected_file_path2 = os.path.join(expected_install_dir2, 'bin/hello-archive')
153 sat.compile(appli + ' --with_children --product ' + product_name2)
155 sat.compile(appli + ' --clean_install --with_children --product ' + product_name2, batch=True)
157 if os.path.exists(expected_file_path) and os.path.exists(expected_file_path2):
159 # pyunit method to compare 2 str
160 self.assertEqual(OK, 'OK')
162 def test_compile_makeflags(self):
163 '''Test the configure command with --make_flags option
168 product_name = 'PRODUCT_GIT'
172 sat.prepare(appli + ' --product ' + product_name)
173 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
174 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
176 sat.clean(appli + ' --build --install --product ' + product_name, batch=True)
177 sat.compile(appli + ' --make_flags 3 --product ' + product_name)
179 if os.path.exists(expected_file_path):
181 # pyunit method to compare 2 str
182 self.assertEqual(OK, 'OK')
184 def test_compile_show(self):
185 '''Test the configure command with --show option
190 product_name = 'PRODUCT_GIT'
194 sat.prepare(appli + ' --product ' + product_name)
195 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
196 expected_file_path = os.path.join(expected_install_dir, 'bin/hello')
198 sat.clean(appli + ' --build --install --product ' + product_name, batch=True)
199 sat.compile(appli + ' --show --product ' + product_name)
201 if not(os.path.exists(expected_file_path)):
203 # pyunit method to compare 2 str
204 self.assertEqual(OK, 'OK')
206 def test_compile_stop_first_fail(self):
207 '''Test the configure command with --stop_first_fail option
215 sat.prepare(appli + ' --product PRODUCT_CVS,Python')
216 expected_install_dir = src.product.get_product_config(sat.cfg, "PRODUCT_CVS").install_dir
218 sat.clean(appli + ' --build --install --product PRODUCT_CVS', batch=True)
219 sat.compile(appli + ' --stop_first_fail --product PRODUCT_CVS,Python')
221 if not(os.path.exists(expected_install_dir)):
223 # pyunit method to compare 2 str
224 self.assertEqual(OK, 'OK')
226 def test_description(self):
227 '''Test the sat -h compile
234 if "The compile command constructs the products" in compile.description():
237 # pyunit method to compare 2 str
238 self.assertEqual(OK, "OK")
241 if __name__ == '__main__':
242 HTMLTestRunner.main()