[pitivi] validate: Allow running the integration tests with make validate



commit 4c2ba9fec4c38c82d18df61bd08fe66c01cbea37
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Mon Oct 24 17:11:38 2016 +0200

    validate: Allow running the integration tests with make validate
    
    Had to pass the path to the `bin/pitivi` executable from `runtests`
    because `__file__` in `pitivivalidate.py` was returning the value for
    gst-validate-launcher's `baseclasses.py`.
    
    Reviewed-by: Thibault Saunier <tsaunier gnome org>
    Differential Revision: https://phabricator.freedesktop.org/D1425

 build/flatpak/pitivi-flatpak           |    1 +
 configure                              |    3 ++
 meson.build                            |    1 +
 tests/meson.build                      |    2 +-
 tests/validate-tests/meson.build       |    5 ++++
 tests/validate-tests/pitivi.py         |   14 +++++-------
 tests/validate-tests/pitivivalidate.py |   36 +++++++++++++------------------
 7 files changed, 32 insertions(+), 30 deletions(-)
---
diff --git a/build/flatpak/pitivi-flatpak b/build/flatpak/pitivi-flatpak
index cba6c43..ddfa46c 100755
--- a/build/flatpak/pitivi-flatpak
+++ b/build/flatpak/pitivi-flatpak
@@ -536,6 +536,7 @@ class PitiviFlatpak:  # pylint: disable=too-many-instance-attributes
                 ("GST_PRESET_PATH",
                  "/app/share/gstreamer-1.0/presets/:/app/share/pitivi/gstpresets/"),
                 "GST_VALIDATE",
+                "GST_VALIDATE_APPS_DIR",
                 "GST_VALIDATE_LAUNCHER_DEBUG",
                 "GTK_DEBUG",
                 "GTK_THEME",
diff --git a/configure b/configure
index 4a1fec4..abcf5cc 100755
--- a/configure
+++ b/configure
@@ -18,6 +18,9 @@ install:
 check:
 \tcd %(build_dir)s && %(ninja)s test
 
+validate:
+\tcd %(build_dir)s && %(ninja)s validate
+
 dist:
 \tcd %(build_dir)s && %(ninja)s dist
 
diff --git a/meson.build b/meson.build
index f50a957..c078897 100644
--- a/meson.build
+++ b/meson.build
@@ -72,6 +72,7 @@ if not get_option('disable-help')
     subdir('help')
 endif
 subdir('tests')
+subdir('tests/validate-tests')
 
 archiver = find_program('git-archive-all', required : false)
 if archiver.found()
diff --git a/tests/meson.build b/tests/meson.build
index 6be62da..2b7de21 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -38,6 +38,6 @@ if runtests.found()
             args = args + ['--plugin', 'nose2.plugins.junitxml', '--config', meson.current_build_dir() + '/' 
+ xunitfile + '.cfg']
         endif
 
-        test(i.get(0), runtests, args: args + ['tests.' + i.get(1)])
+        test(i.get(0), runtests, args : args + ['tests.' + i.get(1)])
     endforeach
 endif
\ No newline at end of file
diff --git a/tests/validate-tests/meson.build b/tests/validate-tests/meson.build
new file mode 100644
index 0000000..1ace174
--- /dev/null
+++ b/tests/validate-tests/meson.build
@@ -0,0 +1,5 @@
+gstvalidate = find_program('gst-validate-launcher', required : false)
+
+if gstvalidate.found()
+    run_target('validate', command : [meson.current_source_dir() + '/runtests'])
+endif
diff --git a/tests/validate-tests/pitivi.py b/tests/validate-tests/pitivi.py
index eaa0282..a0a88be 100644
--- a/tests/validate-tests/pitivi.py
+++ b/tests/validate-tests/pitivi.py
@@ -17,9 +17,7 @@
 # License along with this program; if not, write to the
 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 # Boston, MA 02110-1301, USA.
-"""
-The GES GstValidate default testsuite
-"""
+"""The Pitivi GstValidate testsuite."""
 import os
 
 
