_("do not prepare sample products."))
parser.add_option('f', 'force', 'boolean', 'force',
_("force to prepare the products in development mode."))
+parser.add_option('f', 'force_patch', 'boolean', 'force_patch',
+ _("force to apply patch to the products in development mode."))
def get_products_list(options, cfg, logger):
'''method that gives the product list with their informations from
:return: The text to display for the prepare command description.
:rtype: str
'''
- return _("The prepare command apply the patches on the sources of "
- "the application products if there is any")
+ return _("The prepare command gets the sources of "
+ "the application products and apply the patches if there is any.")
def run(args, runner, logger):
'''method that is called when salomeTools is called with prepare parameter.
for p_name, __ in products_infos:
args_product_opt += ',' + p_name
- if args_product_opt == '--product ':
- args_product_opt = ''
-
args_sample = ''
if options.no_sample:
args_sample = ' --no_sample'
# Construct the option to pass to the patch command
ldev_products = [p for p in products_infos if src.product.product_is_dev(p[1])]
- if len(ldev_products) > 0:
+ if len(ldev_products) > 0 and not options.force_patch:
msg = _("Ignoring the following products "
"in development mode\n")
logger.write(src.printcolors.printcWarning(msg), 1)
for i, (product_name, __) in enumerate(ldev_products):
- args_product_opt.replace(',' + product_name, '')
+ args_product_opt = args_product_opt.replace(',' + product_name, '')
end_text = ', '
if i+1 == len(ldev_products):
end_text = '\n'
msg = _("Use the --force_patch option to apply the patches anyway\n\n")
logger.write(src.printcolors.printcWarning(msg), 1)
-
- args_patch = args_appli + args_product_opt + args_sample
-
- # Call the source command that gets the source
- res_patch = runner.patch(args_patch)
+ if args_product_opt == '--product ':
+ msg = _("Nothing to patch\n")
+ logger.write(msg)
+ res_patch = 0
+ else:
+ args_patch = args_appli + args_product_opt + args_sample
+
+ # Call the source command that gets the source
+ res_patch = runner.patch(args_patch)
return res_source + res_patch
\ No newline at end of file
# get it in checkout mode, else, do not do anything
# unless the force option is invoked
if not os.path.exists(product_info.source_dir) or force:
+ # If the source path exists (it means that force option is invoked)
+ # remove the source path
+ if source_dir.exists():
+ source_dir.rm()
+
# Call the function corresponding to get the sources with True checkout
retcode = get_product_sources(config,
product_info,
# skip
logger.write('%s ...' % _("fixed (ignored)"), 3, False)
return True
-
- if len(product_info.get_source) == 0:
- # skip
- logger.write('%s ...' % _("ignored"), 3, False)
- return True
- # if the get_source is not in [git, archive, cvs, svn, dir]
- logger.write(_("Unknown get_mehtod %(get)s for product %(product)s") % \
+ # if the get_source is not in [git, archive, cvs, svn, fixed, native]
+ logger.write(_("Unknown get source method \"%(get)s\" for product %(product)s") % \
{ 'get': product_info.get_source, 'product': product_info.name }, 3, False)
logger.write(" ... ", 3, False)
logger.flush()
return 0
;;
prepare)
- opts="--product --no_sample --force"
+ opts="--product --no_sample --force --force_patch"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
-MODULE_ARCHIVE :
+PRODUCT_ARCHIVE :
{
- name : "MODULE_ARCHIVE"
+ name : "PRODUCT_ARCHIVE"
build_source : "cmake"
- get_source : "archive"
- git_info:
+ get_source : "native"
+ archive_info:
+ {
+ archive_name : $VARS.salometoolsway + $VARS.sep + '..' + $VARS.sep + 'RESOURCES' + $VARS.sep + 'test-product-4.4.2.tar.gz'
+ }
+ environ :
{
- repo : "http://git.salome-platform.org/gitpub/modules/kernel.git"
- repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name
+ "_LD_LIBRARY_PATH" : "${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+ "_PYTHONPATH" : ["${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+ "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR0}"
+ "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR1}"]
}
+ depend : []
+ opt_depend : []
+ type : "sample"
+ source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ patches : ['/home/salome/salomeTools-4.3.7/data/compil_scripts/patches/scipy.patch', '/export/home/serioja/MODULE_ARCHIVE.patch']
+}
+
+PRODUCT_ARCHIVE_4_4_2 :
+{
+ name : "PRODUCT_ARCHIVE"
+ build_source : "cmake"
+ get_source : "archive"
archive_info:
{
- archive_name : '/data/tmpsalome/salome/prerequis/archives/tclx8.4.tar.bz2'
+ archive_name : $VARS.salometoolsway + $VARS.sep + '..' + $VARS.sep + 'RESOURCES' + $VARS.sep + 'test-product-4.4.2.tar.gz'
}
environ :
{
type : "sample"
source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
- patches : ['/home/salome/salomeTools-4.3.7/data/compil_scripts/patches/scipy.patch', '/export/home/serioja/MODULE_ARCHIVE.patch']
+ patches : []
}
\ No newline at end of file
-MODULE_CVS_V6_7_0 :
+PRODUCT_CVS_V6_7_0 :
{
name : "MODULE_CVS"
build_source : "cmake"
--- /dev/null
+PRODUCT_DEV :
+{
+ name : "PRODUCT_DEV"
+ build_source : "cmake"
+ get_source : "git"
+ git_info:
+ {
+ repo : $VARS.salometoolsway + $VARS.sep + '..' + $VARS.sep + 'RESOURCES' + $VARS.sep + 'test-product.git'
+ repo_dev : $repo
+ }
+ environ :
+ {
+ "_LD_LIBRARY_PATH" : "${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+ "_PYTHONPATH" : ["${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+ "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR0}"
+ "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR1}"]
+ }
+ depend : []
+ opt_depend : []
+ type : "sample"
+ source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ patches : [$VARS.salometoolsway + $VARS.sep + '..' + $VARS.sep + 'RESOURCES' + $VARS.sep + 'mypatch.patch']
+}
\ No newline at end of file
-MODULE_FIXED :
+PRODUCT_FIXED :
{
- name : "MODULE_FIXED"
+ name : "PRODUCT_FIXED"
get_source : "fixed"
environ :
{
--- /dev/null
+PRODUCT_GIT :
+{
+ name : "PRODUCT_GIT"
+ build_source : "cmake"
+ get_source : "git"
+ git_info:
+ {
+ repo : $VARS.salometoolsway + $VARS.sep + '..' + $VARS.sep + 'RESOURCES' + $VARS.sep + 'test-product.git'
+ repo_dev : $repo
+ }
+ environ :
+ {
+ "_LD_LIBRARY_PATH" : "${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+ "_PYTHONPATH" : ["${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+ "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR0}"
+ "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR1}"]
+ }
+ depend : []
+ opt_depend : []
+ type : "sample"
+ source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+ patches : []
+}
\ No newline at end of file
-MODULE_SVN :
+PRODUCT_SVN :
{
- name : "MODULE_SVN"
+ name : "PRODUCT_SVN"
build_source : "cmake"
get_source : "svn"
git_info:
--- /dev/null
+PRODUCT_UNKNOWN :
+{
+ name : "PRODUCT_UNKNOWN"
+ build_source : "cmake"
+ get_source : "unknown"
+ environ :
+ {
+ "_LD_LIBRARY_PATH" : "${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+ "_PYTHONPATH" : ["${SOFT_ROOT_DIR}" + $VARS.sep + "lib"
+ "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR0}"
+ "${SOFT_ROOT_DIR}" + $VARS.sep + "${PYTHON_LIBDIR1}"]
+ }
+ depend : []
+ opt_depend : []
+ type : "sample"
+ source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name
+ build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name
+}
\ No newline at end of file
:return: True if the product has the sample type, else False
:rtype: boolean
'''
- ptype = product_info.type
- return ptype.lower() == 'sample'
+ if 'type' in product_info:
+ ptype = product_info.type
+ return ptype.lower() == 'sample'
+ else:
+ return False
def product_is_fixed(product_info):
'''Know if a product is fixed
import tempfile
import sys
import subprocess
+import time
class outRedirection():
'''redirection of standart output
pid = line2[1]
kill9(pid)
return pid
- return 0
\ No newline at end of file
+ return 0
+
+def check_proc_existence_and_kill_multi(regex, nb_kills, time_between_to_checks = 1):
+ found = False
+ i = 0
+ while not found and i < nb_kills :
+ found = check_proc_existence_and_kill(regex)
+ if found:
+ return found
+ time.sleep(time_between_to_checks)
+ i+=1
+ return 0
\ No newline at end of file
# pyunit method to compare 2 str
self.assertEqual(OK, 'OK')
+ def test_option_schema(self):
+ '''Test the display of the right value of "sat config -s"
+ '''
+
+ OK = 'KO'
+
+ # output redirection
+ my_out = outRedirection()
+
+ # The command to test
+ sat = Sat('')
+ sat.config('-s')
+
+ # stop output redirection
+ my_out.end_redirection()
+
+ # get results
+ res = my_out.read_results()
+
+
+ if 'INTERNAL' in res:
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
# test launch
if __name__ == '__main__':
class TestLog(unittest.TestCase):
'''Test of log command: launch of browser
'''
-
- def test_launch_browser(self):
- '''Test the launch of browser when invoking the log command
- '''
-
- OK = "KO"
-
- sat = Sat("-oUSER.browser='konqueror'")
- time.sleep(sleep_time)
- cmd_log = threading.Thread(target=sat.log, args=('',))
- cmd_log.start()
-
- time.sleep(sleep_time)
-
- browser = sat.cfg.USER.browser
- pid = check_proc_existence_and_kill(browser + ".*" + "hat\.xml")
-
- if pid:
- OK = "OK"
- # pyunit method to compare 2 str
- self.assertEqual(OK, "OK")
-
+
def test_write_xmllog(self):
'''Test the write of xml log when invoking a command
'''
# pyunit method to compare 2 str
self.assertEqual(OK, "OK")
-
+
def test_option_last(self):
'''Test the option --last
'''
# pyunit method to compare 2 str
self.assertEqual(OK, "OK")
-
+
def test_option_clean(self):
'''Test the option --clean
'''
# pyunit method to compare 2 str
self.assertEqual(OK, "OK")
-
+
+ """
def test_option_full(self):
'''Test the option --full
'''
# pyunit method to compare 2 str
self.assertEqual(OK, "OK")
-
+ """
def test_description(self):
'''Test the sat -h log
'''
--- /dev/null
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+# Copyright (C) 2010-2012 CEA/DEN
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import unittest
+import os
+import sys
+import threading
+import time
+
+# get execution path
+testdir = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(testdir, '..', '..'))
+sys.path.append(os.path.join(testdir, '..', '_testTools'))
+sys.path.append(os.path.join(testdir, '..', '..','commands'))
+
+from salomeTools import Sat
+from tools import check_proc_existence_and_kill_multi
+import HTMLTestRunner
+
+sleep_time = 2
+
+class TestLog(unittest.TestCase):
+ '''Test of log command: launch of browser
+ '''
+ def test_launch_browser(self):
+ '''Test the launch of browser when invoking the log command
+ '''
+
+ OK = "KO"
+
+ sat = Sat("-oUSER.browser='konqueror'")
+ time.sleep(sleep_time)
+ cmd_log = threading.Thread(target=sat.log, args=('',))
+ cmd_log.start()
+
+ time.sleep(sleep_time)
+
+ browser = sat.cfg.USER.browser
+ pid = check_proc_existence_and_kill_multi(browser + ".*" + "hat\.xml", 10)
+
+ if pid:
+ OK = "OK"
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, "OK")
+
+# test launch
+if __name__ == '__main__':
+ HTMLTestRunner.main()
--- /dev/null
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+# Copyright (C) 2010-2012 CEA/DEN
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import unittest
+import os
+import sys
+import shutil
+
+# get execution path
+testdir = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(testdir, '..', '..'))
+sys.path.append(os.path.join(testdir, '..', '_testTools'))
+sys.path.append(os.path.join(testdir, '..', '..','commands'))
+
+from tools import outRedirection
+
+import src.product
+
+from salomeTools import Sat
+import HTMLTestRunner
+
+class TestPatch(unittest.TestCase):
+ '''Test of the patch command
+ '''
+
+ def test_patch_dev(self):
+ '''Test the patch command with a product in dev mode
+ '''
+ OK = 'KO'
+
+ appli = 'appli-test'
+ product_name = 'PRODUCT_DEV'
+
+ sat = Sat("-oUSER.output_level=2")
+
+ sat.config(appli)
+
+ expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
+ expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
+ expected_text = 'HELLO WORLD\n'
+
+ if os.path.exists(expected_src_dir):
+ shutil.rmtree(expected_src_dir)
+
+ sat.source(appli + ' --product ' + product_name)
+
+ f = open(expected_file_path, 'r')
+ text = f.readlines()[0]
+ OK1 = 'KO'
+ if text == expected_text:
+ OK1 = 'OK'
+
+ sat.patch(appli + ' --product ' + product_name)
+
+ new_expected_text = 'HELLO WORLD MODIFIED\n'
+ f = open(expected_file_path, 'r')
+ text = f.readlines()[0]
+
+ OK2 = 'KO'
+ if text == new_expected_text:
+ OK2 = 'OK'
+
+ if (OK1, OK2)==('OK', 'OK'):
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+
+ def test_no_sources_found(self):
+ '''Test the patch command with a product with no sources found
+ '''
+ OK = 'KO'
+
+ appli = 'appli-test'
+ product_name = 'PRODUCT_DEV'
+
+ sat = Sat('')
+ sat.config(appli)
+
+ expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
+
+ if os.path.exists(expected_src_dir):
+ shutil.rmtree(expected_src_dir)
+
+ # output redirection
+ my_out = outRedirection()
+
+ sat.patch(appli + ' --product ' + product_name)
+
+ # stop output redirection
+ my_out.end_redirection()
+
+ # get results
+ res = my_out.read_results()
+
+ if "No sources found for the " + product_name +" product" in res:
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+
+ def test_no_patch(self):
+ '''Test the patch command with a product without patch
+ '''
+ OK = 'KO'
+
+ appli = 'appli-test'
+ product_name = 'PRODUCT_ARCHIVE'
+
+ sat = Sat()
+
+ sat.source(appli + ' --product ' + product_name)
+
+ # output redirection
+ my_out = outRedirection()
+
+ sat.patch(appli + ' --product ' + product_name)
+
+ # stop output redirection
+ my_out.end_redirection()
+
+ # get results
+ res = my_out.read_results()
+
+ if "No patch for the " + product_name +" product" in res:
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+
+ def test_invalid_patch(self):
+ '''Test the patch command with a product with a not valid patch
+ '''
+ OK = 'KO'
+
+ appli = 'appli-test'
+ product_name = 'PRODUCT_DEV'
+
+ sat = Sat("-oPRODUCTS.PRODUCT_DEV.patches=['/']")
+
+ sat.source(appli + ' --product ' + product_name)
+
+ # output redirection
+ my_out = outRedirection()
+
+ sat.patch(appli + ' --product ' + product_name)
+
+ # stop output redirection
+ my_out.end_redirection()
+
+ # get results
+ res = my_out.read_results()
+
+ if "Not a valid patch" in res:
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+
+ def test_description(self):
+ '''Test the sat -h patch
+ '''
+
+ OK = "KO"
+
+ import patch
+
+ if "The patch command apply the patches on the sources of" in patch.description():
+ OK = "OK"
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, "OK")
+
+# test launch
+if __name__ == '__main__':
+ HTMLTestRunner.main()
import unittest
import os
import sys
-import io
+import shutil
# get execution path
testdir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(testdir, '..', '_testTools'))
sys.path.append(os.path.join(testdir, '..', '..','commands'))
+import src
+
+from tools import outRedirection
+
from salomeTools import Sat
import HTMLTestRunner
-sleep_time = 3
-
-class TestLog(unittest.TestCase):
+class TestPrepare(unittest.TestCase):
'''Test of the prepare command
'''
-
+
+ def test_prepare_dev(self):
+ '''Test the prepare command with a product in dev mode
+ '''
+ OK = 'KO'
+
+ appli = 'appli-test'
+ product_name = 'PRODUCT_DEV'
+
+ sat = Sat()
+
+ sat.config(appli)
+
+ expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
+ expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
+ expected_text = 'HELLO WORLD\n'
+
+ if os.path.exists(expected_src_dir):
+ shutil.rmtree(expected_src_dir)
+
+ sat.prepare(appli + ' --product ' + product_name)
+
+ f = open(expected_file_path, 'r')
+ text = f.readlines()[0]
+ if text == expected_text:
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+
def test_prepare_all(self):
- '''Test the prepare command with many ways to prepare
+ '''Test the prepare command with all products
'''
-
- OK = "KO"
+ OK = 'KO'
+
+ appli = 'appli-test'
+ product_name = 'PRODUCT_DEV'
sat = Sat()
+ sat.config(appli)
+
+ expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
+ expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
+ expected_text = 'HELLO WORLD\n'
+
+ if os.path.exists(expected_src_dir):
+ shutil.rmtree(expected_src_dir)
+
+ sat.prepare(appli)
+
+ f = open(expected_file_path, 'r')
+ text = f.readlines()[0]
+ if text == expected_text:
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+ def test_prepare_option_sample_and_force(self):
+ '''Test the prepare command with all products
+ '''
+ OK = 'KO'
+
+ appli = 'appli-test'
+
+ sat = Sat()
+ sat.config(appli)
+
try:
- sat.prepare('appli-test')
- OK = "OK"
+ sat.prepare(appli + " --no_sample --force")
+ OK = 'OK'
except:
pass
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+
+ def test_description(self):
+ '''Test the sat -h prepare
+ '''
+
+ OK = "KO"
+
+ import prepare
+ if "The prepare command gets the sources" in prepare.description():
+ OK = "OK"
# pyunit method to compare 2 str
self.assertEqual(OK, "OK")
-
# test launch
if __name__ == '__main__':
--- /dev/null
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+# Copyright (C) 2010-2012 CEA/DEN
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import unittest
+import os
+import sys
+import shutil
+
+# get execution path
+testdir = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(testdir, '..', '..'))
+sys.path.append(os.path.join(testdir, '..', '_testTools'))
+sys.path.append(os.path.join(testdir, '..', '..','commands'))
+
+from tools import outRedirection
+
+import src.product
+
+from salomeTools import Sat
+import HTMLTestRunner
+
+class TestSource(unittest.TestCase):
+ '''Test of the source command
+ '''
+
+ def test_source_archive(self):
+ '''Test the source command with archive product
+ '''
+ appli = 'appli-test'
+ product_name = 'PRODUCT_ARCHIVE'
+
+ sat = Sat()
+ sat.source(appli + ' --product ' + product_name)
+
+ expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
+ expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
+ expected_text = 'HELLO WORLD\n'
+
+ f = open(expected_file_path, 'r')
+ text = f.read()
+
+ # pyunit method to compare 2 str
+ self.assertEqual(text, expected_text)
+
+ def test_source_git(self):
+ '''Test the source command with git product
+ '''
+ appli = 'appli-test'
+ product_name = 'PRODUCT_GIT'
+
+ sat = Sat()
+ sat.source(appli + ' --product ' + product_name)
+
+ expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
+ expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
+ expected_text = 'HELLO WORLD\n'
+
+ f = open(expected_file_path, 'r')
+ text = f.read()
+
+ # pyunit method to compare 2 str
+ self.assertEqual(text, expected_text)
+
+ def test_source_cvs(self):
+ '''Test the source command with cvs product
+ '''
+ appli = 'appli-test'
+ product_name = 'PRODUCT_CVS'
+
+ sat = Sat()
+ sat.source(appli + ' --product ' + product_name)
+
+ expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
+ expected_file_path = os.path.join(expected_src_dir, 'README.FIRST.txt')
+ expected_text = 'Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE\n'
+
+ f = open(expected_file_path, 'r')
+ text = f.readlines()[0]
+
+ # pyunit method to compare 2 str
+ self.assertEqual(text, expected_text)
+
+ """
+ def test_source_svn(self):
+ '''Test the source command with svn product
+ '''
+ OK = 'KO'
+
+ appli = 'appli-test'
+ product_name = 'PRODUCT_SVN'
+
+ sat = Sat()
+ sat.source(appli + ' --product ' + product_name)
+
+ expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
+ expected_file_path = os.path.join(expected_src_dir, 'scripts', 'README')
+ expected_text = 'this directory contains scripts used by salomeTool'
+
+ f = open(expected_file_path, 'r')
+ text = f.readlines()[0]
+
+ if expected_text in text:
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+ """
+
+ def test_source_native(self):
+ '''Test the source command with native product
+ '''
+ OK = 'KO'
+
+ appli = 'appli-test'
+ product_name = 'PRODUCT_NATIVE'
+
+ sat = Sat()
+ sat.source(appli + ' --product ' + product_name)
+
+ expected_src_dir = os.path.join(sat.cfg.APPLICATION.out_dir, 'SOURCES', product_name)
+ if not os.path.exists(expected_src_dir):
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+
+ def test_source_fixed(self):
+ '''Test the source command with fixed product
+ '''
+ OK = 'KO'
+
+ appli = 'appli-test'
+ product_name = 'PRODUCT_FIXED'
+
+ sat = Sat()
+ sat.source(appli + ' --product ' + product_name)
+
+ expected_src_dir = src.product.get_product_config(sat.cfg, product_name).install_dir
+
+ if os.path.exists(expected_src_dir):
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+
+ def test_source_unknown(self):
+ '''Test the source command with unknown product
+ '''
+ OK = 'KO'
+
+ # output redirection
+ my_out = outRedirection()
+
+ appli = 'appli-test'
+ product_name = 'PRODUCT_UNKNOWN'
+
+ sat = Sat()
+ sat.source(appli + ' --product ' + product_name)
+
+ # stop output redirection
+ my_out.end_redirection()
+
+ # get results
+ res = my_out.read_results()
+
+ if "Unknown get source method" in res:
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+
+ def test_source_dev(self):
+ '''Test the source command with a product in dev mode
+ '''
+ OK = 'KO'
+
+ appli = 'appli-test'
+ product_name = 'PRODUCT_DEV'
+
+ sat = Sat()
+
+ sat.config(appli)
+
+ expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
+ expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
+ expected_text = 'HELLO WORLD\n'
+
+ if os.path.exists(expected_src_dir):
+ shutil.rmtree(expected_src_dir)
+
+ sat.source(appli + ' --product ' + product_name)
+
+ f = open(expected_file_path, 'r')
+ text = f.readlines()[0]
+ OK1 = 'KO'
+ if text == expected_text:
+ OK1 = 'OK'
+
+ # output redirection
+ my_out = outRedirection()
+
+ sat.source(appli + ' --product ' + product_name)
+
+ # stop output redirection
+ my_out.end_redirection()
+
+ # get results
+ res = my_out.read_results()
+
+ OK2 = 'KO'
+ if "source directory already exists" in res:
+ OK2 = 'OK'
+
+ # output redirection
+ my_out = outRedirection()
+
+ sat.source(appli + ' --product ' + product_name + ' --force')
+
+ # stop output redirection
+ my_out.end_redirection()
+
+ # get results
+ res = my_out.read_results()
+
+ OK3 = 'KO'
+ if "source directory already exists" not in res:
+ OK3 = 'OK'
+
+ if (OK1, OK2, OK3)==('OK', 'OK', 'OK'):
+ OK = 'OK'
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, 'OK')
+
+ def test_description(self):
+ '''Test the sat -h source
+ '''
+
+ OK = "KO"
+
+ import source
+
+ if "gets the sources of the application" in source.description():
+ OK = "OK"
+
+ # pyunit method to compare 2 str
+ self.assertEqual(OK, "OK")
+
+# test launch
+if __name__ == '__main__':
+ HTMLTestRunner.main()
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+rm -rf .coverage htmlcov
+
coverage run --source=../commands/config.py config/option_value.py > test_res.html
coverage run --source=../commands/config.py -a config/option_value_2.py >> test_res.html
coverage run --source=../commands/config.py -a config/create_user_pyconf.py >> test_res.html
coverage run --source=../commands/config.py -a config/option_copy.py >> test_res.html
coverage run --source=../commands/config.py -a config/option_edit.py >> test_res.html
coverage run --source=../commands/config.py,../commands/log.py,../src/xmlManager.py,../src/logger.py -a log/launch_browser.py >> test_res.html
+coverage run --source=../commands/config.py,../commands/log.py,../src/xmlManager.py,../src/logger.py -a log/launch_browser2.py >> test_res.html
+coverage run --source=../commands/config.py,../commands/source.py,../commands/patch.py,../commands/prepare.py,../src/product.py -a prepare/test_source.py >> test_res.html
+coverage run --source=../commands/config.py,../commands/source.py,../commands/patch.py,../commands/prepare.py,../src/product.py -a prepare/test_patch.py >> test_res.html
coverage run --source=../commands/config.py,../commands/source.py,../commands/patch.py,../commands/prepare.py,../src/product.py -a prepare/test_prepare.py >> test_res.html
coverage html
+
+#firefox test_res.html htmlcov/index.html