diff --git a/client/pifr_client.module b/client/pifr_client.module
index ec49647..62064c6 100644
--- a/client/pifr_client.module
+++ b/client/pifr_client.module
@@ -19,7 +19,8 @@ define('PIFR_CHART_REPOSITORY', variable_get('pifr_chart_repository', 'git://git
define('PIFR_MULTIVARIATE_REPOSITORY', variable_get('pifr_multivariate_repository', 'git://git.drupal.org/project/multivariate.git'));
define('PIFR_SIMPLETEST_REPOSITORY', variable_get('pifr_simpletest_repository', 'git://git.drupal.org/project/chart.git'));
define('PIFR_MENU_REWRITE_REPOSITORY', variable_get('pifr_menu_rewrite_repository', 'git://git.drupal.org/project/menu_rewrite.git'));
-
+define('PIFR_DRUPAL6_CURRENTBRANCH', '6.22');
+define('PIFR_DRUPAL7_CURRENTBRANCH', '7.x');
/**
* The location of the PHP executable to be used when running tests.
diff --git a/client/pifr_client.review.inc b/client/pifr_client.review.inc
index a1afafe..47a3940 100644
--- a/client/pifr_client.review.inc
+++ b/client/pifr_client.review.inc
@@ -1,7 +1,7 @@
'fieldset',
- '#title' => t('Run'),
+ '#title' => t('Test Type'),
);
- $form['run']['type'] = array(
+ $form['testtype']['test'] = array(
'#type' => 'select',
- '#title' => t('Type'),
- '#description' => t('Full suite will be effected by the debug setting which can be set manually or auto ' .
- 'triggered by the presence of SimpleTest.'),
+ '#title' => t('Select test plugin'),
'#options' => array(
- 'default' => t('Default - Drupal 7, full suite'),
- 'quick' => t('Quick - Drupal 7, NonDefaultBlockAdmin test case'),
- 'fail' => t('Fail - Drupal 7, full suite, PHP exceptions'),
- 'd6' => t('Drupal 6 - Several dependencies, full suite'),
+ 'simpletest' => t('SimpleTest'),
+ 'coder' => t('Code Review'),
),
+ '#default_value' => 'pifr_simpletest',
+ '#description' => t('Represents the review plugin which will be invoked for this test.'),
);
- $form['run']['op'] = array(
- '#type' => 'submit',
- '#value' => t('Run'),
+ $form['testtype']['target'] = array(
+ '#type' => 'radios',
+ '#title' => t('Test Type'),
+ '#options' => array(
+ 'core' => 'Core',
+ 'branch' => 'Project Branch',
+ 'file' => 'File',
+ 'patch' => 'Patch',
+ ),
+ '#description' => t('Represents the object type which this test will target. (For Simpletest tests, File and Patch are equivalent.)'),
+ '#default_value' => 'branch',
+ );
+ $form['testtype']['interrupt'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Interrupt any existing tests in progress'),
);
+ $form['testtype']['selecttype'] = array(
+ '#type' => 'submit',
+ '#value' => t('Next >>'),
+ );
+
return $form;
}
/**
- * Run the pre-built tests.
+ * Client review form validation
+ */
+function pifr_client_review_form_validate($form, &$form_state) {
+
+ // Ensure testbot is not actively testing
+ if (variable_get('pifr_client_test', FALSE)) {
+ module_load_include('inc', 'pifr_client', 'pifr_client.cron');
+
+ $test = variable_get('pifr_client_test', FALSE);
+ if ($form_state['values']['interrupt'] == TRUE) {
+ // Reset client to prepare for next test.
+ watchdog('pifr_client', 'Reset client to allow for local test run (t: @test_id).', array('@test_id' => $test['test_id']));
+ pifr_client_cron_clear_variables();
+ pifr_client_cron_test_processes_kill(pifr_client_cron_test_processes_get());
+ }
+ else {
+ form_set_error('form', t('Unable to test due to an existing test in progress (t: @test_id).', array('@test_id' => $test['test_id'])));
+ }
+ }
+
+ if (isset($form_state['storage']['plugin'])) {
+ switch ($form_state['storage']['plugin']) {
+ case 'coder':
+ // Coder Form Validation Steps
+ pifr_client_review_form_validate_coder($form, &$form_state);
+ break;
+ case 'simpletest':
+ default:
+ // Simpletest Form Validation Steps
+ pifr_client_review_form_validate_simpletest($form, &$form_state);
+ break;
+ }
+ }
+}
+
+/**
+ * Client review form submission
*/
function pifr_client_review_form_submit($form, &$form_state) {
- // Set the test variable so that the admin interface reacts accordingly.
- $test = pifr_client_review_pre_built_test($form_state['values']['type']);
- variable_set('pifr_client_test', $test);
- if ($review = pifr_client_review_load($test)) {
- $review->run();
+ if ($form_state['clicked_button']['#id'] == 'edit-selecttype') {
+ // Handle plugin selection submission
+ $form_state['storage']['plugin'] = check_plain($form_state['values']['test']);
+ $form_state['storage']['target'] = check_plain($form_state['values']['target']);
+ }
+ else {
+ switch ($form_state['storage']['plugin']) {
+ case 'coder':
+ // Coder Form Submission Steps
+ pifr_client_review_form_submit_coder($form, $form_state);
+ break;
+ case 'simpletest':
+ default:
+ // Simpletest Form Submission Steps
+ pifr_client_review_form_submit_simpletest($form, $form_state);
+ break;
+ }
+ $form_state['rebuild'] = TRUE;
+ unset($form_state['storage']['plugin']);
+ }
+}
- // Display test information.
- drupal_set_message('Test: ' . pifr_client_review_export($test));
- drupal_set_message('Results: ' . pifr_client_review_export($review->get_result()));
+/**
+ * Client simpletest review form.
+ */
+function pifr_client_review_form_simpletest(&$form_state) {
+ $form = array();
- variable_del('pifr_client_test');
+ $form['runsimpletest'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Customize Simpletest Test Parameters'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+
+ $form['runsimpletest']['version'] = array(
+ '#type' => 'select',
+ '#title' => t('Drupal Core Version'),
+ '#options' => array(
+ 'd6' => t('Drupal 6'),
+ 'd7' => t('Drupal 7'),
+ ),
+ '#default_value' => 'd7',
+ );
+
+ switch ($form_state['storage']['target']) {
+ case 'core':
+ $form['runsimpletest']['coretest'] = array(
+ '#type' => 'radios',
+ '#title' => t('Type of core test to run'),
+ '#options' => array(
+ t('Full suite (All test cases)'),
+ t('Quick test (Single test case)'),
+ t('Failure scenario (Apply bad patch)'),
+ ),
+ '#default_value' => 0,
+ '#description' => t('Full suite will be effected by the debug setting which can be set manually or auto triggered by the presence of SimpleTest.'),
+ );
+
+ // No additional parameters required for a 'core' review
+ break;
+ case 'file':
+ case 'patch':
+ $form['branchtests']['patchfile'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload patch file'),
+ '#size' => 40,
+ '#weight' => 5,
+ );
+ $form['#attributes']['enctype'] = "multipart/form-data";
+ default:
+ $form['branchtests'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Identify Review Target'),
+ '#collapsible' => FALSE,
+ );
+
+ $desc = t('Please enter the Git repository location for the project which contains the branch to test.');
+ $desc .= ' ' . t('This may be a full project link such as git://git.drupal.org/project/drupal.git,');
+ $desc .= ' ' . t('or a sandbox project link such as git://git.drupal.org/sandbox/username/12345678.git.');
+
+ $form['branchtests']['repository'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project Repository'),
+ '#description' => $desc,
+ );
+
+ $desc = t('Please indicate the branch for which you want to run the test.');
+ $desc .= ' ' . t('This value must match an existing tag or branch within your Git repository.');
+ $desc .= ' ' . t('(Valid entries are listed under the "tags" and "heads" labels on the project repository summary page.)');
+
+ $form['branchtests']['branch'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project Branch'),
+ '#description' => $desc,
+ );
}
+
+ $form['op'] = array(
+ '#type' => 'submit',
+ '#value' => t('Run Test'),
+ );
+
+ return $form;
}
/**
- * Get a pre-built test, given the $type.
- *
- * @param string $type Test type, 'default', 'quick', 'fail', 'd6'.
- * @return array Pre-built test information array.
+ * Validate the client simpletest review form.
*/
-function pifr_client_review_pre_built_test($type) {
- // Get the default arguments to be passed to client.
+function pifr_client_review_form_validate_simpletest($form, &$form_state) {
+
+}
+
+/**
+ * Submit the client simpletest review form.
+ */
+function pifr_client_review_form_submit_simpletest($form, &$form_state) {
+ // Get the default arguments to be passed to client
module_load_include('review.inc', 'pifr_server');
$plugin = pifr_server_review_plugin_load('pifr_simpletest');
$default = $plugin->argument_default_get();
- if ($type == 'default' || $type == 'quick' || $type == 'fail') {
- // Provide Drupal HEAD repository and blank patch.
- $test = array(
- 'test_id' => 17,
- 'review' => array(
- 'plugin' => 'pifr_simpletest',
- 'argument' => $default,
+ // Generate basic simpletest $test array
+ $test = array(
+ 'test_id' => 17,
+ 'review' => array(
+ 'plugin' => 'pifr_simpletest',
+ 'argument' => $default,
+ ),
+ 'vcs' => array(
+ 'main' => array(
+ 'repository' => array(
+ 'type' => 'git',
+ 'url' => variable_get('pifr_drupal_repository', 'git://git.drupal.org/project/drupal.git'),
+ ),
+ 'vcs_identifier' => variable_get('pifr_confirmation_vcs_id', '7.2'),
),
- 'vcs' => array(
- 'main' => array(
- 'repository' => array(
- 'type' => 'git',
- 'url' => variable_get('pifr_drupal_repository', 'git://git.drupal.org/project/drupal.git'),
- ),
- 'vcs_identifier' => variable_get('pifr_confirmation_vcs_id', '7.2'),
+ 'dependencies' => array(),
+ ),
+ 'files' => array(),
+ );
+
+ // Update vcs_identifier (and dependencies if needed)
+ if ($form_state['values']['version'] == 'd6') {
+ $test['vcs']['main']['vcs_identifier'] = PIFR_DRUPAL6_CURRENTBRANCH;
+ $test['review']['argument']['drupal.core.version'] = 6;
+ // Update dependencies
+ $test['vcs']['dependencies'] = array(
+ array(
+ 'repository' => array(
+ 'type' => 'git',
+ 'url' => variable_get('pifr_multivariate_repository', 'git://git.drupal.org/project/multivariate.git'),
),
- 'dependencies' => array(),
+ 'vcs_identifier' => 'master', // GITMIGRATION Fragile
),
- 'files' => array(
- url(drupal_get_path('module', 'pifr_simpletest') . '/confirmation/pass.patch', array('absolute' => TRUE)),
+ array(
+ 'repository' => array(
+ 'type' => 'git',
+ 'url' => variable_get('pifr_chart_repository', 'git://git.drupal.org/project/chart.git'),
+ ),
+ 'vcs_identifier' => '6.x-1.3', // GITMIGRATION Fragile
),
);
+ }
+ elseif ($form_state['values']['version'] == 'd7') {
+ $test['vcs']['main']['vcs_identifier'] = PIFR_DRUPAL7_CURRENTBRANCH;
+ $test['review']['argument']['drupal.core.version'] = 7;
+ }
+ // Update with user-specific values
+ switch($form_state['storage']['target']) {
+ case 'patch':
+ case 'file':
+ $test['files'][] = file_create_url(file_create_path('localpatches') . '/' . $form_state['values']['file']->filename);
+ case 'branch':
+ // Update the 'dependencies' section with the project to be reviewed
+ $test['vcs']['dependencies'][] = array(
+ 'repository' => array(
+ 'type' => 'git',
+ 'url' => check_plain($form_state['values']['repository']),
+ ),
+ 'vcs_identifier' => check_plain($form_state['values']['branch']),
+ );
+ break;
+ case 'core':
+ if ($form_state['values']['coretest'] == 1) {
+ // Quick test
+ if ($form_state['values']['version'] == 'd7') {
+ $test['review']['argument']['simpletest.tests'] = array('NonDefaultBlockAdmin');
+ }
+ elseif ($form_state['values']['version'] == 'd6') {
+ $test['review']['argument']['simpletest.tests'] = array('SimpleTestFolderTestCase');
+ }
+ }
+ elseif ($form_state['values']['coretest'] == 2) {
+ // Failure Scenario
+ $test['files'] = array(
+ url(drupal_get_path('module', 'pifr_simpletest') . '/confirmation/fail.patch', array('absolute' => TRUE)),
+ );
+ }
+ break;
+ default:
+ break;
+ }
- // Provide quickest test.
- if ($type == 'quick') {
- $test['review']['argument']['tests'] = array('NonDefaultBlockAdmin');
- }
- elseif ($type == 'fail') {
- $test['files'] = array(
- url(drupal_get_path('module', 'pifr_simpletest') . '/confirmation/fail.patch', array('absolute' => TRUE)),
+ // Set the test variable so that the admin interface reacts accordingly.
+ variable_set('pifr_client_test', $test);
+
+ if ($review = pifr_client_review_load($test)) {
+ variable_set('pifr_client_test_start', time());
+ $review->run();
+
+ // Display test information.
+ drupal_set_message('Test: ' . pifr_client_review_export($test));
+ drupal_set_message('Results: ' . pifr_client_review_export($review->get_result()));
+
+ variable_del('pifr_client_test');
+ }
+}
+
+/**
+ * Client coder review form.
+ */
+function pifr_client_review_form_coder(&$form_state) {
+ $form = array();
+
+ $form['runcoder'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Customize Coder Test Parameters'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+
+ $form['runcoder']['version'] = array(
+ '#type' => 'select',
+ '#title' => t('Drupal Core Version'),
+ '#options' => array(
+ 'd6' => t('Drupal 6'),
+ 'd7' => t('Drupal 7'),
+ ),
+ '#default_value' => 'd7',
+ );
+
+ $reviews = array(
+ 'style' => t('Drupal Coding Standards'),
+ 'comment' => t('Drupal Commenting Standards'),
+ 'sql' => t('Drupal SQL Standards'),
+ 'security' => t('Drupal Security Standards'),
+ 'i18n' => t('Internationalization'),
+ 'coder_tough_love' => t('Coder Tough Love'),
+ );
+ $form['runcoder']['reviews'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Coder Reviews to run'),
+ '#options' => $reviews,
+ '#description' => t('Represents which Coder review components to enable for this test.'),
+ '#default_value' => array('style', 'comment', 'sql', 'security', 'i18n'),
+ );
+
+ $form['runcoder']['severity'] = array(
+ '#type' => 'radios',
+ '#title' => t('Coder Severity warning level'),
+ '#options' => array(
+ 'minor (most warnings)',
+ 'normal',
+ 'critical (fewest warnings)',
+ ),
+ '#default_value' => 1,
+ '#description' => t('Represents the severity level of errors which will be considered a failed test'),
+ );
+
+ switch ($form_state['storage']['target']) {
+ case 'core':
+ // No additional parameters required for a 'core' review
+ break;
+ default:
+ $form['branchtests'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Identify Review Target'),
+ '#collapsible' => FALSE,
+ );
+
+ $desc = t('Please enter the Git repository location for the project which contains the branch to test.');
+ $desc .= ' ' . t('This may be a full project link such as git://git.drupal.org/project/drupal.git,');
+ $desc .= ' ' . t('or a sandbox project link such as git://git.drupal.org/sandbox/username/12345678.git.');
+
+ $form['branchtests']['repository'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project Repository'),
+ '#description' => $desc,
+ );
+
+ $desc = t('Please indicate the branch for which you want to run the test.');
+ $desc .= ' ' . t('This value must match an existing tag or branch within your Git repository.');
+ $desc .= ' ' . t('(Valid entries are listed under the "tags" and "heads" labels on the project repository summary page.)');
+
+ $form['branchtests']['branch'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project Branch'),
+ '#description' => $desc,
);
+ }
+
+ // Add the 'file' or 'patch' form fields as needed
+ if ($form_state['storage']['target'] == 'file') {
+
+ $desc = t('Please supply the name and path of the file (relative to the git project directory above) which you want code reviewed.');
+ $desc .= ' ' . t('(For example, if you want to review the "needsreview.inc" file in your module "includes" directory, enter "includes/needsreview.inc".)');
+
+ $form['branchtests']['filename'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Project File (Path + Name)'),
+ '#description' => $desc,
+ '#weight' => 5,
+ );
+ }
+ elseif ($form_state['storage']['target'] == 'patch') {
+ $form['branchtests']['patchfile'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload patch file'),
+ '#size' => 40,
+ );
+ $form['#attributes']['enctype'] = "multipart/form-data";
+ }
+
+
+ $form['op'] = array(
+ '#type' => 'submit',
+ '#value' => t('Run Test'),
+ );
+
+ return $form;
+}
+
+/**
+ * Validate the client coder review form
+ */
+function pifr_client_review_form_validate_coder($form, &$form_state) {
+ // At least one coder review must be checked
+ if (count($form_state['values']['reviews']) < 1) {
+ form_set_error('reviews', 'Please select at least one coder review component');
+ }
+ // Target-specific validation
+
+ if (isset($form_state['storage']['target'])) {
+ switch ($form_state['storage']['target']) {
+ case 'patch':
+ if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name']['patchfile'])) {
+ // Verify our local patches directory exists
+ $path = file_create_path("localpatches");
+ file_check_directory($path, FILE_CREATE_DIRECTORY);
+ // Attempt to save the uploaded patch file
+ $file = file_save_upload('patchfile', array('pifr_client_validate_patchname' => array($_FILES['files'])), $path, FILE_EXISTS_REPLACE);
+ // Set error if file was not uploaded
+ if (!$file) {
+ form_set_error('patchfile', 'Error uploading patch file.');
+ return;
+ }
+ // Set files to form_state for processing
+ $form_state['values']['file'] = $file;
+ }
+ default:
+ break;
}
}
- elseif ($type == 'd6') {
- // Contrib test with dependencies.
- $test = array(
- 'test_id' => 17,
- 'review' => array(
- 'plugin' => 'pifr_simpletest',
- 'argument' => array(
- 'drupal.core.version' => 6,
- ) + $default,
- ),
- 'vcs' => array(
- 'main' => array(
- 'repository' => array(
- 'type' => 'git',
- 'url' => variable_get('pifr_drupal_repository', 'git://git.drupal.org/project/drupal.git'),
- ),
- 'vcs_identifier' => '6.x',
- ),
- 'dependencies' => array(
- array(
- 'repository' => array(
- 'type' => 'git',
- 'url' => variable_get('pifr_multivariate_repository', 'git://git.drupal.org/project/multivariate.git'),
- ),
- 'vcs_identifier' => 'master', // GITMIGRATION Fragile
- ),
- array(
- 'repository' => array(
- 'type' => 'git',
- 'url' => variable_get('pifr_chart_repository', 'git://git.drupal.org/project/chart.git'),
- ),
- 'vcs_identifier' => 'master', // GITMIGRATION Fragile
- ),
+}
+
+/**
+ * Validate patch file name
+ */
+function pifr_client_validate_patchname($files) {
+ if (substr($files->filename, strlen($files->filename) - 6, 6) != '.patch') {
+ return array('Invalid extension on patch file.');
+ }
+ return array();
+}
+
+/**
+ * Submit the client coder review form
+ */
+function pifr_client_review_form_submit_coder($form, &$form_state) {
+ // Get the default arguments to be passed to client.
+ module_load_include('review.inc', 'pifr_server');
+ $plugin = pifr_server_review_plugin_load('pifr_coder');
+ $default = $plugin->argument_default_get();
+ // Generate basic coder $test array
+ $test = array(
+ 'test_id' => 17,
+ 'review' => array(
+ 'plugin' => 'pifr_coder',
+ 'argument' => $default,
+ ),
+ 'vcs' => array(
+ 'main' => array(
+ 'repository' => array(
+ 'type' => 'git',
+ 'url' => variable_get('pifr_drupal_repository', 'git://git.drupal.org/project/drupal.git'),
),
+ 'vcs_identifier' => variable_get('pifr_confirmation_vcs_id', '7.x'),
),
- 'files' => array(
- url(drupal_get_path('module', 'pifr_simpletest') . '/confirmation/pass.patch', array('absolute' => TRUE)),
- ),
- );
+ 'dependencies' => array(),
+ ),
+ 'files' => array(),
+ );
+
+ // Update vcs_identifier
+ if ($form_state['values']['version'] == 'd6') {
+ $test['vcs']['main']['vcs_identifier'] = PIFR_DRUPAL6_CURRENTBRANCH;
+ $test['review']['argument']['drupal.core.version'] = 6;
+ }
+ elseif ($form_state['values']['version'] == 'd7') {
+ $test['vcs']['main']['vcs_identifier'] = PIFR_DRUPAL7_CURRENTBRANCH;
+ $test['review']['argument']['drupal.core.version'] = 7;
+ }
+ // Update with user-specific values
+ switch ($form_state['storage']['target']) {
+ case 'branch':
+ // Update the 'vcs' section with the project to be reviewed.
+ // No need to clone a full drupal install for code review!
+ $test['vcs']['main']['repository']['url'] = check_plain($form_state['values']['repository']);
+ $test['vcs']['main']['vcs_identifier'] = check_plain($form_state['values']['branch']);
+ break;
+ case 'file':
+ // Update the 'vcs' section with the project to be reviewed.
+ // No need to clone a full drupal install for code review!
+ $test['vcs']['main']['repository']['url'] = check_plain($form_state['values']['repository']);
+ $test['vcs']['main']['vcs_identifier'] = check_plain($form_state['values']['branch']);
+ $test['review']['argument']['test.files'][] = check_plain($form_state['values']['filename']);
+ break;
+ case 'patch':
+ $test['vcs']['main']['repository']['url'] = check_plain($form_state['values']['repository']);
+ $test['vcs']['main']['vcs_identifier'] = check_plain($form_state['values']['branch']);
+ // We stored the file in /localpatches in the files directory
+ $test['files'][] = file_create_url(file_create_path('localpatches') . '/' . $form_state['values']['file']->filename);
+ break;
+ default:
+ break;
+ }
+
+ // Update coder.reviews
+ $test['review']['argument']['coder.reviews'] = $form_state['values']['reviews'];
+
+ // Update coder.severity
+ switch ($form_state['values']['severity']) {
+ case 0:
+ $test['review']['argument']['coder.severity'] = SEVERITY_MINOR;
+ break;
+ case 1:
+ $test['review']['argument']['coder.severity'] = SEVERITY_NORMAL;
+ break;
+ case 2:
+ $test['review']['argument']['coder.severity'] = SEVERITY_CRITICAL;
+ break;
+ }
+
+ variable_set('pifr_client_test', $test);
+
+ if ($review = pifr_client_review_load($test)) {
+ variable_set('pifr_client_test_start', time());
+ $review->run();
+
+ // Display test information.
+ drupal_set_message('Test: ' . pifr_client_review_export($test));
+ drupal_set_message('Results: ' . pifr_client_review_export($review->get_result()));
+
+ variable_del('pifr_client_test');
+ variable_del('pifr_client_test_start');
}
- return $test;
+
}
/**
diff --git a/client/review/db/mysql.inc b/client/review/db/mysql.inc
index 9cc0bb1..5375fce 100644
--- a/client/review/db/mysql.inc
+++ b/client/review/db/mysql.inc
@@ -44,8 +44,10 @@ class pifr_client_db_interface_mysql implements pifr_client_db_interface {
return FALSE;
}
$rows = array();
- while ($row = db_fetch_array($result)) {
- $rows[] = $row;
+ if (!($result === TRUE)) {
+ while ($row = db_fetch_array($result)) {
+ $rows[] = $row;
+ }
}
db_set_active();
return $rows;
diff --git a/client/review/db/pgsql.inc b/client/review/db/pgsql.inc
index 7be00ab..982ad76 100644
--- a/client/review/db/pgsql.inc
+++ b/client/review/db/pgsql.inc
@@ -40,8 +40,10 @@ class pifr_client_db_interface_pgsql implements pifr_client_db_interface {
if (db_set_active('pifr_checkout')) {
$result = @db_query($sql);
$rows = array();
- while ($row = db_fetch_array($result)) {
- $rows[] = $row;
+ if (!($result === TRUE)) {
+ while ($row = db_fetch_array($result)) {
+ $rows[] = $row;
+ }
}
db_set_active();
return $rows;
diff --git a/client/review/vcs/git.inc b/client/review/vcs/git.inc
index 167f2e2..dba74a7 100644
--- a/client/review/vcs/git.inc
+++ b/client/review/vcs/git.inc
@@ -119,8 +119,8 @@ class pifr_client_vcs_git extends pifr_client_vcs {
*/
public function apply($patch, $patch_level = 1, $check_only = FALSE) {
$test_result = pifr_client_review::exec("git apply --check -p$patch_level $patch", TRUE);
- if (!check_only) {
- return (!$test_result != 0);
+ if ($check_only) {
+ return ($test_result == 0);
}
if ($test_result) {
$this->patch_level = $patch_level;
diff --git a/review/client.inc b/review/client.inc
index 417da4e..515c3a0 100644
--- a/review/client.inc
+++ b/review/client.inc
@@ -151,8 +151,9 @@ abstract class pifr_client_review {
require_once drupal_get_path('module', 'pifr_server') . '/pifr_server.review.inc';
$plugin = pifr_server_review_plugin_load($test['review']['plugin']);
$plugin->init();
-
- $this->operations = array_splice($plugin->operation_get_all(), 0, -2);
+
+ $pluginops = $plugin->operation_get_all();
+ $this->operations = array_splice($pluginops, 0, -2);
$this->result_codes = array(
'fail' => count($this->operations) + 1,
'pass' => count($this->operations) + 2,
diff --git a/review/coder/confirmation/fail.patch b/review/coder/confirmation/fail.patch
index 3e87073..80f1e54 100644
--- a/review/coder/confirmation/fail.patch
+++ b/review/coder/confirmation/fail.patch
@@ -1,3 +1,13 @@
+From 856c1d5aaeeb21504e96b90ae3dda35c6464499d Mon Sep 17 00:00:00 2001
+From: Jeremy Thorson
+Date: Fri, 1 Jul 2011 14:52:42 -0500
+Subject: [PATCH] New Coder Fail.Patch Confirmation file
+
+---
+ coder.php | 10 ++++++++++
+ 1 files changed, 10 insertions(+), 0 deletions(-)
+ create mode 100644 coder.php
+
diff --git a/coder.php b/coder.php
new file mode 100644
index 0000000..9e7e776
diff --git a/review/coder/confirmation/pass.patch b/review/coder/confirmation/pass.patch
index ac020af..126799c 100644
--- a/review/coder/confirmation/pass.patch
+++ b/review/coder/confirmation/pass.patch
@@ -1,3 +1,13 @@
+From 65d3bf5cec9ca2f7f2388049b1824cc639664fbb Mon Sep 17 00:00:00 2001
+From: Jeremy Thorson
+Date: Fri, 1 Jul 2011 14:44:19 -0500
+Subject: [PATCH] New Coder Confirmation Pass File.
+
+---
+ coder.php | 5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+ create mode 100644 coder.php
+
diff --git a/coder.php b/coder.php
new file mode 100644
index 0000000..07b27be
diff --git a/review/coder/pifr_coder.client.inc b/review/coder/pifr_coder.client.inc
index 2961f64..f7f348f 100644
--- a/review/coder/pifr_coder.client.inc
+++ b/review/coder/pifr_coder.client.inc
@@ -48,7 +48,7 @@ class pifr_client_review_pifr_coder extends pifr_client_review_pifr_drupal {
// Get the review information for the selected reviews.
$reviews = _coder_reviews();
foreach ($reviews as $key => $review) {
- if (!in_array($key, $this->arguments['coder.reviews'])) {
+ if (!in_array($key, $this->arguments['coder.reviews'], TRUE)) {
unset($reviews[$key]);
}
}
@@ -64,6 +64,11 @@ class pifr_client_review_pifr_coder extends pifr_client_review_pifr_drupal {
'#include_extensions' => _coder_get_reviews_extensions($php_extensions, $reviews),
);
+ // Update the Coder severity level if desired
+ if (!empty($this->arguments['coder.severity'])) {
+ $args['#severity'] = $this->arguments['coder.severity'];
+ }
+
// Cycle through all relevant files and perform review.
$files = $this->syntax_ignore($this->file_list());
diff --git a/review/drupal/pifr_drupal.client.inc b/review/drupal/pifr_drupal.client.inc
index cf82163..3633b56 100644
--- a/review/drupal/pifr_drupal.client.inc
+++ b/review/drupal/pifr_drupal.client.inc
@@ -47,59 +47,64 @@ class pifr_client_review_pifr_drupal extends pifr_client_review {
pifr_debug('Test(%test_id) request received: %test
', array('%test_id' => $this->test['test_id'], '%test' => print_r($test, TRUE)));
$this->log('core_url = [' . $this->core_url . ']; Test repository = [' . $this->test['vcs']['main']['repository']['url'] . ']');
- if ($this->test['vcs']['main']['repository']['url'] != $this->core_url) {
- // Main repository is not core, so this must be a module test. Move the
- // module repository (main) to the dependencies and find the core
- // repository in the dependencies and move it to main.
- $this->test['vcs']['dependencies'][] = $this->test['vcs']['main'];
-
- // Store the project name 'simpletest' for use when applying patches.
- $this->project_directory = basename($this->test['vcs']['main']['repository']['url']);
- $this->project_directory = preg_replace('/\.git$/', '', $this->project_directory);
- $this->log('Project directory is [' . $this->project_directory . ']');
-
-
- foreach ($this->test['vcs']['dependencies'] as $key => $dependency) {
- if ($dependency['repository']['url'] == $this->arguments['drupal.core.url']) {
- $this->test['vcs']['main'] = $dependency;
- unset($this->test['vcs']['dependencies'][$key]);
- break;
+
+
+
+ if ($this->test['review']['plugin'] == 'pifr_simpletest') {
+ if ($this->test['vcs']['main']['repository']['url'] != $this->core_url) {
+ // Main repository is not core, so this must be a module test. Move the
+ // module repository (main) to the dependencies and find the core
+ // repository in the dependencies and move it to main.
+ $this->test['vcs']['dependencies'][] = $this->test['vcs']['main'];
+
+ // Store the project name 'simpletest' for use when applying patches.
+ $this->project_directory = basename($this->test['vcs']['main']['repository']['url']);
+ $this->project_directory = preg_replace('/\.git$/', '', $this->project_directory);
+ $this->log('Project directory is [' . $this->project_directory . ']');
+
+
+ foreach ($this->test['vcs']['dependencies'] as $key => $dependency) {
+ if ($dependency['repository']['url'] == $this->arguments['drupal.core.url']) {
+ $this->test['vcs']['main'] = $dependency;
+ unset($this->test['vcs']['dependencies'][$key]);
+ break;
+ }
}
}
- }
- // Add SimpleTest as dependencies, unless it has already been added.
- if ($this->test['review']['argument']['drupal.core.version'] == 6) {
- $simpletest_url = variable_get('pifr_simpletest_repository', 'git://git.drupal.org/project/simpletest.git');
- $found = FALSE;
- foreach ($this->test['vcs']['dependencies'] as $key => $dependency) {
- if ($dependency['repository']['url'] == $simpletest_url) {
- $found = TRUE;
- break;
+ // Add SimpleTest as dependencies, unless it has already been added.
+ if ($this->test['review']['argument']['drupal.core.version'] == 6) {
+ $simpletest_url = variable_get('pifr_simpletest_repository', 'git://git.drupal.org/project/simpletest.git');
+ $found = FALSE;
+ foreach ($this->test['vcs']['dependencies'] as $key => $dependency) {
+ if ($dependency['repository']['url'] == $simpletest_url) {
+ $found = TRUE;
+ break;
+ }
+ }
+
+ if (!$found) {
+ // Since SimpleTest is not included in Drupal 6 it needs to be checked
+ // out from contrib.
+ $this->test['vcs']['dependencies'][] = array(
+ 'repository' => array(
+ 'type' => 'git',
+ 'url' => $simpletest_url,
+ ),
+ 'vcs_identifier' => '6.x-2.x',
+ );
}
}
-
- if (!$found) {
- // Since SimpleTest is not included in Drupal 6 it needs to be checked
- // out from contrib.
- $this->test['vcs']['dependencies'][] = array(
- 'repository' => array(
- 'type' => 'git',
- 'url' => $simpletest_url,
- ),
- 'vcs_identifier' => '6.x-2.x',
- );
+
+ // Set the dependency directory.
+ $this->arguments['test.directory.dependency'] = $this->module_directory;
+
+ // If the main project is not Drupal core then all patches should be
+ // applied from the root of the primary dependency or project directory.
+ if (!empty($this->project_directory)) {
+ $this->arguments['test.directory.apply'] = $this->module_directory . '/' . $this->project_directory;
}
}
-
- // Set the dependency directory.
- $this->arguments['test.directory.dependency'] = $this->module_directory;
-
- // If the main project is not Drupal core then all patches should be
- // applied from the root of the primary dependency or project directory.
- if (!empty($this->project_directory)) {
- $this->arguments['test.directory.apply'] = $this->module_directory . '/' . $this->project_directory;
- }
}
diff --git a/review/simpletest/pifr_simpletest.client.inc b/review/simpletest/pifr_simpletest.client.inc
index 4e0d4af..e756085 100644
--- a/review/simpletest/pifr_simpletest.client.inc
+++ b/review/simpletest/pifr_simpletest.client.inc
@@ -126,6 +126,11 @@ class pifr_client_review_pifr_simpletest extends pifr_client_review_pifr_drupal
// @TODO: Temporary until #22336 is committed.
$run_tests = file_exists('scripts/run-tests.sh') ? 'scripts/run-tests.sh' : 'core/scripts/run-tests.sh';
$url = escapeshellarg(url('', array('absolute' => TRUE)) . 'checkout');
+ // Attempt to clear out any tables from previous runs
+ if (!$this->exec(PIFR_CLIENT_PHP . ' ./' . $run_tests . ' --php ' . PIFR_CLIENT_PHP . ' --clean')) {
+ $this->set_error(array('@reason' => t('failed during invocation of run-tests.sh --clean')));
+ return;
+ }
if (!$this->exec(PIFR_CLIENT_PHP . ' ./' . $run_tests . ' --concurrency ' . PIFR_CLIENT_CONCURRENCY .
' --php ' . PIFR_CLIENT_PHP . ' --url ' . $url . ' ' . $test_list)) {
$this->set_error(array('@reason' => t('failed during invocation of run-tests.sh')));
@@ -291,6 +296,9 @@ class pifr_client_review_pifr_simpletest extends pifr_client_review_pifr_drupal
* @return array Associative array of test info keyed by test case.
*/
protected function test_info_parse() {
+ if (!is_array($this->output)) {
+ $this->output = explode("\n", $this->output);
+ }
$this->output = array_slice($this->output, 4);
$group = 'Unknown';
$info = array();