From 911273905e57b2a25fa829b301660effc0606eee Mon Sep 17 00:00:00 2001 From: Serge Rehbinder Date: Fri, 11 Mar 2016 15:57:39 +0100 Subject: [PATCH] changing some keys name, factorizing dome code --- commands/patch.py | 28 +- commands/prepare.py | 48 ++++ commands/source.py | 104 ++------ complete_sat.sh | 7 +- data/modules/KERNEL.pyconf | 10 +- data/modules/MODULE_ARCHIVE.pyconf | 6 +- data/modules/MODULE_CVS.pyconf | 11 +- data/modules/MODULE_DEFAULTVERSION.pyconf | 33 +++ data/modules/MODULE_DIR.pyconf | 7 +- data/modules/MODULE_FIXED.pyconf | 13 + data/modules/MODULE_NATIVE.pyconf | 31 +++ data/modules/MODULE_SVN.pyconf | 9 +- data/modules/softA.pyconf | 5 +- data/modules/softB.pyconf | 5 +- src/module.py | 47 +++- test/log/launch_browser.py | 10 +- test/prepare/res.html | 298 ++++++++++++++++++++++ test/prepare/test_prepare.py | 63 +++++ test/run_all.sh | 1 + 19 files changed, 587 insertions(+), 149 deletions(-) create mode 100644 data/modules/MODULE_DEFAULTVERSION.pyconf create mode 100644 data/modules/MODULE_FIXED.pyconf create mode 100644 data/modules/MODULE_NATIVE.pyconf create mode 100644 test/prepare/res.html create mode 100644 test/prepare/test_prepare.py diff --git a/commands/patch.py b/commands/patch.py index 589d9cc..721ed1b 100644 --- a/commands/patch.py +++ b/commands/patch.py @@ -20,6 +20,7 @@ import os import subprocess import src +import prepare # Define all possible option for log command : sat log parser = src.options.Options() @@ -122,29 +123,8 @@ def run(args, runner, logger): runner.cfg.APPLICATION.out_dir, 2) logger.write("\n", 2, False) - # Get the modules to be prepared, regarding the options - if options.modules is None: - # No options, get all modules sources - modules = runner.cfg.APPLICATION.modules - else: - # if option --modules, check that all modules of the command line - # are present in the application. - modules = options.modules - for m in modules: - if m not in runner.cfg.APPLICATION.modules: - raise src.SatException(_("Module %(module)s " - "not defined in application %(application)s") % - { 'module': m, 'application': runner.cfg.VARS.application} ) - - # Construct the list of tuple containing - # the modules name and their definition - modules_infos = src.module.get_modules_infos(modules, runner.cfg) - - # if the --no_sample option is invoked, suppress the sample modules from - # the list - if options.no_sample: - modules_infos = filter(lambda l: not src.module.module_is_sample(l[1]), - modules_infos) + # Get the modules list with modules informations reagrding the options + modules_infos = prepare.get_modules_list(options, runner.cfg, logger) # Get the maximum name length in order to format the terminal display max_module_name_len = 1 @@ -171,7 +151,7 @@ def run(args, runner, logger): res_count = "%d / %d" % (good_result, good_result) else: status = src.KO_STATUS - res_count = "%d / %d" % (good_result, len(modules)) + res_count = "%d / %d" % (good_result, len(modules_infos)) # write results logger.write("Patching sources of the application:", 1) diff --git a/commands/prepare.py b/commands/prepare.py index 4db0527..abb14cb 100644 --- a/commands/prepare.py +++ b/commands/prepare.py @@ -28,6 +28,54 @@ parser.add_option('', 'no_sample', 'boolean', 'no_sample', parser.add_option('f', 'force', 'boolean', 'force', _("force to prepare the modules in development mode.")) +def get_modules_list(options, cfg, logger): + '''method that gives the module list with their informations from + configuration regarding the passed options. + + :param options Options: The Options instance that stores the commands + arguments + :param config Config: The global configuration + :param logger Logger: The logger instance to use for the display and logging + :return: The list of (module name, module_infomrmations). + :rtype: List + ''' + # Get the modules to be prepared, regarding the options + if options.modules is None: + # No options, get all modules sources + modules = cfg.APPLICATION.modules + else: + # if option --modules, check that all modules of the command line + # are present in the application. + modules = options.modules + for m in modules: + if m not in cfg.APPLICATION.modules: + raise src.SatException(_("Module %(module)s " + "not defined in application %(application)s") % + { 'module': m, 'application': cfg.VARS.application} ) + + # Construct the list of tuple containing + # the modules name and their definition + modules_infos = src.module.get_modules_infos(modules, cfg) + + # if the --no_sample option is invoked, suppress the sample modules from + # the list + if options.no_sample: + + lmodules_sample = [m for m in modules_infos if src.module.module_is_sample(m[1])] + + modules_infos = [m for m in modules_infos if m not in lmodules_sample] + + if len(lmodules_sample) > 0: + logger.write(src.printcolors.printcWarning(_("Ignoring the following sample modules:\n")), 1) + for i, module in enumerate(lmodules_sample): + end_text = ', ' + if i+1 == len(lmodules_sample): + end_text = '\n' + + logger.write(module[0] + end_text, 1) + + return modules_infos + def description(): '''method that is called when salomeTools is called with --help option. diff --git a/commands/source.py b/commands/source.py index 18feada..4103f03 100644 --- a/commands/source.py +++ b/commands/source.py @@ -20,6 +20,7 @@ import os import shutil import src +import prepare # Define all possible option for log command : sat log parser = src.options.Options() @@ -240,41 +241,6 @@ def get_sources_from_svn(user, module_info, source_dir, checkout, logger): checkout) return retcode -def get_sources_from_dir(module_info, source_dir, logger): - '''The method called if the module is to be get in dir mode - - :param module_info Config: The configuration specific to - the module to be prepared - :param source_dir Path: The Path instance corresponding to the - directory where to put the sources - :param logger Logger: The logger instance to use for the display and logging - :return: True if it succeed, else False - :rtype: boolean - ''' - # Check if it is a symlink? - use_link = ('symlink' in module_info.dir_info and - module_info.dir_info.symlink) - dirflag = 'dir' - if use_link: dirflag = 'lnk' - - # check that source exists if it is not a symlink - if (not use_link) and (not os.path.exists(module_info.dir_info.dir)): - raise src.SatException(_("Source directory not found: '%s'") % - module_info.dir_info.dir) - - logger.write('%s:%s ... ' % - (dirflag, src.printcolors.printcInfo(module_info.dir_info.dir)), - 3, - False) - logger.flush() - - if use_link: - retcode = src.Path(source_dir).symlink(module_info.dir_info.dir) - else: - retcode = src.Path(module_info.dir_info.dir).copy(source_dir) - - return retcode - def get_module_sources(config, module_info, is_dev, @@ -306,14 +272,14 @@ def get_module_sources(config, logger, pad) - if module_info.get_method == "git": + if module_info.get_sources == "git": return get_sources_from_git(module_info, source_dir, logger, pad, is_dev) - if module_info.get_method == "archive": + if module_info.get_sources == "archive": return get_sources_from_archive(module_info, source_dir, logger) - if module_info.get_method == "cvs": + if module_info.get_sources == "cvs": cvs_user = config.USER.cvs_user return get_sources_from_cvs(cvs_user, module_info, @@ -322,23 +288,30 @@ def get_module_sources(config, logger, pad) - if module_info.get_method == "svn": + if module_info.get_sources == "svn": svn_user = config.USER.svn_user return get_sources_from_svn(svn_user, module_info, source_dir, checkout, logger) - - if module_info.get_method == "dir": - return get_sources_from_dir(module_info, source_dir, logger) + + if module_info.get_sources == "native": + # skip + logger.write('%s ...' % _("native (ignored)"), 3, False) + return True + + if module_info.get_sources == "fixed": + # skip + logger.write('%s ...' % _("fixed (ignored)"), 3, False) + return True - if len(module_info.get_method) == 0: + if len(module_info.get_sources) == 0: # skip logger.write('%s ...' % _("ignored"), 3, False) return True - # if the get_method is not in [git, archive, cvs, svn, dir] + # if the get_sources is not in [git, archive, cvs, svn, dir] logger.write(_("Unknown get_mehtod %(get)s for module %(module)s") % \ - { 'get': module_info.get_method, 'module': module_info.name }, 3, False) + { 'get': module_info.get_sources, 'module': module_info.name }, 3, False) logger.write(" ... ", 3, False) logger.flush() return False @@ -367,7 +340,10 @@ def get_all_module_sources(config, modules, force, logger): for module_name, module_info in modules: # get module name, module informations and the directory where to put # the sources - source_dir = src.Path(module_info.source_dir) + if not src.module.module_is_fixed(module_info): + source_dir = src.Path(module_info.source_dir) + else: + source_dir = src.Path('') # display and log logger.write('%s: ' % src.printcolors.printcLabel(module_name), 3) @@ -453,41 +429,9 @@ def run(args, runner, logger): "on modules in development mode\n\n") logger.write(src.printcolors.printcWarning(msg)) - # Get the modules to be prepared, regarding the options - if options.modules is None: - # No options, get all modules sources - modules = runner.cfg.APPLICATION.modules - else: - # if option --modules, check that all modules of the command line - # are present in the application. - modules = options.modules - for m in modules: - if m not in runner.cfg.APPLICATION.modules: - raise src.SatException(_("Module %(module)s " - "not defined in application %(application)s") % - { 'module': m, 'application': runner.cfg.VARS.application} ) + # Get the modules list with modules informations reagrding the options + modules_infos = prepare.get_modules_list(options, runner.cfg, logger) - # Construct the list of tuple containing - # the modules name and their definition - modules_infos = src.module.get_modules_infos(modules, runner.cfg) - - # if the --no_sample option is invoked, suppress the sample modules from - # the list - if options.no_sample: - - lmodules_sample = [m for m in modules_infos if src.module.module_is_sample(m[1])] - - modules_infos = [m for m in modules_infos if m not in lmodules_sample] - - if len(lmodules_sample) > 0: - logger.write(src.printcolors.printcWarning(_("Ignoring the following sample modules:\n")), 1) - for i, module in enumerate(lmodules_sample): - end_text = ', ' - if i+1 == len(lmodules_sample): - end_text = '\n' - - logger.write(module[0] + end_text, 1) - # Call to the function that gets all the sources good_result, results = get_all_module_sources(runner.cfg, modules_infos, diff --git a/complete_sat.sh b/complete_sat.sh index c78ce05..257ec4b 100755 --- a/complete_sat.sh +++ b/complete_sat.sh @@ -140,7 +140,12 @@ _salomeTools_complete() return 0 ;; source) - opts="--modules --no_sample --force" + opts="--module --no_sample --force" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + patch) + opts="--module --no_sample" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 ;; diff --git a/data/modules/KERNEL.pyconf b/data/modules/KERNEL.pyconf index bb3c00a..06396f4 100644 --- a/data/modules/KERNEL.pyconf +++ b/data/modules/KERNEL.pyconf @@ -1,14 +1,12 @@ -KERNEL_7_7_1 : +KERNEL_V7_7_1 : { name : "KERNEL" - has_gui : "no" - compile_method : "cmake" - get_method : "git" + build_sources : "cmake" + get_sources : "git" git_info: { repo : "http://git.salome-platform.org/gitpub/modules/kernel.git" repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name - tag : 'V7_7_1' } environ : { @@ -19,7 +17,7 @@ KERNEL_7_7_1 : } depend : [] opt_depend : [] - module_type : "sample" + type : "sample" source_dir : $APPLICATION.out_dir + $VARS.sep + 'SOURCES' + $VARS.sep + $name build_dir : $APPLICATION.out_dir + $VARS.sep + 'BUILD' + $VARS.sep + $name } diff --git a/data/modules/MODULE_ARCHIVE.pyconf b/data/modules/MODULE_ARCHIVE.pyconf index 5152d10..5e59cee 100644 --- a/data/modules/MODULE_ARCHIVE.pyconf +++ b/data/modules/MODULE_ARCHIVE.pyconf @@ -1,14 +1,12 @@ MODULE_ARCHIVE : { name : "MODULE_ARCHIVE" - has_gui : "no" compile_method : "cmake" - get_method : "archive" + get_sources : "archive" git_info: { repo : "http://git.salome-platform.org/gitpub/modules/kernel.git" repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name - tag : 'V7_7_1' } archive_info: { @@ -23,7 +21,7 @@ MODULE_ARCHIVE : } depend : [] opt_depend : [] - module_type : "sample" + 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'] diff --git a/data/modules/MODULE_CVS.pyconf b/data/modules/MODULE_CVS.pyconf index c8c75fc..9ce2529 100644 --- a/data/modules/MODULE_CVS.pyconf +++ b/data/modules/MODULE_CVS.pyconf @@ -1,14 +1,12 @@ -MODULE_CVS_6_7_0 : +MODULE_CVS_V6_7_0 : { name : "MODULE_CVS" - has_gui : "no" - compile_method : "cmake" - get_method : "cvs" + build_sources : "cmake" + get_sources : "cvs" git_info: { repo : "http://git.salome-platform.org/gitpub/modules/kernel.git" repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name - tag : 'V7_7_1' } archive_info: { @@ -19,7 +17,6 @@ MODULE_CVS_6_7_0 : server : "cvs.opencascade.com" module_base : "/home/server/cvs/KERNEL" source : 'KERNEL_SRC' - tag : "V6_7_0" } environ : { @@ -30,7 +27,7 @@ MODULE_CVS_6_7_0 : } depend : [] opt_depend : [] - module_type : "sample" + 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 diff --git a/data/modules/MODULE_DEFAULTVERSION.pyconf b/data/modules/MODULE_DEFAULTVERSION.pyconf new file mode 100644 index 0000000..561e047 --- /dev/null +++ b/data/modules/MODULE_DEFAULTVERSION.pyconf @@ -0,0 +1,33 @@ +MODULE_DEFAULTVERSION : +{ + name : "MODULE_DEFAULTVERSION" + build_sources : "cmake" + get_sources : "git" + git_info: + { + repo : "http://git.salome-platform.org/gitpub/modules/kernel.git" + repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name + } + archive_info: + { + archive_name : '' + } + cvs_info: + { + server : "cvs.opencascade.com" + module_base : "/home/server/cvs/KERNEL" + source : 'KERNEL_SRC' + } + 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 diff --git a/data/modules/MODULE_DIR.pyconf b/data/modules/MODULE_DIR.pyconf index bd5e5e6..f51e1e0 100644 --- a/data/modules/MODULE_DIR.pyconf +++ b/data/modules/MODULE_DIR.pyconf @@ -1,14 +1,12 @@ MODULE_DIR : { name : "MODULE_DIR" - has_gui : "no" compile_method : "cmake" - get_method : "dir" + get_sources : "dir" git_info: { repo : "http://git.salome-platform.org/gitpub/modules/kernel.git" repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name - tag : 'V7_7_1' } archive_info: { @@ -21,7 +19,6 @@ MODULE_DIR : svn_info: { repo: 'https://www-svn-corpus.cea.fr/corpus/CORPUS' - tag: 'master' } environ : { @@ -32,7 +29,7 @@ MODULE_DIR : } depend : [] opt_depend : [] - module_type : "sample" + 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 diff --git a/data/modules/MODULE_FIXED.pyconf b/data/modules/MODULE_FIXED.pyconf new file mode 100644 index 0000000..80d90f3 --- /dev/null +++ b/data/modules/MODULE_FIXED.pyconf @@ -0,0 +1,13 @@ +MODULE_FIXED : +{ + name : "MODULE_FIXED" + get_sources : "fixed" + 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}"] + } + type : "sample" +} \ No newline at end of file diff --git a/data/modules/MODULE_NATIVE.pyconf b/data/modules/MODULE_NATIVE.pyconf new file mode 100644 index 0000000..9d853e1 --- /dev/null +++ b/data/modules/MODULE_NATIVE.pyconf @@ -0,0 +1,31 @@ +MODULE_NATIVE : +{ + name : "MODULE_NATIVE" + compile_method : "cmake" + get_sources : "native" + git_info: + { + repo : "http://git.salome-platform.org/gitpub/modules/kernel.git" + repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name + } + archive_info: + { + archive_name : '/data/tmpsalome/salome/prerequis/archives/tclx8.4.tar.bz2' + } + svn_info: + { + repo: 'https://www-svn-corpus.cea.fr/corpus/CORPUS' + } + 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 diff --git a/data/modules/MODULE_SVN.pyconf b/data/modules/MODULE_SVN.pyconf index 228f0e4..a7a45b4 100644 --- a/data/modules/MODULE_SVN.pyconf +++ b/data/modules/MODULE_SVN.pyconf @@ -1,14 +1,12 @@ MODULE_SVN : { name : "MODULE_SVN" - has_gui : "no" - compile_method : "cmake" - get_method : "svn" + build_sources : "cmake" + get_sources : "svn" git_info: { repo : "http://git.salome-platform.org/gitpub/modules/kernel.git" repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name - tag : 'V7_7_1' } archive_info: { @@ -17,7 +15,6 @@ MODULE_SVN : svn_info: { repo: 'https://www-svn-corpus.cea.fr/corpus/CORPUS' - tag: 'master' } environ : { @@ -28,7 +25,7 @@ MODULE_SVN : } depend : [] opt_depend : [] - module_type : "sample" + 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 diff --git a/data/modules/softA.pyconf b/data/modules/softA.pyconf index c1b66bc..f7c0f9b 100644 --- a/data/modules/softA.pyconf +++ b/data/modules/softA.pyconf @@ -1,21 +1,18 @@ softA : { name : "softA" - has_gui : "no" - compile_method : "cmake" # ou autotools, ou script + get_sources : "cmake" # ou autotools, ou script get_method : "git" # "archive", embedded", "native" "fixed" cvs_info: { server : $SITE.prepare.default_cvs_server module_base : $SITE.prepare.cvs_dir + $name source : 'softA_SRC' - tag : '' } git_info: { repo : $SITE.prepare.default_git_server + $VARS.sep + $name repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name - tag : $APPLICATION.default_version_to_download } archive_info: { diff --git a/data/modules/softB.pyconf b/data/modules/softB.pyconf index e433544..31e195d 100644 --- a/data/modules/softB.pyconf +++ b/data/modules/softB.pyconf @@ -1,21 +1,18 @@ softB : { name : "softB" - has_gui : "no" - compile_method : "cmake" # ou autotools, ou script + get_sources : "cmake" # ou autotools, ou script get_method : "git" # "archive", embedded", "native" "fixed" cvs_info: { server : $SITE.prepare.default_cvs_server module_base : $SITE.prepare.cvs_dir + $name source : 'softB_SRC' - tag : '' } git_info: { repo : $SITE.prepare.default_git_server + $VARS.sep + $name repo_dev : $SITE.prepare.default_git_server_dev + $VARS.sep + $name - tag : $APPLICATION.default_version_to_download } archive_info: { diff --git a/src/module.py b/src/module.py index ada190d..c2a4b5f 100644 --- a/src/module.py +++ b/src/module.py @@ -15,12 +15,14 @@ # 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 -'''In this file are implemented the classes and method +'''In this file are implemented the classes and methods relative to the module notion of salomeTools ''' import src +AVAILABLE_VCS = ['git', 'svn', 'cvs'] + def get_module_config(config, module_name, version): '''Get the specific configuration of a module from the global configuration @@ -50,6 +52,26 @@ def get_module_config(config, module_name, version): for depend in mod_info.opt_depend: if depend in config.MODULES: mod_info.depend.append(depend,'') + + # Check if the module is defined as native in the application + pass # to be done + + # In case of a module get with a vcs, put the tag (equal to the version) + if mod_info is not None and mod_info.get_sources in AVAILABLE_VCS: + + if mod_info.get_sources == 'git': + mod_info.git_info.tag = version + + if mod_info.get_sources == 'svn': + mod_info.svn_info.tag = version + + if mod_info.get_sources == 'cvs': + mod_info.cvs_info.tag = version + + # In case of a fixed module, define the install_dir (equal to the version) + if mod_info is not None and mod_info.get_sources=="fixed": + mod_info.install_dir = version + return mod_info def get_modules_infos(lmodules, config): @@ -65,7 +87,11 @@ def get_modules_infos(lmodules, config): # Loop on module names for mod in lmodules: # Get the version of the module from the application definition - version_mod = config.APPLICATION.modules[mod][0] + version_mod = config.APPLICATION.modules[mod] + # if no version, then take the default one defined in the application + if isinstance(version_mod, bool): + version_mod = config.APPLICATION.tag + # Get the specific configuration of the module mod_info = get_module_config(config, mod, version_mod) if mod_info is not None: @@ -80,9 +106,20 @@ def module_is_sample(module_info): '''Know if a module has the sample type :param module_info Config: The configuration specific to - the module to be prepared + the module :return: True if the module has the sample type, else False :rtype: boolean ''' - mtype = module_info.module_type - return mtype.lower() == 'sample' \ No newline at end of file + mtype = module_info.type + return mtype.lower() == 'sample' + +def module_is_fixed(module_info): + '''Know if a module is fixed + + :param module_info Config: The configuration specific to + the module + :return: True if the module is fixed, else False + :rtype: boolean + ''' + get_src = module_info.get_sources + return get_src.lower() == 'fixed' \ No newline at end of file diff --git a/test/log/launch_browser.py b/test/log/launch_browser.py index 369deef..2eb9698 100644 --- a/test/log/launch_browser.py +++ b/test/log/launch_browser.py @@ -36,7 +36,7 @@ from tools import outRedirection import HTMLTestRunner import src.xmlManager -sleep_time = 3 +sleep_time = 2 class TestLog(unittest.TestCase): '''Test of log command: launch of browser @@ -49,6 +49,7 @@ class TestLog(unittest.TestCase): OK = "KO" sat = Sat("-oUSER.browser='konqueror'") + time.sleep(sleep_time) cmd_log = threading.Thread(target=sat.log, args=('',)) cmd_log.start() @@ -100,7 +101,7 @@ class TestLog(unittest.TestCase): OK = "OK" sys.stdin = sys.__stdin__ except: - pass + sys.stdin = sys.__stdin__ # pyunit method to compare 2 str self.assertEqual(OK, "OK") @@ -120,7 +121,7 @@ class TestLog(unittest.TestCase): sys.stdin = io.StringIO(one) try: - sat.log('appli-test --last') + sat.log('appli-test -t --last') OK = "OK" sys.stdin = sys.__stdin__ except: @@ -252,6 +253,8 @@ class TestLog(unittest.TestCase): sat.config('appli-test -v VARS.python') + + time.sleep(sleep_time) cmd_log = threading.Thread(target=sat.log, args=('appli-test --last',)) cmd_log.start() @@ -326,6 +329,7 @@ class TestLog(unittest.TestCase): OK = "KO" sat = Sat("-oUSER.browser='konqueror'") + time.sleep(sleep_time) cmd_log = threading.Thread(target=sat.log, args=('--full',)) cmd_log.start() diff --git a/test/prepare/res.html b/test/prepare/res.html new file mode 100644 index 0000000..42ebed3 --- /dev/null +++ b/test/prepare/res.html @@ -0,0 +1,298 @@ + + + + + Unit Test Report + + + + + + + + + +
+

