Skip to content

Commit 25a48ae

Browse files
committed
Ensure meta context is initialized once and use built-in GLib.Test flag
1 parent 9e5ac04 commit 25a48ae

4 files changed

Lines changed: 9 additions & 28 deletions

File tree

tests/Main.vala

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,6 @@
55

66
namespace Gala {
77
public int main (string[] args) {
8-
string? test_name = null;
9-
10-
OptionEntry[] entries = {
11-
{ "test-name", 't', NONE, STRING, ref test_name, null, null },
12-
{ null }
13-
};
14-
15-
var context = new OptionContext ("io.elementary.gala.tests");
16-
context.add_main_entries (entries, null);
17-
18-
try {
19-
context.parse (ref args);
20-
} catch (Error e) {
21-
Test.message ("Option parsing failed: %s", e.message);
22-
return 1;
23-
}
24-
258
Type[] test_types = {
269
typeof (SetupTest),
2710
typeof (GestureControllerTest),
@@ -32,12 +15,7 @@ namespace Gala {
3215
Object[] tests = {};
3316

3417
for (var i = 0; i < test_types.length; i++) {
35-
unowned var test_type = test_types[i];
36-
37-
var should_launch_test = test_name == null || test_type.name () == "Gala%s".printf (test_name);
38-
if (should_launch_test) {
39-
tests += GLib.Object.new_with_properties (test_type, {}, {});
40-
}
18+
tests += GLib.Object.new_with_properties (test_types[i], {}, {});
4119
}
4220

4321
Test.init (ref args);

tests/MutterTestCase.vala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ public abstract class Gala.MutterTestCase : Gala.TestCase {
2525
"--virtual-monitor", "1280x720@60"
2626
};
2727

28-
protected Meta.Context context { get; private set; }
29-
protected Clutter.Stage stage { get { return (Clutter.Stage) context.get_backend ().get_stage (); } }
28+
protected static Meta.Context? context { get; private set; }
29+
protected static Clutter.Stage? stage { get { return (Clutter.Stage) context?.get_backend ().get_stage (); } }
3030

3131
private MainLoop? main_loop;
3232

3333
construct {
34+
if (context != null) {
35+
return;
36+
}
37+
3438
context = new Meta.Context ("");
3539

3640
unowned var unowned_args = MUTTER_ARGS;

tests/lib/SetupTest.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class Gala.SetupTest : MutterTestCase {
3535
var stage = backend.get_stage ();
3636
assert_true (stage != null);
3737
assert_true (stage is Clutter.Stage);
38-
assert_true (this.stage == stage);
38+
assert_true (MutterTestCase.stage == stage);
3939

4040
// Creating an actor requires clutter machinery to be set up, so check this
4141
var actor = new Clutter.Actor ();

tests/meson.build

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ test_executable = executable(
2626
)
2727

2828
foreach lib_test : lib_tests
29-
test(lib_test, test_executable, args: ['--test-name=@0@'.format(lib_test)], suite: ['Gala'], is_parallel: false)
29+
test(lib_test, test_executable, args: ['-p', '/Gala@0@'.format(lib_test)], suite: ['Gala'], is_parallel: false)
3030
endforeach
31-

0 commit comments

Comments
 (0)