Commit e8dce071 authored by Aaron Wells's avatar Aaron Wells

Move the Behat test short circuit, to further down the line

We can still run unit tests and the minaccept, to gain information
about the patch, before we decide to exit because the uploader forgot
to write a Behat test for it.
parent e1ce4af9
...@@ -72,7 +72,6 @@ $i = 0; ...@@ -72,7 +72,6 @@ $i = 0;
$trustedusers = array(); $trustedusers = array();
foreach ($commitancestors as $commit) { foreach ($commitancestors as $commit) {
$commit = trim($commit); $commit = trim($commit);
$i++;
$content = gerrit_query('/changes/?q=commit:' . $commit . '+branch:' . $GERRIT_BRANCH . '&o=LABELS&o=CURRENT_REVISION&pp=0'); $content = gerrit_query('/changes/?q=commit:' . $commit . '+branch:' . $GERRIT_BRANCH . '&o=LABELS&o=CURRENT_REVISION&pp=0');
// Because we queried by commit and branch, should return exactly one record. // Because we queried by commit and branch, should return exactly one record.
...@@ -144,7 +143,7 @@ foreach ($commitancestors as $commit) { ...@@ -144,7 +143,7 @@ foreach ($commitancestors as $commit) {
// in groups that are set to make their list of members public) // in groups that are set to make their list of members public)
$groups = gerrit_query('/accounts/' . $uploader . '/groups/?pp=0'); $groups = gerrit_query('/accounts/' . $uploader . '/groups/?pp=0');
foreach ($groups as $group) { foreach ($groups as $group) {
if ($groups->owner == 'Mahara Reviewers' || $groups->owner == 'Mahara Testers') { if ($group->owner == 'Mahara Reviewers' || $group->owner == 'Mahara Testers') {
$trustedusers[$uploader] = true; $trustedusers[$uploader] = true;
} }
} }
...@@ -175,24 +174,7 @@ foreach ($commitancestors as $commit) { ...@@ -175,24 +174,7 @@ foreach ($commitancestors as $commit) {
echo "$i. Ancestor patch with git commit id $commit looks ok so we will continue\n"; echo "$i. Ancestor patch with git commit id $commit looks ok so we will continue\n";
} }
$firstcommit = false; $firstcommit = false;
} $i++;
echo "\n";
echo "########## Check the patch contains a Behat test\n";
echo "\n";
if (trim(shell_exec("git diff-tree --no-commit-id --name-only -r HEAD | grep -c $BEHATTESTREGEX")) >= 1) {
echo "Patch includes a Behat test.\n";
}
else {
echo "This patch does not include a Behat test!\n";
# Check whether the commit message has "behatnotneeded" in it.
if (trim(shell_exec("git log -1 | grep -i -c $BEHATNOTNEEDED")) >= 1) {
echo "... but the patch is marked with \"$BEHATNOTNEEDED\", so we will continue.\n";
}
else {
echo "Please write a Behat test for it, or, if it cannot be tested, put \"$BEHATNOTNEEDED\" in its commit message.\n";
exit(1);
}
} }
echo "\n"; echo "\n";
...@@ -232,6 +214,24 @@ echo "########## Run unit tests\n"; ...@@ -232,6 +214,24 @@ echo "########## Run unit tests\n";
echo "\n"; echo "\n";
passthru_or_die('external/vendor/bin/phpunit htdocs/'); passthru_or_die('external/vendor/bin/phpunit htdocs/');
echo "\n";
echo "########## Verify that the patch contains a Behat test\n";
echo "\n";
if (trim(shell_exec("git diff-tree --no-commit-id --name-only -r HEAD | grep -c $BEHATTESTREGEX")) >= 1) {
echo "Patch includes a Behat test.\n";
}
else {
echo "This patch does not include a Behat test!\n";
# Check whether the commit message has "behatnotneeded" in it.
if (trim(shell_exec("git log -1 | grep -i -c $BEHATNOTNEEDED")) >= 1) {
echo "... but the patch is marked with \"$BEHATNOTNEEDED\", so we will continue.\n";
}
else {
echo "Please write a Behat test for it, or, if it cannot be tested, put \"$BEHATNOTNEEDED\" in its commit message.\n";
exit(1);
}
}
echo "\n"; echo "\n";
echo "########## Build & Minify CSS\n"; echo "########## Build & Minify CSS\n";
echo "\n"; echo "\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment