[mutter/wip/3v1n0/run-tests-in-ci: 13/14] tests: add headless_tests support



commit 0503ecaf84391f1d170fd8fd48ba7970d63f1afb
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Wed Nov 14 02:19:09 2018 -0600

    tests: add headless_tests support
    
    Run tests using Xvfb so that we can run them in CI

 clutter/tests/conform/meson.build |  9 +++++++++
 cogl/tests/conform/meson.build    | 14 ++++++++++++++
 cogl/tests/unit/meson.build       | 20 +++++++++++++++-----
 meson.build                       | 20 ++++++++++++++++++++
 meson_options.txt                 |  6 ++++++
 src/tests/meson.build             | 30 ++++++++++++++++++++++++++++++
 6 files changed, 94 insertions(+), 5 deletions(-)
---
diff --git a/clutter/tests/conform/meson.build b/clutter/tests/conform/meson.build
index b89487a09..8355187bf 100644
--- a/clutter/tests/conform/meson.build
+++ b/clutter/tests/conform/meson.build
@@ -82,4 +82,13 @@ foreach test : clutter_conform_tests
     suite: ['clutter', 'clutter/conform'],
     env: test_env
   )
+
+  if have_headless_tests
+    test(test, xvfb,
+      args: test_executable,
+      suite: ['clutter-headless', 'clutter-headless/conform', 'headless'],
+      env: test_env,
+      is_parallel: false,
+    )
+  endif
 endforeach
diff --git a/cogl/tests/conform/meson.build b/cogl/tests/conform/meson.build
index 8688488e7..7ffd16a83 100644
--- a/cogl/tests/conform/meson.build
+++ b/cogl/tests/conform/meson.build
@@ -105,3 +105,17 @@ test('conform', cogl_run_tests,
   is_parallel: false,
   timeout: 60,
 )
+
+if have_headless_tests
+  test('conform', xvfb,
+    suite: ['cogl-headless', 'headless'],
+    args: [
+      cogl_run_tests.path(),
+      cogl_config_env,
+      libmutter_cogl_test_conformance,
+      cogl_conform_unit_tests
+    ],
+    is_parallel: false,
+    timeout: 500,
+  )
+endif
diff --git a/cogl/tests/unit/meson.build b/cogl/tests/unit/meson.build
index acbcb617b..2d955df11 100644
--- a/cogl/tests/unit/meson.build
+++ b/cogl/tests/unit/meson.build
@@ -32,12 +32,22 @@ cogl_unit_unit_tests = custom_target('cogl-tests-unit-unit-tests',
   install: false,
 )
 
+cogl_unit_test_args = [
+  cogl_config_env,
+  libmutter_cogl_test_unit,
+  cogl_unit_unit_tests
+]
 test('unit', cogl_run_tests,
   suite: ['cogl'],
-  args: [
-    cogl_config_env,
-    libmutter_cogl_test_unit,
-    cogl_unit_unit_tests
-  ],
+  args: cogl_unit_test_args,
   is_parallel: false,
 )
+
+if have_headless_tests
+  test('unit', xvfb,
+    suite: ['cogl-headless', 'headless'],
+    args: [ cogl_run_tests.path() ] + cogl_unit_test_args,
+    is_parallel: false,
+    timeout: 90,
+  )
+endif
diff --git a/meson.build b/meson.build
index 0f4f0d04a..8bf1cd477 100644
--- a/meson.build
+++ b/meson.build
@@ -245,6 +245,26 @@ if have_tests
   endif
 endif
 
+headless_tests_option = get_option('headless_tests')
+have_headless_tests = not headless_tests_option.disabled()
+if have_headless_tests
+  if not have_tests and not have_cogl_tests and not have_clutter_tests
+    have_headless_tests = false
+    if headless_tests_option.enabled()
+      error('Headless tests are enabled, but no other test suite is')
+    endif
+  endif
+  if have_headless_tests
+    xvfb = find_program('xvfb-run', required: headless_tests_option.enabled())
+    have_headless_tests = xvfb.found()
+  endif
+endif
+if have_headless_tests
+  headless_tests_suite = ['headless']
+else
+  headless_tests_suite = []
+endif
+
 required_functions = [
   'ffs',
   'clz',
diff --git a/meson_options.txt b/meson_options.txt
index a0924faf1..544fd13ef 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -123,6 +123,12 @@ option('tests',
   description: 'Enable mutter tests'
 )
 
+option('headless_tests',
+  type: 'feature',
+  value: 'auto',
+  description: 'Enable mutter headless tests'
+)
+
 option('verbose',
   type: 'boolean',
   value: true,
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 5bdf5f25b..841201d42 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -107,6 +107,18 @@ foreach stacking_test: stacking_tests
     is_parallel: false,
     timeout: 60,
   )
+  if have_headless_tests
+    test(stacking_test, xvfb,
+      suite: ['mutter-headless', 'mutter-headless/stacking', 'headless'],
+      env: test_env,
+      args: [
+        test_runner,
+        files(join_paths('stacking', stacking_test + '.metatest')),
+      ],
+      is_parallel: false,
+      timeout: 60,
+    )
+  endif
 endforeach
 
 test('normal', unit_tests,
@@ -122,3 +134,21 @@ test('headless-start', headless_start_test,
   is_parallel: false,
   timeout: 60,
 )
+
+if have_headless_tests
+  test('normal', xvfb,
+    args: unit_tests,
+    suite: ['mutter-headless', 'mutter-headless/unit', 'headless'],
+    env: test_env,
+    is_parallel: false,
+    timeout: 60,
+  )
+
+  test('headless-start', xvfb,
+    args: headless_start_test,
+    suite: ['mutter-headless', 'mutter-headless/unit', 'headless'],
+    env: test_env,
+    is_parallel: false,
+    timeout: 60,
+  )
+endif


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