From: Serge Rehbinder Date: Thu, 21 Apr 2016 07:10:24 +0000 (+0200) Subject: Update the tests X-Git-Tag: sprint-04~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c599cfed181749f9e0ef99923cb67186c9a0c212;p=tools%2Fsat.git Update the tests --- diff --git a/commands/prepare.py b/commands/prepare.py index eeb47d2..073e980 100644 --- a/commands/prepare.py +++ b/commands/prepare.py @@ -16,6 +16,8 @@ # 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 re + import src # Define all possible option for prepare command : sat prepare @@ -132,19 +134,35 @@ def run(args, runner, logger): ldev_products, logger) logger.write("\n", 1) - + # Construct the final commands arguments args_clean = args_appli + args_product_opt_clean + " --source" args_source = args_appli + args_product_opt args_patch = args_appli + args_product_opt_patch + + # If there is no more any product in the command arguments, + # do not call the concerned command + oExpr = re.compile("^--product *$") + do_clean = not(oExpr.search(args_product_opt_clean)) + do_source = not(oExpr.search(args_product_opt)) + do_patch = not(oExpr.search(args_product_opt_patch)) + + + # Initialize the results to a failing status + res_clean = 1 + res_source = 1 + res_patch = 1 # Call the commands using the API - msg = _("Clean the source directories ...") - logger.write(msg, 3) - res_clean = runner.clean(args_clean, batch=True, verbose = 0) - if res_clean == 0: - logger.write('%s\n' % src.printcolors.printc(src.OK_STATUS), 3) - res_source = runner.source(args_source) - res_patch = runner.patch(args_patch) + if do_clean: + msg = _("Clean the source directories ...") + logger.write(msg, 3) + res_clean = runner.clean(args_clean, batch=True, verbose = 0) + if res_clean == 0: + logger.write('%s\n\n' % src.printcolors.printc(src.OK_STATUS), 3) + if do_source: + res_source = runner.source(args_source) + if do_patch: + res_patch = runner.patch(args_patch) return res_clean + res_source + res_patch \ No newline at end of file diff --git a/test/config/option_copy.py b/test/config/option_copy.py index 4f70994..d671383 100644 --- a/test/config/option_copy.py +++ b/test/config/option_copy.py @@ -19,7 +19,6 @@ import unittest import os import sys -import shutil # get execution path testdir = os.path.dirname(os.path.realpath(__file__)) diff --git a/test/config/option_edit.py b/test/config/option_edit.py index f0a1b13..c156419 100644 --- a/test/config/option_edit.py +++ b/test/config/option_edit.py @@ -28,8 +28,6 @@ sys.path.append(os.path.join(testdir, '..', '..')) sys.path.append(os.path.join(testdir, '..', '_testTools')) from salomeTools import Sat -import src -from tools import outRedirection from tools import check_proc_existence_and_kill import HTMLTestRunner diff --git a/test/config/option_value.py b/test/config/option_value.py index b6b8055..678d3f0 100644 --- a/test/config/option_value.py +++ b/test/config/option_value.py @@ -20,7 +20,6 @@ import unittest import os import sys import platform -import shutil # get execution path testdir = os.path.dirname(os.path.realpath(__file__)) @@ -28,7 +27,6 @@ sys.path.append(os.path.join(testdir, '..', '..')) sys.path.append(os.path.join(testdir, '..', '_testTools')) from salomeTools import Sat -import src from tools import outRedirection import HTMLTestRunner diff --git a/test/log/launch_browser.py b/test/log/launch_browser.py index c7f9104..9d62d86 100644 --- a/test/log/launch_browser.py +++ b/test/log/launch_browser.py @@ -32,9 +32,7 @@ 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 = 2 diff --git a/test/prepare/test_patch.py b/test/prepare/test_patch.py index eb014be..5da0fb2 100644 --- a/test/prepare/test_patch.py +++ b/test/prepare/test_patch.py @@ -122,7 +122,7 @@ class TestPatch(unittest.TestCase): appli = 'appli-test' product_name = 'PRODUCT_ARCHIVE' - sat = Sat() + sat = Sat('-v4') sat.source(appli + ' --product ' + product_name) diff --git a/test/prepare/test_prepare.py b/test/prepare/test_prepare.py index f03b6c8..bebeeca 100644 --- a/test/prepare/test_prepare.py +++ b/test/prepare/test_prepare.py @@ -29,8 +29,6 @@ sys.path.append(os.path.join(testdir, '..', '..','commands')) import src -from tools import outRedirection - from salomeTools import Sat import HTMLTestRunner @@ -106,7 +104,7 @@ class TestPrepare(unittest.TestCase): sat.config(appli) try: - sat.prepare(appli + " --no_sample --force") + sat.prepare(appli + " --force --force_patch") OK = 'OK' except: pass diff --git a/test/prepare/test_source.py b/test/prepare/test_source.py index 12831ef..900b94b 100644 --- a/test/prepare/test_source.py +++ b/test/prepare/test_source.py @@ -19,7 +19,6 @@ import unittest import os import sys -import shutil # get execution path testdir = os.path.dirname(os.path.realpath(__file__)) @@ -132,7 +131,7 @@ class TestSource(unittest.TestCase): sat = Sat() sat.source(appli + ' --product ' + product_name) - expected_src_dir = os.path.join(sat.cfg.APPLICATION.out_dir, 'SOURCES', product_name) + expected_src_dir = os.path.join(sat.cfg.APPLICATION.workdir, 'SOURCES', product_name) if not os.path.exists(expected_src_dir): OK = 'OK' @@ -184,68 +183,6 @@ class TestSource(unittest.TestCase): # 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