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
28 class TestCase(unittest.TestCase):
29 """Test of the clean command"""
32 # Test the clean command with no arguments (nothing to clean)
40 my_out = outRedirection()
44 # stop output redirection
45 my_out.end_redirection()
48 res = my_out.read_results()
50 if "Nothing to suppress" in res:
52 self.assertEqual(OK, 'OK')
55 # Test the clean of sources
59 product_name = "PRODUCT_GIT"
63 # Make sure the sources exist
64 sat.prepare(appli + " -p " + product_name)
67 sat.clean(appli + " -p " + product_name + " --sources", batch=True)
69 expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
71 if not os.path.exists(expected_src_dir):
73 self.assertEqual(OK, "OK")
76 # Test the clean of build
80 product_name = "PRODUCT_GIT"
84 # Make sure the build exists
85 sat.prepare(appli + " -p " + product_name)
86 sat.configure(appli + " -p " + product_name)
89 sat.clean(appli + " -p " + product_name + " --build", batch=True)
91 expected_build_dir = src.product.get_product_config(sat.cfg, product_name).build_dir
93 if not os.path.exists(expected_build_dir):
95 self.assertEqual(OK, "OK")
98 # Test the clean of install
102 product_name = "PRODUCT_GIT"
106 # Make sure the build exists
107 sat.prepare(appli + " -p " + product_name)
108 sat.configure(appli + " -p " + product_name)
111 sat.clean(appli + " -p " + product_name + " --install", batch=True)
113 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
115 if not os.path.exists(expected_install_dir):
117 self.assertEqual(OK, "OK")
120 # Test the clean of all (build, src, install)
124 product_name = "PRODUCT_GIT"
128 # Make sure the build exists
129 sat.prepare(appli + " -p " + product_name)
130 sat.compile(appli + " -p " + product_name)
133 sat.clean(appli + " -p " + product_name + " --all", batch=True)
135 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
136 expected_build_dir = src.product.get_product_config(sat.cfg, product_name).build_dir
137 expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
139 if not os.path.exists(expected_install_dir) and not os.path.exists(expected_build_dir) and not os.path.exists(expected_src_dir):
141 self.assertEqual(OK, "OK")
144 # Test the clean with sources_without_dev option
148 product_name = "PRODUCT_GIT"
149 product_name2 = "PRODUCT_DEV"
153 # Make sure the build exists
154 sat.prepare(appli + " -p " + product_name + "," + product_name2)
157 sat.clean(appli + " -p " + product_name + " --sources_without_dev", batch=True)
159 expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
160 expected_src_dir2 = src.product.get_product_config(sat.cfg, product_name2).source_dir
162 if not os.path.exists(expected_src_dir) and os.path.exists(expected_src_dir2):
164 self.assertEqual(OK, "OK")
168 # Test the sat -h clean
173 if "The clean command suppress the source, build, or install" in clean.description():
175 self.assertEqual(OK, "OK")
178 if __name__ == '__main__':