Salome HOME
Merge branch 'nct/jan21' of https://codev-tuleap.cea.fr/plugins/git/salome/sat into...
[tools/sat.git] / commands / check.py
index cfa2c822946fdb60fbadfc2fc34c2e140fb96476..ffb31af02439e35014fd8904df00541e23165cca 100644 (file)
@@ -23,46 +23,10 @@ import src
 # Define all possible option for the check command :  sat check <options>
 parser = src.options.Options()
 parser.add_option('p', 'products', 'list2', 'products',
-    _('Optional: 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)
@@ -121,21 +85,27 @@ def check_product(p_name_info, config, logger):
 
     # Verify if the command has to be launched or not
     ignored = False
-    if not src.get_property_in_product_cfg(p_info, CHECK_PROPERTY):
-        msg = _("The product %s is defined as not having tests. "
+    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
-    if "build_dir" not in p_info:
-        msg = _("No build_dir key defined in "
-                "the config file of %s: product ignored." % p_name)
+    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
-    if not src.product.product_compiles(p_info):
+    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
@@ -163,7 +133,7 @@ def check_product(p_name_info, config, logger):
     
     # Instantiate the class that manages all the construction commands
     # like cmake, check, make install, make test, environment management, etc...
-    builder = src.compilation.Builder(config, logger, p_info)
+    builder = src.compilation.Builder(config, logger, p_name, p_info)
     
     # Prepare the environment
     log_step(logger, header, "PREPARE ENV")
@@ -218,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 '
@@ -245,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