check that at least one test was added
This commit is contained in:
parent
e89a3ffc97
commit
3df5204252
35
t/merge-ready/added-test.t
Normal file
35
t/merge-ready/added-test.t
Normal file
@ -0,0 +1,35 @@
|
||||
use 5.38.0;
|
||||
|
||||
use Test2::V0;
|
||||
|
||||
use Git::Wrapper;
|
||||
|
||||
my $target_branch = $ENV{TARGET_BRANCH} // 'main';
|
||||
|
||||
my $git = Git::Wrapper->new('.');
|
||||
|
||||
my $on_target = grep { "* $target_branch" eq $_ } $git->branch;
|
||||
|
||||
if ($on_target) {
|
||||
pass "nothing to check here";
|
||||
}
|
||||
else {
|
||||
my @diff = $git->diff($target_branch);
|
||||
ok test_file_modified(@diff), "added to a test file";
|
||||
}
|
||||
|
||||
sub test_file_modified (@diff) {
|
||||
my $in_test_file = 0;
|
||||
for (@diff) {
|
||||
if (/^diff/) {
|
||||
$in_test_file = /\.t$/;
|
||||
next;
|
||||
}
|
||||
|
||||
return 1 if $in_test_file and /^\+/;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
done_testing;
|
Loading…
Reference in New Issue
Block a user