From 679edb1aef3299d69338f39007379f5fdc543525 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Aguerre?= Date: Wed, 15 Apr 2015 17:11:11 +0200 Subject: [PATCH] add extra tests to application --- bin/appli_gen.py | 25 +++++++++++++++++++++++++ bin/virtual_salome.py | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/bin/appli_gen.py b/bin/appli_gen.py index 9604eecf8..b263cd3e7 100644 --- a/bin/appli_gen.py +++ b/bin/appli_gen.py @@ -47,6 +47,8 @@ system_conf_tag = "system_conf" modules_tag = "modules" module_tag = "module" samples_tag = "samples" +extra_tests_tag = "extra_tests" +extra_test_tag = "extra_test" resources_tag = "resources" # --- names of attributes in XML configuration file @@ -65,6 +67,7 @@ class xml_parser: self.config = {} self.config["modules"] = [] self.config["guimodules"] = [] + self.config["extra_tests"] = [] parser = xml.sax.make_parser() parser.setContentHandler(self) parser.parse(fileName) @@ -118,6 +121,15 @@ class xml_parser: self.config["guimodules"].append(nam) pass pass + # --- if we are analyzing "extra_test" element then store its "name" and "path" attributes + elif self.space == [appli_tag,extra_tests_tag,extra_test_tag] and \ + nam_att in attrs.getNames() and \ + path_att in attrs.getNames(): + nam = attrs.getValue( nam_att ) + path = attrs.getValue( path_att ) + self.config["extra_tests"].append(nam) + self.config[nam]=path + pass pass def endElement(self, name): @@ -195,6 +207,19 @@ def install(prefix, config_file, verbose=0): pass pass + for extra_test in _config.get("extra_tests", []): + if _config.has_key(extra_test): + print "--- add extra test ", extra_test, _config[extra_test] + options = params() + options.verbose = verbose + options.clear = 0 + options.prefix = home_dir + options.extra_test_name = extra_test + options.extra_test_path = _config[extra_test] + virtual_salome.link_extra_test(options) + pass + pass + appliskel_dir = os.path.join(home_dir, 'bin', 'salome', 'appliskel') for fn in ('envd', diff --git a/bin/virtual_salome.py b/bin/virtual_salome.py index 0a2493121..db99db036 100755 --- a/bin/virtual_salome.py +++ b/bin/virtual_salome.py @@ -199,7 +199,7 @@ def link_module(options): f.write("SUBDIRS(%s)\n"%options.module_name) else: if verbose: - print module_bin_dir, " doesn't exist" + print module_test_dir, " doesn't exist" pass #directory idl/salome : create it and link content @@ -340,6 +340,40 @@ def link_module(options): pass pass +def link_extra_test(options): + global verbose + + if not options.extra_test_path: + print "Option extra_test is mandatory" + return + + extra_test_dir=os.path.abspath(options.extra_test_path) + if not os.path.exists(extra_test_dir): + print "Test %s does not exist" % extra_test_dir + return + + verbose = options.verbose + + home_dir = os.path.expanduser(options.prefix) + test_dir = os.path.join(home_dir,'bin','salome', 'test') + + if options.clear: + rmtree(test_dir) + pass + + #directory bin/salome/test : create it and link content + if os.path.exists(extra_test_dir): + # link /bin/salome/test/ to /bin/salome/test + print "link %s --> %s"%(os.path.join(test_dir, options.extra_test_name), extra_test_dir) + symlink(extra_test_dir, os.path.join(test_dir, options.extra_test_name)) + # register extra_test for testing in CTestTestfile.cmake + with open(os.path.join(test_dir, "CTestTestfile.cmake"), "ab") as f: + f.write("SUBDIRS(%s)\n"%options.extra_test_name) + else: + if verbose: + print extra_test_dir, " doesn't exist" + pass + # ----------------------------------------------------------------------------- def main(): -- 2.39.2