File: run-test.rb

package info (click to toggle)
ruby-gnome 4.3.4-1.0
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 22,316 kB
  • sloc: ruby: 55,217; ansic: 29,012; xml: 333; sh: 225; cpp: 45; makefile: 42
file content (114 lines) | stat: -rwxr-xr-x 2,678 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env ruby
#
# Copyright (C) 2008-2025  Ruby-GNOME Project Team
#
# This library 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 library 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 library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

require "rbconfig"
require "pathname"
require "time"

require_relative "helper"

ruby = RbConfig.ruby

# for creating a separating line
def separator
  "-" * 80
end

def run_broadwayd(target)
  unless ENV["RUBY_GNOME_GTK4_USE_BROADWAY"] == "yes"
    return yield
  end

  case target.basename.to_s
  when "gdk4", "gtk4"
    pid = spawn("gtk4-broadwayd")
    begin
      gdk_backend, ENV["GDK_BACKEND"] = ENV["GDK_BACKEND"], "broadway"
      yield
    ensure
      ENV["GDK_BACKEND"] = gdk_backend
      Process.kill(:TERM, pid)
      Process.waitpid(pid)
    end
  else
    yield
  end
end

targets = []
includes = []

base_dir = Pathname(__dir__)
if ARGV.empty?
  candidates = Pathname.glob((base_dir + "*").to_s)
else
  candidates = ARGV.collect do |package|
    base_dir + package
  end
end
candidates.each do |dir|
  next unless dir.directory?
  source_dir = dir.expand_path
  next unless (source_dir + "test").directory?
  targets << dir
end

all_test_packages = Helper.all_test_packages

ignored_modules = [
  "vte3",
  "vte4",
  "gnumeric",
  "webkit-gtk",
  "clutter-gstreamer",
  "webkit-gtk2",
  "goffice",
  "gsf",
  "gtksourceview2",
  "gtksourceview3",
  "libhandy",
 ]

failed_target_names = []
targets.each do |target|
  next unless all_test_packages.include?(target.basename.to_s)

  puts "::group::Test #{target}"
  puts "#{Time.now.iso8601}: Running test for #{target}"
  puts separator


  run_broadwayd(target) do
    test_run = target + "test/run.rb"
    test_run = target + "test/run-test.rb" unless test_run.exist?
    unless system(ruby, *includes, test_run.to_s)
      puts "Failed to run test: #{target.basename}"
      failed_target_names << target.basename.to_s
    end
  end

  puts separator
  puts "::endgroup::"
end

if failed_target_names.empty?
  exit(true)
else
  puts "Failed targets: #{failed_target_names.join(', ')}"
  exit(false)
end