aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Zhmylove <zhmylove@narod.ru>2023-09-23 18:06:54 +0300
committerGitHub <noreply@github.com>2023-09-23 17:06:54 +0200
commit26608b74d9dff430af97b5c804e00d3c989aab4f (patch)
tree068ebd9909dcf1c6bdf083edf27c06915a632136
parent5489db6bc84b402de85643e6e86b18379e67864b (diff)
downloadi3-26608b74d9dff430af97b5c804e00d3c989aab4f.tar.gz
i3-26608b74d9dff430af97b5c804e00d3c989aab4f.zip
Fix failing testcase when the font exists (#5679)
When the font from testcase's config exists on the system, load_configuration() does not fallback to a 'fixed' one resulting in a fail of this case. The fallback scenario is added as well.
-rwxr-xr-xtestcases/complete-run.pl.in2
-rw-r--r--testcases/t/317-bar-config-font-fallback.t42
-rw-r--r--testcases/t/317-bar-config-font-order.t8
3 files changed, 50 insertions, 2 deletions
diff --git a/testcases/complete-run.pl.in b/testcases/complete-run.pl.in
index 00f8e609..0a1e11c6 100755
--- a/testcases/complete-run.pl.in
+++ b/testcases/complete-run.pl.in
@@ -203,7 +203,7 @@ for my $display (@displays) {
# Read previous timing information, if available. We will be able to roughly
# predict the test duration and schedule a good order for the tests.
my $timingsjson = slurp('.last_run_timings.json') if -e '.last_run_timings.json';
-%timings = %{decode_json($timingsjson)} if length($timingsjson) > 0;
+%timings = %{decode_json($timingsjson)} if length($timingsjson // '') > 0;
# Re-order the files so that those which took the longest time in the previous
# run will be started at the beginning to not delay the whole run longer than
diff --git a/testcases/t/317-bar-config-font-fallback.t b/testcases/t/317-bar-config-font-fallback.t
new file mode 100644
index 00000000..020fd3ee
--- /dev/null
+++ b/testcases/t/317-bar-config-font-fallback.t
@@ -0,0 +1,42 @@
+#!perl
+# vim:ts=4:sw=4:expandtab
+#
+# Please read the following documents before working on tests:
+# • https://build.i3wm.org/docs/testsuite.html
+# (or docs/testsuite)
+#
+# • https://build.i3wm.org/docs/lib-i3test.html
+# (alternatively: perldoc ./testcases/lib/i3test.pm)
+#
+# • https://build.i3wm.org/docs/ipc.html
+# (or docs/ipc)
+#
+# • https://i3wm.org/downloads/modern_perl_a4.pdf
+# (unless you are already familiar with Perl)
+#
+# Verifies that bar config blocks get the i3-wide font configured,
+# regardless of where the font is configured in the config file
+# (before or after the bar config blocks).
+# Ticket: #5031
+# Bug still in: 4.20-105-g4db383e4
+use i3test i3_config => <<'EOT';
+# i3 config file (v4)
+
+bar {
+ # no font directive here, no i3-wide font configured (yet)
+}
+
+# NOTE: iso99887 is invalid font specification, so it should always fallback
+font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso99887-9
+EOT
+
+my $i3 = i3(get_socket_path(0));
+my $bars = $i3->get_bar_config()->recv;
+
+my $bar_id = shift @$bars;
+my $bar_config = $i3->get_bar_config($bar_id)->recv;
+
+# This should fallback to 'fixed' due to nonexistent font set in config
+is($bar_config->{font}, 'fixed', 'font fallback ok');
+
+done_testing;
diff --git a/testcases/t/317-bar-config-font-order.t b/testcases/t/317-bar-config-font-order.t
index 72782152..31bda2f5 100644
--- a/testcases/t/317-bar-config-font-order.t
+++ b/testcases/t/317-bar-config-font-order.t
@@ -34,6 +34,12 @@ my $bars = $i3->get_bar_config()->recv;
my $bar_id = shift @$bars;
my $bar_config = $i3->get_bar_config($bar_id)->recv;
-is($bar_config->{font}, 'fixed', 'font ok');
+
+# This should either load the font specified, or fallback to 'fixed'
+my %valid_fonts = map {; $_ => 1 } qw(
+ -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+ fixed
+);
+is($valid_fonts{ $bar_config->{font} }, 1, 'font ok');
done_testing;