File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
312316sub kill {
Original file line number Diff line number Diff line change 11use 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
548done_testing;
You can’t perform that action at this time.
0 commit comments