Skip to content

Commit a761b67

Browse files
committed
Tests: avoid rebuilding libgala for each test
1 parent fb6e904 commit a761b67

11 files changed

Lines changed: 40 additions & 10 deletions

File tree

.github/workflows/main.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ jobs:
3636
env:
3737
DESTDIR: out
3838
run: |
39-
meson build -Ddocumentation=true -Dtests=true
40-
ninja -C build
41-
ninja -C build install
39+
meson setup build --prefix=/usr -Ddocumentation=true
40+
cd build
41+
ninja install
42+
- name: Build Tests
43+
run: |
44+
cd build
45+
meson configure -Dtests=true
46+
ninja install
4247
- name: Prepare Test Environment
4348
run: |
4449
mkdir -p -m 700 ${{ github.workspace }}/runtime-dir

lib/Gestures/Backends/GestureBackend.vala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
/*
2-
* Copyright 2025 elementary, Inc. (https://elementary.io)
2+
* Copyright 2025-2026 elementary, Inc. (https://elementary.io)
33
* SPDX-License-Identifier: GPL-3.0-or-later
44
*
55
* Authored by: Leonhard Kargl <leo.kargl@proton.me>
66
*/
77

8+
#if TESTS
9+
public interface Gala.GestureBackend : Object {
10+
#else
811
private interface Gala.GestureBackend : Object {
12+
#endif
913
public signal bool on_gesture_detected (Gesture gesture, uint32 timestamp);
1014
public signal void on_begin (double percentage, uint64 time);
1115
public signal void on_update (double percentage, uint64 time);

lib/Gestures/Gesture.vala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ namespace Gala {
2020
/**
2121
* Physical direction of the gesture. This direction doesn't follow natural scroll preferences.
2222
*/
23+
#if TESTS
24+
public enum GestureDirection {
25+
#else
2326
private enum GestureDirection {
27+
#endif
2428
UNKNOWN = 0,
2529

2630
// GestureType.SWIPE and GestureType.SCROLL
@@ -59,7 +63,11 @@ namespace Gala {
5963
}
6064
}
6165

66+
#if TESTS
67+
public class Gesture {
68+
#else
6269
private class Gesture {
70+
#endif
6371
public Clutter.EventType type;
6472
public GestureDirection direction;
6573
public int fingers;

lib/Gestures/GestureController.vala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ public class Gala.GestureController : Object {
119119
trigger.enable_backends (this);
120120
}
121121

122+
#if TESTS
123+
public void enable_backend (GestureBackend backend) {
124+
#else
122125
internal void enable_backend (GestureBackend backend) {
126+
#endif
123127
backend.on_gesture_detected.connect (gesture_detected);
124128
backend.on_begin.connect (gesture_begin);
125129
backend.on_update.connect (gesture_update);

lib/Gestures/Triggers/GestureTrigger.vala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
* the necessary backends for the type of gesture.
1111
*/
1212
public interface Gala.GestureTrigger : Object {
13+
#if TESTS
14+
public abstract bool triggers (Gesture gesture);
15+
public abstract void enable_backends (GestureController controller);
16+
#else
1317
internal abstract bool triggers (Gesture gesture);
1418
internal abstract void enable_backends (GestureController controller);
19+
#endif
1520
}

lib/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ config_h = configure_file(
7676
install_dir: join_paths(get_option('datadir'), 'vala', 'vapi')
7777
)
7878

79-
gala_dep = declare_dependency(link_with: [gala_lib], include_directories: include_directories('.'))
79+
gala_lib_dep = declare_dependency(link_with: [gala_lib], include_directories: include_directories('.'))
8080

8181
pkg.generate(
8282
gala_lib,

meson.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ if vala.version().version_compare('>= 0.56.17')
168168
vala_flags += ['--define', 'VALA_0_56_17']
169169
endif
170170

171+
if get_option('tests')
172+
vala_flags += ['--define', 'TESTS']
173+
endif
174+
175+
171176
add_project_arguments(vala_flags, language: 'vala')
172177
add_project_link_arguments(['-Wl,-rpath,@0@'.format(mutter_typelib_dir)], language: 'c')
173178

plugins/pip/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gala_pip_sources = files(
77
gala_pip_lib = shared_library(
88
'gala-pip',
99
gala_pip_sources,
10-
dependencies: [gala_dep, gala_base_dep],
10+
dependencies: [gala_lib_dep, gala_base_dep],
1111
install: true,
1212
install_dir: plugins_dir,
1313
install_rpath: mutter_typelib_dir,

plugins/template/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ gala_template_sources = files(
55
gala_template_lib = shared_library(
66
'gala-template',
77
gala_template_sources,
8-
dependencies: [gala_dep, gala_base_dep],
8+
dependencies: [gala_lib_dep, gala_base_dep],
99
install: false,
1010
install_dir: plugins_dir,
1111
install_rpath: mutter_typelib_dir,

src/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ gala_bin = executable(
7676
'gala',
7777
gala_bin_sources,
7878
config_header,
79-
dependencies: [gala_dep, gala_base_dep, pantheon_desktop_shell_dep],
79+
dependencies: [gala_lib_dep, gala_base_dep, pantheon_desktop_shell_dep],
8080
install_rpath: mutter_typelib_dir,
8181
install: true,
8282
)

0 commit comments

Comments
 (0)