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'))
29 from tools import outRedirection
31 from salomeTools import Sat
36 class TestClean(unittest.TestCase):
37 '''Test of the clean command
40 def test_clean_no_args(self):
41 '''Test the clean command with no arguments (nothing to clean)
50 my_out = outRedirection()
54 # stop output redirection
55 my_out.end_redirection()
58 res = my_out.read_results()
60 if "Nothing to suppress" in res:
63 # pyunit method to compare 2 str
64 self.assertEqual(OK, 'OK')
66 def test_clean_sources(self):
67 '''Test the clean of sources
72 product_name = "PRODUCT_GIT"
76 # Make sure the sources exist
77 sat.prepare(appli + " -p " + product_name)
80 sat.clean(appli + " -p " + product_name + " --sources", batch=True)
82 expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
84 if not os.path.exists(expected_src_dir):
87 # pyunit method to compare 2 str
88 self.assertEqual(OK, "OK")
90 def test_clean_build(self):
91 '''Test the clean of build
96 product_name = "PRODUCT_GIT"
100 # Make sure the build exists
101 sat.prepare(appli + " -p " + product_name)
102 sat.configure(appli + " -p " + product_name)
105 sat.clean(appli + " -p " + product_name + " --build", batch=True)
107 expected_build_dir = src.product.get_product_config(sat.cfg, product_name).build_dir
109 if not os.path.exists(expected_build_dir):
112 # pyunit method to compare 2 str
113 self.assertEqual(OK, "OK")
115 def test_clean_install(self):
116 '''Test the clean of install
121 product_name = "PRODUCT_GIT"
125 # Make sure the build exists
126 sat.prepare(appli + " -p " + product_name)
127 sat.configure(appli + " -p " + product_name)
130 sat.clean(appli + " -p " + product_name + " --install", batch=True)
132 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
134 if not os.path.exists(expected_install_dir):
137 # pyunit method to compare 2 str
138 self.assertEqual(OK, "OK")
140 def test_clean_all(self):
141 '''Test the clean of all (build, src, install)
146 product_name = "PRODUCT_GIT"
150 # Make sure the build exists
151 sat.prepare(appli + " -p " + product_name)
152 sat.compile(appli + " -p " + product_name)
155 sat.clean(appli + " -p " + product_name + " --all", batch=True)
157 expected_install_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
158 expected_build_dir = src.product.get_product_config(sat.cfg, product_name).build_dir
159 expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
161 if not os.path.exists(expected_install_dir) and not os.path.exists(expected_build_dir) and not os.path.exists(expected_src_dir):
164 # pyunit method to compare 2 str
165 self.assertEqual(OK, "OK")
167 def test_clean_sources_without_dev(self):
168 '''Test the clean with sources_without_dev option
173 product_name = "PRODUCT_GIT"
174 product_name2 = "PRODUCT_DEV"
178 # Make sure the build exists
179 sat.prepare(appli + " -p " + product_name + "," + product_name2)
182 sat.clean(appli + " -p " + product_name + " --sources_without_dev", batch=True)
184 expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
185 expected_src_dir2 = src.product.get_product_config(sat.cfg, product_name2).source_dir
187 if not os.path.exists(expected_src_dir) and os.path.exists(expected_src_dir2):
190 # pyunit method to compare 2 str
191 self.assertEqual(OK, "OK")
194 def test_description(self):
195 '''Test the sat -h clean
202 if "The clean command suppress the source, build, or install" in clean.description():
205 # pyunit method to compare 2 str
206 self.assertEqual(OK, "OK")
209 if __name__ == '__main__':
210 HTMLTestRunner.main()