@@ -27,10 +25,10 @@ TEST_MANAGER = "pitivi"
 
 
 def setup_tests(test_manager, options):
-    print("Setting up Pitivi default tests")
-    options.pitivi_scenario_paths = [os.path.join(os.path.abspath(os.path.join(os.path.dirname(__file__))),
-                                                  "scenarios")]
-    options.add_paths(os.path.abspath(os.path.join(os.path.dirname(__file__),
-                      "..", "samples")))
+    path = os.path.abspath(os.path.dirname(__file__))
+    print("Setting up Pitivi integration tests in %s" % path)
+    options.pitivi_scenario_paths = [os.path.join(path, "scenarios")]
+    options.add_paths(os.path.join(path, os.path.pardir, "samples"))
+    options.pitivi_executable = os.path.join(path, "..", "..", "bin", "pitivi")
     test_manager.register_defaults()
     return True
diff --git a/tests/validate-tests/pitivivalidate.py b/tests/validate-tests/pitivivalidate.py
index 06e38b6..d09032b 100644
--- a/tests/validate-tests/pitivivalidate.py
+++ b/tests/validate-tests/pitivivalidate.py
@@ -18,7 +18,6 @@
 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 # Boston, MA 02110-1301, USA.
 import os
-import sys
 from urllib import unquote
 
 import urlparse
@@ -29,10 +28,6 @@ from baseclasses import TestsManager
 
 Pitivi_DURATION_TOLERANCE = utils.GST_SECOND / 2
 
-PITIVI_COMMAND = "pitivi"
-if "win32" in sys.platform:
-    PITIVI_COMMAND += ".exe"
-
 
 def quote_uri(uri):
     """
@@ -47,9 +42,8 @@ def quote_uri(uri):
 
 class PitiviTest(GstValidateTest):
 
-    def __init__(self, classname, options, reporter, scenario,
-                 combination=None):
-        super(PitiviTest, self).__init__(PITIVI_COMMAND, classname, options, reporter,
+    def __init__(self, executable, classname, options, reporter, scenario):
+        super(PitiviTest, self).__init__(executable, classname, options, reporter,
                                          scenario=None)
         self._scenario = scenario
 
@@ -88,10 +82,10 @@ class PitiviTestsManager(TestsManager):
         group = parser.add_argument_group("Pitivi specific option group"
                                           " and behaviours",
                                           description="")
+        group.add_argument("--pitivi-executable", dest="pitivi_executable",
+                           default=os.path.join("..", "..", "bin", "pitivi"),
+                           help="Path to the pitivi executable")
         group.add_argument("--pitivi-scenarios-paths", dest="pitivi_scenario_paths",
-                           default=os.path.join(os.path.basename(__file__),
-                                                "pitivi",
-                                                "pitivi scenarios"),
                            help="Paths in which to look for scenario files")
 
     def set_settings(self, options, args, reporter):
@@ -106,23 +100,23 @@ class PitiviTestsManager(TestsManager):
     def list_tests(self):
         return self.tests
 
-    def register_defaults(self):
-        scenarios = list()
+    def find_scenarios(self):
         for path in self.options.pitivi_scenario_paths:
             for root, dirs, files in os.walk(path):
-                for f in files:
-                    if not f.endswith(".scenario"):
+                for file in files:
+                    if not file.endswith(".scenario"):
                         continue
-                    scenarios.append(os.path.join(path, root, f))
+                    yield os.path.join(path, root, file)
 
-        for scenario_name in scenarios:
+    def register_defaults(self):
+        for scenario_name in self.find_scenarios():
             scenario = self._scenarios.get_scenario(scenario_name)
             if scenario is None:
                 continue
 
-            classname = "pitivi.%s" % (scenario.name)
-            self.add_test(PitiviTest(classname,
+            classname = "pitivi.%s" % scenario.name
+            self.add_test(PitiviTest(self.options.pitivi_executable,
+                                     classname,
                                      self.options,
                                      self.reporter,
-                                     scenario=scenario)
-                          )
+                                     scenario=scenario))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]