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
24 from src.salomeTools import Sat
26 from unittestpy.tools import outRedirection
29 class TestCase(unittest.TestCase):
30 """Test of the clean command"""
33 # Test the clean command with no arguments (nothing to clean)
41 my_out = outRedirection()
45 # stop output redirection
46 my_out.end_redirection()
49 res = my_out.read_results()
51 if "Nothing to suppress" in res:
53 self.assertEqual(OK, "OK")
56 # Test the clean of sources
60 product_name = "PRODUCT_GIT"
64 # Make sure the sources exist
65 sat.prepare(appli + " -p " + product_name)
68 sat.clean(appli + " -p " + product_name + " --sources", batch=True)
70 expected_src_dir = src.product.get_product_config(
74 if not os.path.exists(expected_src_dir):
76 self.assertEqual(OK, "OK")
79 # Test the clean of build
83 product_name = "PRODUCT_GIT"
87 # Make sure the build exists
88 sat.prepare(appli + " -p " + product_name)
89 sat.configure(appli + " -p " + product_name)
92 sat.clean(appli + " -p " + product_name + " --build", batch=True)
94 expected_build_dir = src.product.get_product_config(
98 if not os.path.exists(expected_build_dir):
100 self.assertEqual(OK, "OK")
103 # Test the clean of install
107 product_name = "PRODUCT_GIT"
111 # Make sure the build exists
112 sat.prepare(appli + " -p " + product_name)
113 sat.configure(appli + " -p " + product_name)
116 sat.clean(appli + " -p " + product_name + " --install", batch=True)
118 expected_install_dir = src.product.get_product_config(
119 sat.cfg, product_name
122 if not os.path.exists(expected_install_dir):
124 self.assertEqual(OK, "OK")
127 # Test the clean of all (build, src, install)
131 product_name = "PRODUCT_GIT"
135 # Make sure the build exists
136 sat.prepare(appli + " -p " + product_name)
137 sat.compile(appli + " -p " + product_name)
140 sat.clean(appli + " -p " + product_name + " --all", batch=True)
142 expected_install_dir = src.product.get_product_config(
143 sat.cfg, product_name
145 expected_build_dir = src.product.get_product_config(
146 sat.cfg, product_name
148 expected_src_dir = src.product.get_product_config(
149 sat.cfg, product_name
153 not os.path.exists(expected_install_dir)
154 and not os.path.exists(expected_build_dir)
155 and not os.path.exists(expected_src_dir)
158 self.assertEqual(OK, "OK")
161 # Test the clean with sources_without_dev option
165 product_name = "PRODUCT_GIT"
166 product_name2 = "PRODUCT_DEV"
170 # Make sure the build exists
171 sat.prepare(appli + " -p " + product_name + "," + product_name2)
174 sat.clean(appli + " -p " + product_name + " --sources_without_dev", batch=True)
176 expected_src_dir = src.product.get_product_config(
177 sat.cfg, product_name
179 expected_src_dir2 = src.product.get_product_config(
180 sat.cfg, product_name2
183 if not os.path.exists(expected_src_dir) and os.path.exists(expected_src_dir2):
185 self.assertEqual(OK, "OK")
188 # Test the sat -h clean
194 "The clean command suppress the source, build, or install"
195 in clean.description()
198 self.assertEqual(OK, "OK")
202 if __name__ == "__main__":