Skip to content

Commit

Permalink
Fix failing testcase when the font exists (#5679)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zhmylove committed Sep 23, 2023
1 parent 5489db6 commit 26608b7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion testcases/complete-run.pl.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions testcases/t/317-bar-config-font-fallback.t
Original file line number Diff line number Diff line change
@@ -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;
8 changes: 7 additions & 1 deletion testcases/t/317-bar-config-font-order.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 26608b7

Please sign in to comment.