[pitivi] tests: Base our testsuite on gst-validate-launcher



commit 92ed9f2f34a90d70436fb95b7a1238850e780cc6
Author: Thibault Saunier <tsaunier gnome org>
Date:   Thu Feb 23 09:15:50 2017 -0300

    tests: Base our testsuite on gst-validate-launcher
    
    It brings in a lot of feature such as segfault detection and backtrace printing
    generation of xunit files, ability to run in gdb or valgrind
    etc...
    
    Remove the option to generate the xunit file as the user should simply
    run gst-validate-launcher tests/run_testsuite.py --xunit-file=file.xunit
    to generate it, no reason to have it in the build system anymore.
    
    Differential Revision: https://phabricator.freedesktop.org/D1677

 build/flatpak/pitivi-flatpak |    6 +---
 meson_options.txt            |    1 -
 tests/meson.build            |   46 +++-----------------------------
 tests/run_testsuite.py       |   59 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 65 insertions(+), 47 deletions(-)
---
diff --git a/build/flatpak/pitivi-flatpak b/build/flatpak/pitivi-flatpak
index 8611e36..ca5ac30 100755
--- a/build/flatpak/pitivi-flatpak
+++ b/build/flatpak/pitivi-flatpak
@@ -530,9 +530,6 @@ class PitiviFlatpak:  # pylint: disable=too-many-instance-attributes
             subprocess.check_call(builder_args)
 
             configure_args = ["./configure", "--prefix=/app", "--libdir=lib"]
-            if self.check:
-                configure_args.append("-Denable-xunit=true")
-
             self.run_in_sandbox(*configure_args, exit_on_failure=True,
                                 cwd=self.topdir)
             self.run_in_sandbox("make", exit_on_failure=True,
@@ -576,7 +573,8 @@ class PitiviFlatpak:  # pylint: disable=too-many-instance-attributes
                 "/app/share/gstreamer-1.0/presets/:/app/share/pitivi/gstpresets/",
             "GST_PLUGIN_SYSTEM_PATH": "/app/lib/gstreamer-1.0/",
             "GST_PRESET_PATH":
-                "/app/share/gstreamer-1.0/presets/:/app/share/pitivi/gstpresets/"}
+                "/app/share/gstreamer-1.0/presets/:/app/share/pitivi/gstpresets/",
+        }
         for envvar, path in prefixes.items():
             value = forwarded.get(envvar, "")
             forwarded[envvar] = "%s:%s" % (path, value)
diff --git a/meson_options.txt b/meson_options.txt
index 51b34bd..05283fa 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,2 +1 @@
-option('enable-xunit', type : 'boolean', value : false)
 option('disable-help', type : 'boolean', value : false)
diff --git a/tests/meson.build b/tests/meson.build
index 7e172a1..76e19ef 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,45 +1,7 @@
-runtests = find_program('nose2', required : false)
+runtests = find_program('gst-validate-launcher', required : true)
 
 if runtests.found()
-    tests = [
-        ['Test application module', 'test_application'],
-        ['Test check module', 'test_check'],
-        ['Test clipproperties', 'test_clipproperties'],
-        ['Test common utilities', 'test_common'],
-        ['Test logging subsystem', 'test_log'],
-        ['Test effects', 'test_effects'],
-        ['Test the main window', 'test_mainwindow'],
-        ['Test the media library', 'test_media_library'],
-        ['Test the misc utilities', 'test_misc'],
-        ['Test the pipeline', 'test_pipeline'],
-        ['Test the preference dialog', 'test_prefs'],
-        ['Test presets', 'test_preset'],
-        ['Test the previewer', 'test_previewers'],
-        ['Test the project', 'test_project'],
-        ['Test rendering', 'test_render'],
-        ['Test the keyboard shortcuts', 'test_shortcuts'],
-        ['Test system integration', 'test_system'],
-        ['Test graphical timeline elements', 'test_timeline_elements'],
-        ['Test graphical layers', 'test_timeline_layer'],
-        ['Test the graphical timeline', 'test_timeline_timeline'],
-        ['Test undo/redo for the project', 'test_undo_project'],
-        ['Test the undo subsystem', 'test_undo'],
-        ['Test undo/redo in the timeline', 'test_undo_timeline'],
-        ['Test utilities', 'test_utils'],
-        ['Test the timeline utilities', 'test_utils_timeline'],
-        ['Test our compound widget', 'test_widgets'],
-    ]
-
-    foreach i: tests
-        args = ['-t', meson.source_root(), '-s', meson.current_source_dir()]
-        if get_option('enable-xunit')
-            xunitfile = '' + i.get(0).underscorify() + '.xunit'
-            config = configuration_data()
-            config.set('path', xunitfile)
-            configure_file(input : 'nose2-junit-xml.cfg.in', configuration : config, output : xunitfile + 
'.cfg')
-            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)])
-    endforeach
+    test('Pitivi unit tests', runtests,
+         args : [join_paths(meson.current_source_dir(), 'run_testsuite.py')],
+         env: ['PYTHONPATH=' + meson.source_root()], timeout: 500)
 endif
diff --git a/tests/run_testsuite.py b/tests/run_testsuite.py
new file mode 100644
index 0000000..854129d
--- /dev/null
+++ b/tests/run_testsuite.py
@@ -0,0 +1,59 @@
+# Pitivi video editor
+# Copyright (c) 2017, Thibault Saunier <tsaunier gnome org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+# pylint: disable=missing-docstring,invalid-name
+"""GstValidateLauncher testsuite to run out unit tests."""
+import os
+import sys
+import unittest
+
+TEST_MANAGER = "base"
+CDIR = os.path.dirname(os.path.realpath(__file__))
+sys.path.insert(0, os.path.join(CDIR, '..'))
+
+# pylint: disable=wrong-import-position
+# pylint: disable=unused-import
+# Import tests so that the module is initialized
+import tests  # noqa
+# pylint: disable=import-error
+from launcher.baseclasses import Test  # noqa
+
+
+# pylint: disable=too-few-public-methods
+class PitiviTest(Test):
+    """A launcher.Test subclass for our unit tests."""
+    def build_arguments(self):
+        """Builds subprocess arguments."""
+        self.add_arguments('-m', 'unittest', self.classname)
+
+
+def setup_tests(test_manager, options):
+    """Sets up Pitivi unit testsuite."""
+    print("Forcing 1 job at a time as testsuite will fail otherwise")
+    options.num_jobs = 1
+    loader = unittest.TestLoader()
+    testsuites = loader.discover(CDIR)
+    for testsuite in testsuites:
+        for _tests in testsuite:
+            for test in _tests:
+                test_manager.add_test(PitiviTest(
+                    sys.executable,
+                    'tests.' + test.id(),
+                    options, test_manager.reporter,
+                    extra_env_variables={'PYTHONPATH': os.path.join(CDIR, '..')}))
+
+    return True


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