]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/TestCommon.pm
tests: skip properly with git <2.6
[public-inbox.git] / lib / PublicInbox / TestCommon.pm
index 64fe04996d7dd35ab2e6d625aeca0942500b98bd..d6b7d20e385b1b7e68d98444ea570ac46cc671cb 100644 (file)
@@ -9,12 +9,14 @@ use v5.10.1;
 use Fcntl qw(FD_CLOEXEC F_SETFD F_GETFD :seek);
 use POSIX qw(dup2);
 use IO::Socket::INET;
+use File::Spec;
 our @EXPORT;
 BEGIN {
        @EXPORT = qw(tmpdir tcp_server tcp_connect require_git require_mods
                run_script start_script key2sub xsys xsys_e xqx eml_load tick
                have_xapian_compact json_utf8 setup_public_inboxes
-               tcp_host_port test_lei lei $lei $lei_out $lei_err $lei_opt);
+               tcp_host_port test_lei lei lei_ok
+               $lei $lei_out $lei_err $lei_opt);
        require Test::More;
        my @methods = grep(!/\W/, @Test::More::EXPORT);
        eval(join('', map { "*$_=\\&Test::More::$_;" } @methods));
@@ -459,6 +461,13 @@ our $lei = sub {
 
 sub lei (@) { $lei->(@_) }
 
+sub lei_ok (@) {
+       my $msg = ref($_[-1]) ? pop(@_) : undef;
+       # filter out anything that looks like a path name for consistent logs
+       my @msg = grep(!m!\A/!, @_);
+       ok($lei->(@_), "lei @msg". ($msg ? " ($$msg)" : ''));
+}
+
 sub json_utf8 () {
        state $x = ref(PublicInbox::Config->json)->new->utf8->canonical;
 }
@@ -467,7 +476,7 @@ sub test_lei {
 SKIP: {
        my ($cb) = pop @_;
        my $test_opt = shift // {};
-       require_git(2.6) or skip('git 2.6+ required for lei test', 2);
+       require_git(2.6, 1) or skip('git 2.6+ required for lei test', 2);
        require_mods(qw(json DBD::SQLite Search::Xapian), 2);
        require PublicInbox::Config;
        delete local $ENV{XDG_DATA_HOME};