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 salomeTools import Sat
32 class TestSource(unittest.TestCase):
33 '''Test of the source command
36 def test_environ_no_option(self):
37 '''Test the environ command without any option
43 file_env_name = 'env_launch.sh'
48 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
50 if os.path.exists(expected_file_path):
51 os.remove(expected_file_path)
55 if os.path.exists(expected_file_path):
58 # pyunit method to compare 2 str
59 self.assertEqual(OK, 'OK')
61 def test_environ_option_products(self):
62 '''Test the environ command with option --products
67 product_name = 'PRODUCT_GIT'
69 file_env_name = 'env_launch.sh'
74 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
76 if os.path.exists(expected_file_path):
77 os.remove(expected_file_path)
79 sat.environ(appli + ' --products ' + product_name)
81 if os.path.exists(expected_file_path):
84 # pyunit method to compare 2 str
85 self.assertEqual(OK, 'OK')
87 def test_environ_option_target(self):
88 '''Test the environ command with option --target
94 file_env_name = 'env_launch.sh'
99 expected_file_path = os.path.join('.', file_env_name)
100 expected_file_path2 = os.path.join('.', 'env_build.sh')
102 if os.path.exists(expected_file_path):
103 os.remove(expected_file_path)
105 sat.environ(appli + ' --target .')
107 if os.path.exists(expected_file_path):
110 if os.path.exists(expected_file_path):
111 os.remove(expected_file_path)
112 os.remove(expected_file_path2)
114 # pyunit method to compare 2 str
115 self.assertEqual(OK, 'OK')
117 def test_environ_option_prefix(self):
118 '''Test the environ command with option --prefix
124 file_env_name = prefix + '_launch.sh'
129 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
131 if os.path.exists(expected_file_path):
132 os.remove(expected_file_path)
134 sat.environ(appli + ' --prefix ' + prefix)
136 if os.path.exists(expected_file_path):
139 # pyunit method to compare 2 str
140 self.assertEqual(OK, 'OK')
142 def test_environ_option_shell(self):
143 '''Test the environ command with option --shell
149 file_env_name = 'env_launch.bat'
154 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
156 if os.path.exists(expected_file_path):
157 os.remove(expected_file_path)
159 sat.environ(appli + ' --shell ' + shell)
161 if os.path.exists(expected_file_path):
164 # pyunit method to compare 2 str
165 self.assertEqual(OK, 'OK')
168 if __name__ == '__main__':
169 HTMLTestRunner.main()