Unit Test Report

+

Start Time: 2016-03-11 15:04:07

+

Duration: 0:01:32.373196

+

Status: Pass 1

+ +

+
+ + + +

Show +Summary +Failed +All +

+ ++++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Test Group/Test caseCountPassFailErrorView
TestLog: Test of log command: launch of browser1100Detail
test_prepare_all: Test the prepare command with many ways to prepare
+ + + + pass + + + + +
Total1100 
+ +
 
+ + + diff --git a/test/prepare/test_prepare.py b/test/prepare/test_prepare.py new file mode 100644 index 0000000..00d8e97 --- /dev/null +++ b/test/prepare/test_prepare.py @@ -0,0 +1,63 @@ +#!/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 io + +# 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 +from tools import outRedirection +import HTMLTestRunner +import src.xmlManager + +sleep_time = 3 + +class TestLog(unittest.TestCase): + '''Test of the prepare command + ''' + + def test_prepare_all(self): + '''Test the prepare command with many ways to prepare + ''' + + OK = "KO" + + sat = Sat() + + try: + sat.prepare('appli-test') + OK = "OK" + except: + pass + + + # pyunit method to compare 2 str + self.assertEqual(OK, "OK") + + +# test launch +if __name__ == '__main__': + HTMLTestRunner.main() diff --git a/test/run_all.sh b/test/run_all.sh index b9bed1a..bf13d1f 100755 --- a/test/run_all.sh +++ b/test/run_all.sh @@ -22,4 +22,5 @@ coverage run --source=../commands/config.py -a config/create_user_pyconf.py >> t 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/source.py,../commands/patch.py,../commands/prepare.py,../src/module.py -a prepare/test_prepare.py >> test_res.html coverage html -- 2.39.2