View | Details | Raw Unified | Return to bug 25109
Collapse All | Expand All

(-)a/t/Koha/Script.t (-1 / +14 lines)
Lines 48-54 my $interface = C4::Context->interface; Link Here
48
is( $interface, 'commandline', "Context interface set correctly with no flags" );
48
is( $interface, 'commandline', "Context interface set correctly with no flags" );
49
49
50
subtest 'lock_exec() tests' => sub {
50
subtest 'lock_exec() tests' => sub {
51
    plan tests => 2;
51
52
    plan tests => 3;
52
53
53
    # Launch the sleep script
54
    # Launch the sleep script
54
    my $pid = fork();
55
    my $pid = fork();
Lines 63-68 subtest 'lock_exec() tests' => sub { Link Here
63
64
64
    like( $result, qr{Unable to acquire the lock.*}, 'Exception found' );
65
    like( $result, qr{Unable to acquire the lock.*}, 'Exception found' );
65
66
67
    $pid = fork();
68
    if ( $pid == 0 ) {
69
        system( dirname(__FILE__) . '/sleep.pl 2>&1' );
70
        exit;
71
    }
72
73
    sleep 1; # Make sure we start after the fork
74
    $command = dirname(__FILE__) . '/wait.pl';
75
    $result  = `$command 2>&1`;
76
77
    is( $result, 'YAY!', 'wait.pl successfully waits for the lock' );
78
66
    throws_ok
79
    throws_ok
67
        { Koha::Script->new({ lock_name => 'blah' }); }
80
        { Koha::Script->new({ lock_name => 'blah' }); }
68
        'Koha::Exceptions::MissingParameter',
81
        'Koha::Exceptions::MissingParameter',
(-)a/t/Koha/wait.pl (-1 / +17 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use Koha::Script;
6
use Fcntl qw(:flock);
7
use Try::Tiny;
8
9
# # Lock execution
10
my $script = Koha::Script->new({ script => 'sleep.pl' });
11
12
$script->lock_exec({ wait => 1 });
13
14
print STDOUT "YAY!";
15
16
# Normal exit
17
1;

Return to bug 25109