test/udev-test: gracefully exit when imports fail

In Fedora rawhide various perl modules are now available as separate
packages that are not pulled in by dependencies. If we don't have some
package, skip the tests.

This ugly code is apparently the way to do conditional imports:
https://www.cs.ait.ac.th/~on/O/oreilly/perl/cookbook/ch12_03.htm.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-11-17 17:13:31 +01:00 committed by Yu Watanabe
parent 07e4a8dc23
commit d407638382
1 changed files with 13 additions and 5 deletions

View File

@ -18,11 +18,19 @@
use warnings;
use strict;
use POSIX qw(WIFEXITED WEXITSTATUS);
use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT);
use IPC::Semaphore;
use Time::HiRes qw(usleep);
use Cwd qw(getcwd abs_path);
BEGIN {
my $EXIT_TEST_SKIP = 77;
unless (eval "use POSIX qw(WIFEXITED WEXITSTATUS);
use Cwd qw(getcwd abs_path);
use IPC::Semaphore;
use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR IPC_CREAT);
use Time::HiRes qw(usleep); 1") {
warn "Failed to import dependencies, skipping the test: $@";
exit($EXIT_TEST_SKIP);
}
}
my $udev_bin = "./test-udev";
my $valgrind = 0;