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 class TestSource(unittest.TestCase):
27 """Test of the environ command"""
30 # Test the environ command without any option
35 file_env_name = 'env_launch.sh'
40 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
42 if os.path.exists(expected_file_path):
43 os.remove(expected_file_path)
47 if os.path.exists(expected_file_path):
49 self.assertEqual(OK, 'OK')
52 # Test the environ command with option '--products'
56 product_name = 'PRODUCT_GIT'
58 file_env_name = 'env_launch.sh'
63 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
65 if os.path.exists(expected_file_path):
66 os.remove(expected_file_path)
68 sat.environ(appli + ' --products ' + product_name)
70 if os.path.exists(expected_file_path):
72 self.assertEqual(OK, 'OK')
75 # Test the environ command with option --target
80 file_env_name = 'env_launch.sh'
85 expected_file_path = os.path.join('.', file_env_name)
86 expected_file_path2 = os.path.join('.', 'env_build.sh')
88 if os.path.exists(expected_file_path):
89 os.remove(expected_file_path)
91 sat.environ(appli + ' --target .')
93 if os.path.exists(expected_file_path):
96 if os.path.exists(expected_file_path):
97 os.remove(expected_file_path)
98 os.remove(expected_file_path2)
100 # pyunit method to compare 2 str
101 self.assertEqual(OK, 'OK')
104 # Test the environ command with option --prefix
109 file_env_name = prefix + '_launch.sh'
114 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
116 if os.path.exists(expected_file_path):
117 os.remove(expected_file_path)
119 sat.environ(appli + ' --prefix ' + prefix)
121 if os.path.exists(expected_file_path):
123 self.assertEqual(OK, 'OK')
126 # Test the environ command with option --shell
131 file_env_name = 'env_launch.bat'
136 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
138 if os.path.exists(expected_file_path):
139 os.remove(expected_file_path)
141 sat.environ(appli + ' --shell ' + shell)
143 if os.path.exists(expected_file_path):
145 self.assertEqual(OK, 'OK')
148 if __name__ == '__main__':