Skip to content

Commit 76e5970

Browse files
committed
feat: recreate PR Test-More#289 — Terminate on abort to avoid HALT issue
1 parent ea862e4 commit 76e5970

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

lib/Test2/Harness/Scheduler.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ sub abort {
307307
CORE::kill('TERM', $pid);
308308
$job->{killed} = 1;
309309
}
310+
311+
# When aborting all runs (e.g. BAIL_OUT), terminate the entire scheduler.
312+
# Skip for partial aborts where only specific runs are targeted.
313+
$self->terminate(1) unless @runs;
310314
}
311315

312316
sub kill {

t/unit/Test2/Harness/Scheduler.t

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
11
use Test2::V0 -target => 'Test2::Harness::Scheduler';
22

3-
skip_all "write me";
3+
use Test2::Harness::Util::HashBase qw{};
4+
5+
subtest 'abort without runs terminates scheduler' => sub {
6+
my $scheduler = bless {
7+
runs => {},
8+
running => { jobs => {} },
9+
plugins => [],
10+
}, $CLASS;
11+
12+
ok(!$scheduler->terminated, 'not terminated before abort');
13+
$scheduler->abort();
14+
ok($scheduler->terminated, 'terminated after full abort');
15+
};
16+
17+
subtest 'abort with specific runs does not terminate scheduler' => sub {
18+
my $run_id = 'run-123';
19+
20+
my $run = mock {} => (
21+
add => [
22+
set_halt => sub { },
23+
],
24+
);
25+
26+
my $scheduler = bless {
27+
runs => { $run_id => $run },
28+
running => { jobs => {} },
29+
plugins => [],
30+
}, $CLASS;
31+
32+
ok(!$scheduler->terminated, 'not terminated before partial abort');
33+
$scheduler->abort($run_id);
34+
ok(!$scheduler->terminated, 'not terminated after partial abort');
35+
};
36+
37+
subtest 'kill delegates to abort and terminates' => sub {
38+
my $scheduler = bless {
39+
runs => {},
40+
running => { jobs => {} },
41+
plugins => [],
42+
}, $CLASS;
43+
44+
$scheduler->kill();
45+
ok($scheduler->terminated, 'terminated after kill');
46+
};
447

548
done_testing;

0 commit comments

Comments
 (0)