X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=commands%2Fcheck.py;h=7961ca04e778ae2790aa336c515767cb08ced548;hb=107552854ce17709e5953955d2514079a72035e6;hp=b9e1528b21cbf4f9cdb4b668f88adc8d8783ffc9;hpb=9898fb9b81879fff3cad50f4fd64a4fa0fa900d5;p=tools%2Fsat.git diff --git a/commands/check.py b/commands/check.py index b9e1528..7961ca0 100644 --- a/commands/check.py +++ b/commands/check.py @@ -23,44 +23,10 @@ import src # Define all possible option for the check command : sat check parser = src.options.Options() parser.add_option('p', 'products', 'list2', 'products', - _('products to configure. This option can be' - ' passed several time to configure several products.')) + _('Optional: products to check. This option accepts a comma separated list.')) + +CHECK_PROPERTY = "has_unit_tests" -def get_products_list(options, cfg, logger): - '''method that gives the product list with their informations from - configuration regarding the passed options. - - :param options Options: The Options instance that stores the commands - arguments - :param cfg Config: The global configuration - :param logger Logger: The logger instance to use for the display and - logging - :return: The list of (product name, product_informations). - :rtype: List - ''' - # Get the products to be prepared, regarding the options - if options.products is None: - # No options, get all products sources - products = cfg.APPLICATION.products - else: - # if option --products, check that all products of the command line - # are present in the application. - products = options.products - for p in products: - if p not in cfg.APPLICATION.products: - raise src.SatException(_("Product %(product)s " - "not defined in application %(application)s") % - { 'product': p, 'application': cfg.VARS.application} ) - - # Construct the list of tuple containing - # the products name and their definition - products_infos = src.product.get_products_infos(products, cfg) - - products_infos = [pi for pi in products_infos if not( - src.product.product_is_native(pi[1]) or - src.product.product_is_fixed(pi[1]))] - - return products_infos def log_step(logger, header, step): logger.write("\r%s%s" % (header, " " * 20), 3) @@ -89,10 +55,6 @@ def check_all_products(config, products_infos, logger): ''' res = 0 for p_name_info in products_infos: - __, p_info = p_name_info - if ("build_dir" not in "build_dir" or - not src.product.product_compiles(p_info)): - continue res_prod = check_product(p_name_info, config, logger) if res_prod != 0: res += 1 @@ -120,6 +82,54 @@ def check_product(p_name_info, config, logger): logger.write(header, 3) logger.write("\n", 4, False) logger.flush() + + # Verify if the command has to be launched or not + ignored = False + if src.product.product_is_native(p_info): + msg = _("The product %s is defined as being native. " + "product ignored." % p_name) + logger.write("%s\n" % msg, 4) + ignored = True + elif not src.get_property_in_product_cfg(p_info, CHECK_PROPERTY): + msg = _("The product %s is defined as not having tests. " + "product ignored." % p_name) + logger.write("%s\n" % msg, 4) + ignored = True + elif not src.product.product_compiles(p_info): + msg = _("The product %s is defined as not compiling. " + "product ignored." % p_name) + logger.write("%s\n" % msg, 4) + ignored = True + elif "build_dir" not in p_info: + msg = _("No build_dir key defined in " + "the config file of %s: product ignored." % p_name) + logger.write("%s\n" % msg, 4) + ignored = True + + + # Get the command to execute for script products + cmd_found = True + command = "" + if src.product.product_has_script(p_info) and not ignored: + command = src.get_cfg_param(p_info, "test_build", "Not found") + if command == "Not found": + cmd_found = False + msg = _('WARNING: The product %s is defined as having tests. But it' + ' is compiled using a script and the key "test_build" is ' + 'not defined in the definition of %s' % (p_name, p_name)) + logger.write("%s\n" % msg, 4) + + if ignored or not cmd_found: + log_step(logger, header, "ignored") + logger.write("==== %(name)s %(IGNORED)s\n" % + { "name" : p_name , + "IGNORED" : src.printcolors.printcInfo("IGNORED")}, + 4) + logger.write("\n", 3, False) + logger.flush() + if not cmd_found: + return 1 + return 0 # Instantiate the class that manages all the construction commands # like cmake, check, make install, make test, environment management, etc... @@ -130,12 +140,11 @@ def check_product(p_name_info, config, logger): res_prepare = builder.prepare() log_res_step(logger, res_prepare) - # Execute buildconfigure, configure if the product is autotools - # Execute ccheck if the product is ccheck len_end_line = 20 + # Launch the check log_step(logger, header, "CHECK") - res = builder.check() + res = builder.check(command=command) log_res_step(logger, res) # Log the result @@ -163,7 +172,10 @@ def description(): :rtype: str ''' return _("The check command executes the \"check\" command in" - " the build directory") + " the build directory of all the products of the application." + "\nIt is possible to reduce the list of products to check by using" + " the --products option\n\nexample\nsat check SALOME-master " + "--products KERNEL,GUI,GEOM") def run(args, runner, logger): '''method that is called when salomeTools is called with check parameter. @@ -176,7 +188,7 @@ def run(args, runner, logger): src.check_config_has_application( runner.cfg ) # Get the list of products to treat - products_infos = get_products_list(options, runner.cfg, logger) + products_infos = src.product.get_products_list(options, runner.cfg, logger) # Print some informations logger.write(_('Executing the check command in the build ' @@ -203,4 +215,4 @@ def run(args, runner, logger): 'valid_result': nb_products - res, 'nb_products': nb_products }, 1) - return res \ No newline at end of file + return res