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
27 class TestSource(unittest.TestCase):
28 """Test of the environ command"""
31 # Test the environ command without any option
36 file_env_name = "env_launch.sh"
41 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
43 if os.path.exists(expected_file_path):
44 os.remove(expected_file_path)
48 if os.path.exists(expected_file_path):
50 self.assertEqual(OK, "OK")
53 # Test the environ command with option '--products'
57 product_name = "PRODUCT_GIT"
59 file_env_name = "env_launch.sh"
64 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
66 if os.path.exists(expected_file_path):
67 os.remove(expected_file_path)
69 sat.environ(appli + " --products " + product_name)
71 if os.path.exists(expected_file_path):
73 self.assertEqual(OK, "OK")
76 # Test the environ command with option --target
81 file_env_name = "env_launch.sh"
86 expected_file_path = os.path.join(".", file_env_name)
87 expected_file_path2 = os.path.join(".", "env_build.sh")
89 if os.path.exists(expected_file_path):
90 os.remove(expected_file_path)
92 sat.environ(appli + " --target .")
94 if os.path.exists(expected_file_path):
97 if os.path.exists(expected_file_path):
98 os.remove(expected_file_path)
99 os.remove(expected_file_path2)
101 # pyunit method to compare 2 str
102 self.assertEqual(OK, "OK")
105 # Test the environ command with option --prefix
110 file_env_name = prefix + "_launch.sh"
115 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
117 if os.path.exists(expected_file_path):
118 os.remove(expected_file_path)
120 sat.environ(appli + " --prefix " + prefix)
122 if os.path.exists(expected_file_path):
124 self.assertEqual(OK, "OK")
127 # Test the environ command with option --shell
132 file_env_name = "env_launch.bat"
137 expected_file_path = os.path.join(sat.cfg.APPLICATION.workdir, file_env_name)
139 if os.path.exists(expected_file_path):
140 os.remove(expected_file_path)
142 sat.environ(appli + " --shell " + shell)
144 if os.path.exists(expected_file_path):
146 self.assertEqual(OK, "OK")
150 if __name__ == "__main__":