Debian Codegraph @

t/unit/Test2/Harness/TestFile.t

raw
1 use Test2::V0 -target => 'Test2::Harness::TestFile';
2 # HARNESS-DURATION-SHORT
3
4 use ok $CLASS;
5
6 use Test2::Tools::GenTemp qw/gen_temp/;
7
8 my $tmp = gen_temp(
9 long => "#!/usr/bin/perl\n\nuse strict;\n use warnings\n\n# HARNESS-CAT-LONG\n# HARNESS-NO-TIMEOUT\n# HARNESS-USE-ISOLATION\nfoo\n# HARNESS-NO-SEE\n",
10 med1 => "# HARNESS-NO-PRELOAD\n",
11 med2 => "#HARNESS-NO-FORK\n",
12 all => "#HARNESS-NO-TIMEOUT\n# HARNESS-NO-STREAM\n# HARNESS-NO-FORK\n# HARNESS-NO-PRELOAD\n# HARNESS-USE-ISOLATION\n",
13 notime => "#HARNESS-NO-TIMEOUT\n",
14 warn => "#!/usr/bin/perl -w\n",
15 taint => "#!/usr/bin/env perl -t -w\n",
16 foo => "#HARNESS-CATEGORY-FOO\n#HARNESS-STAGE-FoO",
17 meta => "#HARNESS-META-mykey-myval\n# HARNESS-META-otherkey-otherval\n# HARNESS-META mykey my-val2\n# HARNESS-META slack #my-val # comment after harness statement\n",
18
19 package => "package Foo::Bar::Baz;\n# HARNESS-NO-PRELOAD\n",
20
21 timeout => "# HARNESS-TIMEOUT-EVENT 90\n# HARNESS-TIMEOUT-POSTEXIT 85\n",
22 timeout2 => "# HARNESS-TIMEOUT-EVENT-90\n# HARNESS-TIMEOUT-POST-EXIT 85\n",
23 badtimeout => "# HARNESS-TIMEOUT-EVENTX 90\n# HARNESS-TIMEOUT-POSTEXITX 85\n",
24
25 conflicts1 => "# HARNESS-CONFLICTS PASSWD\n",
26 conflicts2 => "# HARNESS-CONFLICTS PASSWD DAEMON\n",
27 conflicts3 => "# HARNESS-CONFLICTS PASSWD\n# HARNESS-CONFLICTS DAEMON # Nothing to see here\n",
28 conflicts4 => "# HARNESS-CONFLICTS PASSWD DAEMON\n# HARNESS-CONFLICTS PASSWD\n# HARNESS-CONFLICTS PASSWD\n# HARNESS-CONFLICTS PASSWD DAEMON\n",
29
30 shares1 => "# HARNESS-SHARES PASSWD\n",
31 shares2 => "# HARNESS-SHARES-PASSWD\n",
32 shares3 => "# HARNESS-SHARES PASSWD DAEMON\n",
33 shares4 => "# HARNESS-SHARES PASSWD\n# HARNESS-SHARES-DAEMON # Nothing to see here\n",
34 shares5 => "# HARNESS-SHARES PASSWD DAEMON\n# HARNESS-SHARES PASSWD\n# HARNESS-SHARES-PASSWD\n",
35
36 both => "# HARNESS-CONFLICTS DAEMON\n# HARNESS-SHARES PASSWD DAEMON\n",
37
38 extra_comments => "#!/usr/bin/perl\n\nuse strict;\n# comment here\n use warnings\n\n# copyright Dewey Cheatem and Howe\n# HARNESS-CAT-LONG\n# HARNESS-NO-TIMEOUT\n# HARNESS-USE-ISOLATION\n",
39
40 smoke1 => "#HARNESS-SMOKE\n",
41 smoke2 => "#HARNESS-YES-SMOKE\n",
42
43 retry => "#HARNESS-RETRY\n", # mean retry once => --retry similar to --retry=1
44 retry5 => "#HARNESS-RETRY 5\n",
45 retry_iso => "#HARNESS-RETRY-ISO\n",
46 retry_iso3 => "#HARNESS-RETRY-ISO 3\n",
47 no_retry => "#HARNESS-NO-RETRY\n",
48
49 not_perl => "#!/usr/bin/bash\n",
50 not_env_perl => "#!/usr/bin/env bash\n",
51 binary => "\0\a\cX\e\n\cR",
52 );
53
54 subtest timeouts => sub {
55 my $one = $CLASS->new(file => File::Spec->catfile($tmp, 'timeout'));
56 is($one->event_timeout, 90, "set event timeout");
57 is($one->post_exit_timeout, 85, "set event timeout");
58
59 my $task = $one->queue_item(42);
60 is($task->{event_timeout}, 90, "event timeout made it to task");
61 is($task->{post_exit_timeout}, 85, "post-exit timeout made it to task");
62
63 my $two = $CLASS->new(file => File::Spec->catfile($tmp, 'timeout2'));
64 is($two->event_timeout, 90, "set event timeout");
65 is($two->post_exit_timeout, 85, "set event timeout");
66
67 my $bad = $CLASS->new(file => File::Spec->catfile($tmp, 'badtimeout'));
68 is(
69 warnings { $bad->headers },
70 [
71 "'EVENTX' is not a valid timeout type, use 'EVENT' or 'POSTEXIT' at " . $bad->file . " line 1.\n",
72 "'POSTEXITX' is not a valid timeout type, use 'EVENT' or 'POSTEXIT' at " . $bad->file . " line 2.\n",
73 ],
74 "Got warnings"
75 );
76 };
77
78 subtest invalid => sub {
79 like(
80 dies { $CLASS->new(file => File::Spec->catfile($tmp, 'invalid')) },
81 qr/^Invalid test file/,
82 "Need a valid test file"
83 );
84 };
85
86 subtest meta => sub {
87 my $foo = $CLASS->new(file => File::Spec->catfile($tmp, 'meta'));
88
89 is([$foo->meta], [], "No key returns empty list");
90 is([$foo->meta('foo')], [], "Empty key returns empty list");
91 is([$foo->meta('mykey')], [qw/myval my-val2/], "Got both values for the 'mykey' key");
92 is([$foo->meta('otherkey')], ['otherval'], "Got other key");
93 is([$foo->meta('slack')], ['#my-val'], "Got hyphenated key");
94 };
95
96 subtest foo => sub {
97 my $foo = $CLASS->new(file => File::Spec->catfile($tmp, 'foo'));
98 is($foo->check_category, 'foo', "Category is foo");
99 is($foo->check_stage, 'FoO', "Stage is FoO, case-sensitive");
100 };
101
102 subtest package => sub {
103 my $one = $CLASS->new(file => File::Spec->catfile($tmp, 'package'));
104 is($one->queue_item(42)->{use_preload}, 0, "No preload");
105 };
106
107 subtest taint => sub {
108 my $taint = $CLASS->new(file => File::Spec->catfile($tmp, 'taint'), queue_args => [via => ['xxx']]);
109
110 is($taint->switches, ['-t', '-w'], "No SHBANG switches");
111 is($taint->shbang, {switches => ['-t', '-w'], line => "#!/usr/bin/env perl -t -w"}, "Parsed shbang");
112
113 is(
114 $taint->queue_item(42),
115 {
116 category => 'general',
117 duration => 'medium',
118 stage => undef,
119 file => $taint->file,
120 rel_file => $taint->relative,
121 job_name => 42,
122 job_id => T(),
123 stamp => T(),
124 switches => ['-t', '-w'],
125 use_fork => 1,
126 use_preload => 1,
127 use_stream => 1,
128 io_events => 1,
129 use_timeout => 1,
130 binary => 0,
131 non_perl => 0,
132 smoke => 0,
133 conflicts => [],
134 shares => [],
135 via => ['xxx'],
136 rank => T(),
137 run_id => FDNE(),
138 },
139 "Got queue item data",
140 );
141 };
142
143 subtest warn => sub {
144 my $warn = $CLASS->new(file => File::Spec->catfile($tmp, 'warn'));
145
146 is($warn->switches, ['-w'], "got SHBANG switches");
147 is($warn->shbang, {switches => ['-w'], line => "#!/usr/bin/perl -w"}, "Parsed shbang");
148
149 is(
150 $warn->queue_item(42),
151 {
152 category => 'general',
153 duration => 'medium',
154 stage => undef,
155 file => $warn->file,
156 rel_file => $warn->relative,
157 job_name => 42,
158 job_id => T(),
159 stamp => T(),
160 rank => T(),
161 switches => ['-w'],
162 use_fork => 1,
163 use_preload => 1,
164 use_stream => 1,
165 io_events => 1,
166 use_timeout => 1,
167 binary => 0,
168 non_perl => 0,
169 smoke => 0,
170 conflicts => [],
171 shares => [],
172 run_id => FDNE(),
173 },
174 "Got queue item data",
175 );
176 };
177
178 subtest notime => sub {
179 my $notime = $CLASS->new(file => File::Spec->catfile($tmp, 'notime'));
180
181 is($notime->check_feature('timeout'), 0, "Timeouts turned off");
182 is($notime->check_feature('timeout', 1), 0, "Timeouts turned off with default 1");
183
184 is($notime->check_category, 'general', "Category is general");
185 is($notime->check_duration, 'long', "Duration is long");
186
187 is($notime->switches, [], "No SHBANG switches");
188 is($notime->shbang, {}, "No shbang");
189
190 is(
191 $notime->queue_item(42),
192 {
193 category => 'general',
194 duration => 'long',
195 stage => undef,
196 file => $notime->file,
197 rel_file => $notime->relative,
198 job_name => 42,
199 job_id => T(),
200 rank => T(),
201 stamp => T(),
202 switches => [],
203 use_fork => 1,
204 use_preload => 1,
205 use_stream => 1,
206 io_events => 1,
207 use_timeout => 0,
208 binary => 0,
209 non_perl => 0,
210 smoke => 0,
211 conflicts => [],
212 shares => [],
213 run_id => FDNE(),
214 },
215 "Got queue item data",
216 );
217 };
218
219 subtest all => sub {
220 my $all = $CLASS->new(file => File::Spec->catfile($tmp, 'all'));
221
222 is($all->check_feature('timeout'), 0, "Timeouts turned off");
223 is($all->check_feature('timeout', 1), 0, "Timeouts turned off with default 1");
224
225 is($all->check_feature('fork'), 0, "Forking is off");
226 is($all->check_feature('fork', 1), 0, "Checking fork with different default");
227
228 is($all->check_feature('preload'), 0, "Preload is off");
229 is($all->check_feature('preload', 1), 0, "Checking preload with different default");
230
231 is($all->check_feature('isolation'), 1, "No isolation");
232 is($all->check_feature('isolation', 0), 1, "Use isolation with a default of false");
233
234 is($all->check_feature('stream'), 0, "Use stream");
235 is($all->check_feature('stream', 1), 0, "no stream with a default of true");
236
237 is($all->check_category, 'isolation', "Category is isolation");
238
239 is($all->switches, [], "No SHBANG switches");
240 is($all->shbang, {}, "No shbang");
241
242 is(
243 $all->queue_item(42),
244 {
245 category => 'isolation',
246 duration => 'long',
247 stage => undef,
248 file => $all->file,
249 rel_file => $all->relative,
250 job_name => 42,
251 job_id => T(),
252 rank => T(),
253 stamp => T(),
254 switches => [],
255 use_fork => 0,
256 use_preload => 0,
257 use_stream => 0,
258 io_events => 1,
259 use_timeout => 0,
260 smoke => 0,
261 conflicts => [],
262 shares => [],
263 binary => 0,
264 non_perl => 0,
265 run_id => FDNE(),
266 },
267 "Got queue item data",
268 );
269 };
270
271 subtest med2 => sub {
272 my $med2 = $CLASS->new(file => File::Spec->catfile($tmp, 'med2'));
273
274 is($med2->check_feature('timeout'), 1, "Timeouts turned on");
275 is($med2->check_feature('timeout', 0), 0, "Timeouts turned off with default 0");
276
277 is($med2->check_feature('fork'), 0, "Forking is off");
278 is($med2->check_feature('fork', 1), 0, "Checking fork with different default");
279
280 is($med2->check_feature('preload'), 1, "Preload is on");
281 is($med2->check_feature('preload', 0), 0, "Checking preload with different default");
282
283 is($med2->check_feature('isolation'), 0, "No isolation");
284 is($med2->check_feature('isolation', 1), 1, "Use isolation with a default of true");
285
286 is($med2->check_feature('stream'), 1, "Use stream");
287 is($med2->check_feature('stream', 0), 0, "no stream with a default of false");
288
289 is($med2->check_category, 'general', "Category is general");
290 is($med2->check_duration, 'medium', "duration is medium");
291
292 is($med2->switches, [], "No SHBANG switches");
293 is($med2->shbang, {}, "No shbang");
294
295 is(
296 $med2->queue_item(42),
297 {
298 run_id => FDNE(),
299 category => 'general',
300 duration => 'medium',
301 stage => undef,
302 file => $med2->file,
303 rel_file => $med2->relative,
304 job_name => 42,
305 job_id => T(),
306 rank => T(),
307 stamp => T(),
308 switches => [],
309 use_fork => 0,
310 use_preload => 1,
311 use_stream => 1,
312 io_events => 1,
313 use_timeout => 1,
314 binary => 0,
315 non_perl => 0,
316 smoke => 0,
317 conflicts => [],
318 shares => [],
319 },
320 "Got queue item data",
321 );
322 };
323
324 subtest med1 => sub {
325 my $med1 = $CLASS->new(file => File::Spec->catfile($tmp, 'med1'));
326
327 is($med1->check_feature('timeout'), 1, "Timeouts turned on");
328 is($med1->check_feature('timeout', 0), 0, "Timeouts turned off with default 0");
329
330 is($med1->check_feature('fork'), 1, "Forking is ok");
331 is($med1->check_feature('fork', 0), 0, "Checking fork with different default");
332
333 is($med1->check_feature('preload'), 0, "Preload is off");
334 is($med1->check_feature('preload', 1), 0, "Checking preload with different default");
335
336 is($med1->check_feature('isolation'), 0, "No isolation");
337 is($med1->check_feature('isolation', 1), 1, "Use isolation with a default of true");
338
339 is($med1->check_feature('stream'), 1, "Use stream");
340 is($med1->check_feature('stream', 0), 0, "no stream with a default of false");
341
342 is($med1->check_category, 'general', "Category is general");
343 is($med1->check_duration, 'medium', "duration is medium");
344
345 is($med1->switches, [], "No SHBANG switches");
346 is($med1->shbang, {}, "No shbang");
347
348 is(
349 $med1->queue_item(42),
350 {
351 run_id => FDNE(),
352 category => 'general',
353 duration => 'medium',
354 stage => undef,
355 file => $med1->file,
356 rel_file => $med1->relative,
357 job_name => 42,
358 stamp => T(),
359 rank => T(),
360 job_id => T(),
361 switches => [],
362 use_fork => 1,
363 use_preload => 0,
364 use_stream => 1,
365 io_events => 1,
366 use_timeout => 1,
367 binary => 0,
368 non_perl => 0,
369 smoke => 0,
370 conflicts => [],
371 shares => [],
372 },
373 "Got queue item data",
374 );
375 };
376
377 subtest long => sub {
378 my $long = $CLASS->new(file => File::Spec->catfile($tmp, 'long'));
379
380 is($long->check_feature('timeout'), 0, "Timeouts turned off");
381 is($long->check_feature('timeout', 1), 0, "Timeouts turned off even with default 1");
382
383 is($long->check_feature('fork'), 1, "Forking is ok");
384 is($long->check_feature('fork', 0), 0, "Checking fork with different default");
385
386 is($long->check_feature('preload'), 1, "Preload is ok");
387 is($long->check_feature('preload', 0), 0, "Checking preload with different default");
388
389 is($long->check_feature('isolation'), 1, "Use isolation");
390 is($long->check_feature('isolation', 0), 1, "Use isolation even with a default of false");
391
392 is($long->check_feature('stream'), 1, "Use stream");
393 is($long->check_feature('stream', 0), 0, "no stream with a default of false");
394
395 is($long->check_category, 'isolation', "Category is isolation");
396 is($long->check_duration, 'long', "duration is long");
397
398 ok(!exists $long->headers->{SEE}, "Did not see directive after code line");
399
400 is($long->switches, [], "No SHBANG switches");
401 is($long->shbang, {switches => [], line => "#!/usr/bin/perl"}, "got shbang");
402
403 is(
404 $long->queue_item(42),
405 {
406 run_id => FDNE(),
407 category => 'isolation',
408 duration => 'long',
409 stage => undef,
410 file => $long->file,
411 rel_file => $long->relative,
412 job_name => 42,
413 job_id => T(),
414 rank => T(),
415 stamp => T(),
416 switches => [],
417 use_fork => 1,
418 use_preload => 1,
419 use_stream => 1,
420 io_events => 1,
421 use_timeout => 0,
422 binary => 0,
423 non_perl => 0,
424 smoke => 0,
425 conflicts => [],
426 shares => [],
427 },
428 "Got queue item data",
429 );
430 };
431
432 subtest extra_comments => sub {
433 my $long = $CLASS->new(file => File::Spec->catfile($tmp, 'extra_comments'));
434
435 is($long->check_feature('timeout'), 0, "Timeouts turned off");
436 is($long->check_feature('timeout', 1), 0, "Timeouts turned off even with default 1");
437
438 is($long->check_feature('fork'), 1, "Forking is ok");
439 is($long->check_feature('fork', 0), 0, "Checking fork with different default");
440
441 is($long->check_feature('preload'), 1, "Preload is ok");
442 is($long->check_feature('preload', 0), 0, "Checking preload with different default");
443
444 is($long->check_feature('isolation'), 1, "Use isolation");
445 is($long->check_feature('isolation', 0), 1, "Use isolation even with a default of false");
446
447 is($long->check_feature('stream'), 1, "Use stream");
448 is($long->check_feature('stream', 0), 0, "no stream with a default of false");
449
450 is($long->check_category, 'isolation', "Category is isolation");
451 is($long->check_duration, 'long', "Duration is long");
452
453 is($long->switches, [], "No SHBANG switches");
454 is($long->shbang, {switches => [], line => "#!/usr/bin/perl"}, "got shbang");
455
456 is(
457 $long->queue_item(42),
458 {
459 run_id => FDNE(),
460 category => 'isolation',
461 duration => 'long',
462 stage => undef,
463 file => $long->file,
464 rel_file => $long->relative,
465 job_name => 42,
466 job_id => T(),
467 rank => T(),
468 stamp => T(),
469 switches => [],
470 use_fork => 1,
471 use_preload => 1,
472 use_stream => 1,
473 io_events => 1,
474 use_timeout => 0,
475 binary => 0,
476 non_perl => 0,
477 smoke => 0,
478 conflicts => [],
479 shares => [],
480 },
481 "Got queue item data",
482 );
483 };
484
485 subtest conflicts => sub {
486 my $parsed_file = $CLASS->new(file => File::Spec->catfile($tmp, 'conflicts1'));
487 is($parsed_file->conflicts_list, ['passwd'], "1 conflict line is reflected as an array");
488
489 $parsed_file = $CLASS->new(file => File::Spec->catfile($tmp, 'conflicts2'));
490 is([sort @{$parsed_file->conflicts_list}], ['daemon', 'passwd'], "1 conflict line with 2 conflict categories");
491
492 $parsed_file = $CLASS->new(file => File::Spec->catfile($tmp, 'conflicts3'));
493 is([sort @{$parsed_file->conflicts_list}], ['daemon', 'passwd'], "2 conflict lines with some comments on one of them");
494
495 $parsed_file = $CLASS->new(file => File::Spec->catfile($tmp, 'conflicts4'));
496 is([sort @{$parsed_file->conflicts_list}], ['daemon', 'passwd'], "Duplicate conflict lines only lead to 2 conflict items.");
497
498 };
499
500 sub shares_in {
501 my ($name) = @_;
502 my $file = $CLASS->new(file => File::Spec->catfile($tmp, $name));
503 return [sort @{$file->shares_list}];
504 }
505
506 subtest shares => sub {
507 is(shares_in('shares1'), ['passwd'], "1 share on 1 line is reflected as an array");
508 is(shares_in('shares2'), ['passwd'], "dashes and spaces delimit the same way");
509 is(shares_in('shares3'), ['daemon', 'passwd'], "1 share line with 2 share categories");
510 is(shares_in('shares4'), ['daemon', 'passwd'], "2 share lines with a comment on one of them");
511 is(shares_in('shares5'), ['daemon', 'passwd'], "Duplicate share lines only lead to 2 share items");
512 };
513
514 subtest shares_and_conflicts => sub {
515 my $file = $CLASS->new(file => File::Spec->catfile($tmp, 'both'));
516
517 is(
518 warnings { $file->headers },
519 ["'daemon' is listed as both a conflict and a share in " . $file->file . ", treating it as a conflict.\n"],
520 "Warned about the name claimed both exclusively and shared",
521 );
522
523 is([sort @{$file->conflicts_list}], ['daemon'], "Exclusive claim was kept");
524 is([sort @{$file->shares_list}], ['passwd'], "Shared claim on the same name was dropped");
525 };
526
527 subtest binary => sub {
528 my $path = File::Spec->catfile($tmp, 'binary');
529 ok(-B $path, "File is binary");
530
531 like(
532 dies { my $binary = $CLASS->new(file => $path); $binary->shbang },
533 qr{Cannot run binary test file '[^']*\Q$path\E': file is not executable\.},
534 "File must be executable",
535 );
536
537 my $control = mock $CLASS => (
538 override => [
539 is_executable => sub { 1 },
540 ],
541 );
542
543 my $binary = $CLASS->new(file => $path);
544 is($binary->switches, [], "No SHBANG switches");
545 is($binary->shbang, {}, "No shbang");
546
547 is(
548 $binary->queue_item(42),
549 {
550 run_id => FDNE(),
551 category => 'general',
552 duration => 'medium',
553 stage => undef,
554 file => match qr{\Q$path\E$},
555 rel_file => $binary->relative,
556 job_name => 42,
557 job_id => T(),
558 rank => T(),
559 stamp => T(),
560 switches => [],
561 use_fork => 1,
562 use_preload => 1,
563 use_stream => 1,
564 io_events => 1,
565 use_timeout => 1,
566 conflicts => [],
567 shares => [],
568 binary => 1,
569 non_perl => 1,
570 smoke => 0,
571 },
572 "Got queue item data",
573 );
574 };
575
576 subtest not_perl => sub {
577 my $path = File::Spec->catfile($tmp, 'not_perl');
578
579 my $not_perl = $CLASS->new(file => File::Spec->catfile($tmp, 'not_perl'));
580
581 is($not_perl->switches, [], "No SHBANG switches");
582 is($not_perl->shbang, {line => "#!/usr/bin/bash", non_perl => 1}, "Non-perl shbang");
583
584 is(
585 $not_perl->queue_item(42),
586 {
587 run_id => FDNE(),
588 category => 'general',
589 duration => 'medium',
590 stage => undef,
591 file => match qr{\Q$path\E$},
592 rel_file => $not_perl->relative,
593 job_name => 42,
594 job_id => T(),
595 rank => T(),
596 stamp => T(),
597 switches => [],
598 use_fork => 1,
599 use_preload => 1,
600 use_stream => 1,
601 io_events => 1,
602 use_timeout => 1,
603 conflicts => [],
604 shares => [],
605 binary => 0,
606 non_perl => 1,
607 smoke => 0,
608 },
609 "Got queue item data",
610 );
611 };
612
613
614 subtest not_env_perl => sub {
615 my $path = File::Spec->catfile($tmp, 'not_env_perl');
616
617 my $not_env_perl = $CLASS->new(file => File::Spec->catfile($tmp, 'not_env_perl'));
618
619 is($not_env_perl->switches, [], "No SHBANG switches");
620 is($not_env_perl->shbang, {line => "#!/usr/bin/env bash", non_perl => 1}, "Non-perl shbang");
621
622 is(
623 $not_env_perl->queue_item(42),
624 {
625 run_id => FDNE(),
626 category => 'general',
627 duration => 'medium',
628 stage => undef,
629 file => match qr{\Q$path\E$},
630 rel_file => $not_env_perl->relative,
631 job_name => 42,
632 job_id => T(),
633 rank => T(),
634 stamp => T(),
635 switches => [],
636 use_fork => 1,
637 use_preload => 1,
638 use_stream => 1,
639 io_events => 1,
640 use_timeout => 1,
641 conflicts => [],
642 shares => [],
643 smoke => 0,
644 binary => 0,
645 non_perl => 1,
646 },
647 "Got queue item data",
648 );
649 };
650
651 subtest smoke => sub {
652 my $path = File::Spec->catfile($tmp, 'smoke1');
653 my $smoke1 = $CLASS->new(file => $path);
654 is($smoke1->check_feature(smoke => 0), 1, "Turned smoke on");
655 is(
656 $smoke1->queue_item(42),
657 {
658 run_id => FDNE(),
659 category => 'general',
660 duration => 'medium',
661 stage => undef,
662 file => match qr{\Q$path\E$},
663 rel_file => $smoke1->relative,
664 job_name => 42,
665 rank => T(),
666 job_id => T(),
667 stamp => T(),
668 switches => [],
669 use_fork => 1,
670 use_preload => 1,
671 use_stream => 1,
672 io_events => 1,
673 use_timeout => 1,
674 binary => 0,
675 non_perl => 0,
676 smoke => 1,
677 conflicts => [],
678 shares => [],
679 },
680 "Got queue item data",
681 );
682
683 my $smoke2 = $CLASS->new(file => File::Spec->catfile($tmp, 'smoke2'));
684 is($smoke2->check_feature(smoke => 0), 1, "Turned smoke on");
685 };
686
687 subtest smoke => sub {
688 my $retry = $CLASS->new(file => File::Spec->catfile($tmp, 'retry'));
689 my $task = $retry->queue_item(42);
690 is($task->{retry}, 1, "Enabled retry");
691 ok(!exists($task->{retry_isolated}), "not isolated");
692
693 $retry = $CLASS->new(file => File::Spec->catfile($tmp, 'retry5'));
694 $task = $retry->queue_item(42);
695 is($task->{retry}, 5, "Enabled retry, value of 5 results in '6' because of initial try");
696 ok(!exists($task->{retry_isolated}), "not isolated");
697
698 $retry = $CLASS->new(file => File::Spec->catfile($tmp, 'retry_iso'));
699 $task = $retry->queue_item(42);
700 is($task->{retry}, 1, "Enabled retry");
701 is($task->{retry_isolated}, T(), "isolated retry");
702
703 $retry = $CLASS->new(file => File::Spec->catfile($tmp, 'retry_iso3'));
704 $task = $retry->queue_item(42);
705 is($task->{retry}, 3, "Enabled retry, 1 initital + 3 retries");
706 is($task->{retry_isolated}, T(), "isolated retry");
707
708 $retry = $CLASS->new(file => File::Spec->catfile($tmp, 'no_retry'));
709 $task = $retry->queue_item(42);
710 is($task->{retry}, 0, "Retry set to 0");
711 ok(!exists($task->{retry_isolated}), "not isolated");
712 };
713
714 done_testing;