Index: /var/www/testing_reporter/sites/all/modules/simpletestauto/enable_module.inc
===================================================================
--- /var/www/testing_reporter/sites/all/modules/simpletestauto/enable_module.inc (revision 20)
+++ /var/www/testing_reporter/sites/all/modules/simpletestauto/enable_module.inc (working copy)
@@ -4,6 +4,32 @@
require_once($scriptdir.'/simpletest/web_tester.php');
require_once($scriptdir.'/simpletest/reporter.php');
+class TestDrupal7Enable extends WebTestCase {
+
+ function setUp() {}
+
+ function testD7Install() {
+ global $args;
+ $gotopath = $args->install_url . $args->instance . '/index.php?q=admin/build/modules';
+ $this->assertTrue($this->get($gotopath));
+ $this->assertFieldByName('name');
+ $this->assertFieldByName('pass');
+ $this->setFieldByName('name', 'admin');
+ $this->setFieldByName('pass', 'testPWD');
+ $this->clickSubmitByName('op');
+ $this->assertResponse(200);
+
+
+ #---------------------------#
+
+ $this->assertFieldById('edit-status-' . $args->module);
+ $this->setFieldById('edit-status-' . $args->module, TRUE);
+ $this->clickSubmitByName('op');
+ $this->assertResponse(200);
+
+ }
+}
+
class TestDrupal6Enable extends WebTestCase {
function setUp() {}
@@ -63,7 +89,6 @@
function testD5Install() {
global $args;
$gotopath = $args->install_url . $args->instance . '/index.php?q=admin/modules';
- print_r($gotopath);
$this->assertTrue($this->get($gotopath));
$this->assertFieldById('edit-name');
$this->assertFieldById('edit-pass');
@@ -93,6 +118,16 @@
$args->install_dir = $simpletest_install_dir;
$args->module = $module;
switch ($version) {
+ case '7':
+ $test = &new TestDrupal7Enable();
+ $reporter = &new InstallReporter();
+ $test->run($reporter);
+ $fails = $result[1];
+ if ($fails > 0) {
+ terminateTesting(STA_FAIL, $result[0]);
+ return FALSE;
+ }
+ break;
case '6':
$test = &new TestDrupal6Enable();
$reporter = &new InstallReporter();
@@ -103,7 +138,7 @@
return FALSE;
}
break;
- case '5':
+ case '5':
$test = &new TestDrupal5Enable();
$reporter = &new InstallReporter();
$test->run($reporter);
@@ -125,6 +160,9 @@
return FALSE;
}
break;
+ default :
+ terminateTesting(STA_FAIL, t("Install case for this version not accounted for in enable_module.inc"));
+ break;
}
return TRUE;
}
\ No newline at end of file
Index: /var/www/testing_reporter/sites/all/modules/simpletestauto/install_drupal.inc
===================================================================
--- /var/www/testing_reporter/sites/all/modules/simpletestauto/install_drupal.inc (revision 20)
+++ /var/www/testing_reporter/sites/all/modules/simpletestauto/install_drupal.inc (working copy)
@@ -4,6 +4,72 @@
require_once($scriptdir.'/simpletest/web_tester.php');
require_once($scriptdir.'/simpletest/reporter.php');
+class TestDrupal7Install extends WebTestCase {
+
+ function setUp() {}
+
+ function testD7Install() {
+ global $args;
+ $gotopath = $args->install_url . $args->instance . '/install.php';
+ $this->assertTrue($this->get($gotopath));
+ $this->assertResponse(200);
+ $this->assertLink('Install Drupal in English');
+ $this->click('Install Drupal in English');
+
+ #----------------------------#
+
+ $this->assertFieldById('edit-db-user');
+ $this->assertFieldById('edit-db-path');
+ $this->assertFieldById('edit-db-pass');
+ $this->setFieldById('edit-db-path', $args->instance);
+ $this->setFieldById('edit-db-user', $args->db_user);
+ $this->setFieldById('edit-db-pass', $args->db_pass);
+ $this->clickSubmitById('edit-save');
+
+ #---------------------------#
+
+ $this->assertResponse(200);
+ $this->assertTitle(new PatternExpectation('/Installing Drupal/'));
+ $i = 0;
+ do {
+ $gotopath = $args->install_url . $args->instance . '/install.php?locale=en&profile=default&id=1&op=do_nojs';
+ $this->assertTrue($this->get($gotopath));
+ $this->assertResponse(200);
+ $res = strpos($this->_browser->getContent(), 'Remaining 0 of 10');
+ $i++;
+ } while ($res === FALSE && $i < 5);
+
+ $gotopath = $args->install_url . $args->instance . '/install.php?locale=en&profile=default&id=1&op=finished';
+ $this->assertTrue($this->get($gotopath));
+ $this->assertResponse(200);
+ $this->assertFieldByName('site_name');
+ $this->assertFieldByName('site_mail');
+ $this->assertFieldByName('account[name]');
+ $this->assertFieldByName('account[mail]');
+ $this->assertFieldByName('account[pass][pass1]');
+ $this->assertFieldByName('account[pass][pass2]');
+ $this->setFieldByName('site_name', $args->instance);
+ $this->setFieldByName('site_mail', $args->instance . '@testing.drupal.org');
+ $this->setFieldByName('account[name]', 'admin');
+ $this->setFieldByName('account[mail]', 'admin@testing.drupal.org');
+ $this->setFieldByName('account[pass][pass1]', 'testPWD');
+ $this->setFieldByName('account[pass][pass2]', 'testPWD');
+ $this->clickSubmitByName('op');
+
+ #--------------------------#
+
+ $this->assertText('Drupal installation complete');
+ $this->assertLink('your new site');
+ $this->click('your new site');
+
+ #--------------------------#
+
+ $this->assertResponse(200);
+ $this->assertTitle($args->instance);
+ $this->assertText('Welcome');
+ }
+}
+
class TestDrupal6Install extends WebTestCase {
function setUp() {}
@@ -106,7 +172,7 @@
}
function installDrupal47() {
- global $args, $bins;
+ global $args;
$instance_dir = $args->install_dir . '/' . $args->instance;
$exec_cmd = $bins['sed'] . ' -i "s/' .
@@ -138,7 +204,19 @@
$args->install_url = $simpletest_install_dir_url;
$args->install_dir = $simpletest_install_dir;
switch ($version) {
- case '6':
+ case '7':
+ chmod($simpletest_install_dir . '/' . $instance . '/sites/default', 0777);
+ $test = &new TestDrupal7Install();
+ $reporter = &new InstallReporter();
+ $test->run($reporter);
+ $result = $reporter->getOutput();
+ $fails = $result[1];
+ if ($fails > 0) {
+ terminateTesting(STA_FAIL, $result[0]);
+ return FALSE;
+ }
+ break;
+ case '6':
chmod($simpletest_install_dir . '/' . $instance . '/sites/default', 0777);
$test = &new TestDrupal6Install();
$reporter = &new InstallReporter();
@@ -144,7 +222,6 @@
$reporter = &new InstallReporter();
$test->run($reporter);
$result = $reporter->getOutput();
- print_r($result);
$fails = $result[1];
if ($fails > 0) {
terminateTesting(STA_FAIL, $result[0]);
@@ -169,6 +246,9 @@
return FALSE;
}
break;
+ default :
+ terminateTesting(STA_FAIL, t("Install case for this version not accounted for in install_drupal.inc"));
+ break;
}
if ($version == '5' || $version == '4.7') {
//we need to manually insert admin user and some additional data
Index: /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto.inc
===================================================================
--- /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto.inc (revision 20)
+++ /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto.inc (working copy)
@@ -14,7 +14,8 @@
$node->patch_url = file_create_url($file->filepath);
}
$etc = serialize($node->etc);
- db_query("INSERT INTO {simpletestauto_test} (nid, project, patch_url, version, test_status, file_path, file_mime, file_size, issue_id, submitter, etc) VALUES (%d, '%s', '%s', '%s', '%d', '%s', '%s', '%d', '%d', '%s', '%s')", $node->nid, $node->project, $node->patch_url,$node->version, $node->test_status, $file->filepath, $file->filemime, $file->filesize, $node->issue_id, $node->submitter, $etc);
+ db_query("INSERT INTO {simpletestauto_test} (nid, project, patch_url, version, test_status, file_path, file_mime, file_size, issue_id, submitter, etc, daily_run) VALUES (%d, '%s', '%s', '%s', '%d', '%s', '%s', '%d', '%d', '%s', '%s',%d)", $node->nid, $node->project, $node->patch_url,$node->version, $node->test_status, $file->filepath, $file->filemime, $file->filesize, $node->issue_id, $node->submitter, $etc, $node->daily_run);
+ send_test_request($node);
}
function simpletestauto_test_update($node) {
@@ -19,8 +20,8 @@
function simpletestauto_test_update($node) {
$etc = serialize($node->etc);
- db_query("UPDATE {simpletestauto_test} SET project = '%s', patch_url = '%s', version = '%s', test_status = '%d', site_url = '%s', etc = '%s' WHERE nid = %d", $node->project, $node->patch_url, $node->version, $node->test_status, $node->site_url, $etc, $node->nid);
-}
+ db_query("UPDATE {simpletestauto_test} SET project = '%s', patch_url = '%s', version = '%s', test_status = '%d', site_url = '%s', etc = '%s', test_xml = '%s' WHERE nid = %d", $node->project, $node->patch_url, $node->version, $node->test_status, $node->site_url, $etc, $node->test_xml, $node->nid);
+ }
function simpletestauto_test_load($node) {
$test = db_fetch_object(db_query('SELECT * FROM {simpletestauto_test} WHERE nid = %d', $node->nid));
@@ -29,6 +30,7 @@
}
function simpletestauto_test_delete($node) {
+ //TODO modify delete so it also deletes instance and database sample code in simpletes.module
db_query('DELETE FROM {simpletestauto_test} WHERE nid = %d', $node->nid);
}
@@ -74,13 +76,21 @@
'DRUPAL-5-1' => 'Drupal 5.1',
);
$form['version'] = array(
- '#type' => 'textfield',
+ '#type' => 'select',
'#title' => t('Version'),
- '#default_value' => (isset($node->version) ? $node->version : 'HEAD') ,
+ '#default_value' => (isset($node->version) ? $node->version : 'HEAD'),
+ '#options' => simpletestauto_get_releases(),
'#required' => TRUE,
'#disabled' => $disabled,
);
-
+ $form['daily_run'] = array(
+ '#type' => 'radios',
+ '#required' => true,
+ '#title' => t('Daily Run'),
+ '#description' => t('A daily run test instance performs a complete battery of tests against a cvs checkout of Drupal. Patch URL/File Attachment is not necessary if it is a daily run.'),
+ '#default_value' => (isset($node->daily_run) ? $node->daily_run : 0),
+ '#options' => array(0 => t('No'),1 => t('Yes')),
+ );
$form['patch_url'] = array(
'#type' => 'textfield',
'#title' => t('Patch URL'),
@@ -102,13 +112,15 @@
function simpletestauto_test_node_form_validate($form_id, $form) {
global $form_values;
- $edit = $_POST['edit'];
- $file = file_check_upload('patch_file');
- if ($form_values['patch_url'] == "" && $file == NULL) {
- form_set_error('patch_url', t('Please provide a patch url or upload a new file.'));
+ if($form['daily_run'] != 1) {
+ $edit = $_POST['edit'];
+ $file = file_check_upload('patch_file');
+ if ($form_values['patch_url'] == "" && $file == NULL) {
+ form_set_error('patch_url', t('Please provide a patch url or upload a new file.'));
+ }
+ $form_values['file'] = file_save_upload($file);
}
- $form_values['file'] = file_save_upload($file);
-}
+ }
/**
* Implementation of hook_content().
@@ -120,6 +132,9 @@
function simpletestauto_test_view(&$node, $teaser = false, $page = false) {
+ require_once(drupal_get_path('module', 'simpletest').'/simpletest/reporter.php');
+ require_once(drupal_get_path('module', 'simpletest').'/drupal_reporter.php');
+
$node = node_prepare($node, $teaser);
if (!$teaser && $page) {
@@ -129,7 +144,7 @@
$rows[] = array('Version: ', check_plain($node->version));
$rows[] = array(t('Patch url: '), l($node->patch_url, $node->patch_url));
$issue_url = "http://drupal.org/node/" . $node->issue_id;
- $rows[] = array(t('Drupal.org issue: '), l($issue_url, $issue_url));
+ $rows[] = array(t('Type: '), (!$node->patch_url ? t('Full Version Testing') : t('d.o. issue ').l($issue_url, $issue_url)));
$rows[] = array(t('Patch by: '), $node->submitter);
if ($node->site_url) {
$rows[] = array(t('Test site: '), l($node->site_url, $node->site_url));
@@ -157,6 +172,28 @@
$result_class = 'simpletestauto_error';
break;
}
+ if(strlen($node->test_xml) > 1) {
+ if(strstr($node->test_xml, 'Fatal error') !== FALSE) {
+ $status = t('INTERNAL ERROR');
+ $result_class = 'simpletestauto_error';
+ $node->content['parsed_results'] = array(
+ '#value' => '
'.htmlspecialchars($node->test_xml).'
',
+ '#weight' => 10,
+ );
+ } else {
+ $parser = &new SimpleTestXmlParser(new DrupalReporter());
+ $parser->parse($node->test_xml);
+ $parsed = $parser->_listener->getOutput();
+ $node->content['parsed_results'] = array(
+ '#value' => $parser->_listener->getOutput(),
+ '#weight' => 10,
+ );
+ }
+ $node->content['last_run'] = array(
+ '#value' => t("Last Test Results:"),
+ '#weight' => 5,
+ );
+ }
$rows[] = array(t('Status: '), array('data' => $status, 'class' => $result_class));
$node->content['test_summary'] = array(
'#value' => '' . theme('table', array(), $rows) . '
',
@@ -184,4 +221,100 @@
}
}
}
+/**
+ * Generates an array of CVS Tags taken from http://cvs.drupal.org/viewvc.py/drupal/
+ *
+ * @return array
+ */
+function simpletestauto_get_releases() {
+ $drupal_releases = array(
+ 'HEAD' => 'HEAD',
+ 'DRUPAL-6-2' => 'DRUPAL-6-2',
+ 'DRUPAL-6-1' => 'DRUPAL-6-1',
+ 'DRUPAL-6-0-RC4' => 'DRUPAL-6-0-RC-4',
+ 'DRUPAL-6-0-RC3' => 'DRUPAL-6-0-RC-3',
+ 'DRUPAL-6-0-RC2' => 'DRUPAL-6-0-RC-2',
+ 'DRUPAL-6-0-RC1' => 'DRUPAL-6-0-RC-1',
+ 'DRUPAL-6-0' => 'DRUPAL-6-0',
+ 'DRUAPL-6' => 'DRUPAL-6',
+ 'DRU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
+ 'DRUPAL-4-5' => 'DRUPAL-4-5',
+ 'DRUPAL-4-4-3' => 'DRUPAL-4-4-3',
+ 'DRUPAL-4-4-2' => 'DRUPAL-4-4-2',
+ 'DRUPAL-4-4-1' => 'DRUPAL-4-4-1',
+ 'DRUPAL-4-4-0' => 'DRUPAL-4-4-0',
+ 'DRUPAL-4-4' => 'DRUPAL-4-4',
+ 'DRUPAL-4-3-2' => 'DRUPAL-4-3-2',
+ 'DRUPAL-4-3-1' => 'DRUPAL-4-3-1',
+ 'DRUPAL-4-3-0' => 'DRUPAL-4-3-0',
+ 'DRUPAL-4-3' => 'DRUPAL-4-3',
+ 'DRUPAL-4-2-0' => 'DRUPAL-4-2-0',
+ 'DRUPAL-4-2' => 'DRUPAL-4-2',
+ 'DRUPAL-4-2' => 'DRUPAL-4-2',
+ 'DRUPAL-4-1-0' => 'DRUPAL-4-1-0',
+ 'DRUPAL-4-1' => 'DRUPAL-4-1',
+ 'DRUPAL-4-0-0' => 'DRUPAL-4-0-0',
+ 'DRUPAL-4-0' => 'DRUPAL-4-0',
+ 'DRUPAL-3-0-0' => 'DRUPAL-3-0-0',
+ 'DRUPAL-3-0' => 'DRUPAL-3-0'
+ );
+ return $drupal_releases;
+}
?>
Index: /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto.install
===================================================================
--- /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto.install (revision 20)
+++ /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto.install (working copy)
@@ -57,4 +57,16 @@
return $items;
}
+function simpletestauto_update_3() {
+ $items = array();
+ $items[] = update_sql("ALTER TABLE {simpletestauto_test} ADD daily_run int NOT NULL default '0'");
+ $items[] = db_query("CREATE TABLE {simpletestauto_report} (
+ nid int(10) unsigned NOT NULL default '0',
+ test_xml longtext NULL default '',
+ created int(11) NOT NULL default '0',
+ PRIMARY KEY (`nid`,`created`)
+ ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
+ return $items;
+}
+
?>
Index: /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto.module
===================================================================
--- /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto.module (revision 20)
+++ /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto.module (working copy)
@@ -19,7 +19,7 @@
define('SIMPLETESTAUTO_FAIL', 4);
define('SIMPLETESTAUTO_SUBMITED', 5);
define('SIMPLETESTAUTO_ERROR', 6);
-
+
/**
* Display help and module information
@@ -48,7 +48,23 @@
function simpletestauto_perm() {
return array('Access test automation', 'Administer test automation', 'create simpletestauto_test', 'edit own simpletestauto_test');
}
-
+function simpletest_auto_pift_test() {
+ $pift = array(
+ 'ftid' => '123',
+ 'pid' => '123',
+ 'rid' => '123',
+ 'uid' => '157412',
+ 'issue_id' => '248990',
+ 'issue_title' => 'Does automated testing work?',
+ 'project' => 'Drupal',
+ 'version' => '7.x-dev',
+ 'submitter' => 'cwgordon7',
+ 'patch_url' => 'http://drupal.org/files/issues/break_drupal_01.patch',
+ 'project_server' => 'http://testing_reporter',
+ );
+ simpletestauto_newPatch($pift);
+ return 'processing complete';
+ }
/**
* implementation of menu hook
*/
@@ -53,7 +69,15 @@
* implementation of menu hook
*/
function simpletestauto_menu($may_cache) {
+
$items[] = array(
+ 'path' => 'simpletest_auto/pift',
+ 'title' => 'Simpletestauto pift test',
+ 'callback' => 'simpletest_auto_pift_test',
+ 'access' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
+ $items[] = array(
'path' => 'admin/settings/simpletestauto',
'title' => t('Simpletestauto Settings'),
'description' => t('Simpletestauto settings page. Test server information, somet test settings, ...'),
@@ -92,7 +116,15 @@
*/
function simpletestauto_admin_settings() {
global $base_url;
- $form['simpletestauto_server_pwd'] = array(
+ $form['xmlrpc_settings'] = array(
+ '#title' => t('XML-RPC Server Settings'),
+ '#type' => 'fieldset',
+ '#description' => t("XML-RPC server specific settings"),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+
+ );
+ $form['xmlrpc_settings']['simpletestauto_server_pwd'] = array(
'#type' => 'password_confirm',
'#title' => t('Automatic testing server password'),
'#default_value' => variable_get('simpletestauto_server_pwd', ''),
@@ -100,7 +132,7 @@
'#description' => t('Testing server password.'),
);
- $form['simpletestauto_server_url'] = array(
+ $form['xmlrpc_settings']['simpletestauto_server_url'] = array(
'#type' => 'textfield',
'#title' => t('Automatic testing server url'),
'#default_value' => variable_get('simpletestauto_server_url', $base_url.'/xmlrpc.php'),
@@ -108,7 +140,142 @@
'#maxlength' => 255,
'#description' => t('Url of the server that will handle request for automatic patch testing.'),
);
-
+
+ $form['server_settings'] = array(
+ '#title' => t('Server Settings'),
+ '#type' => 'fieldset',
+ '#description' => t("Server specific settings"),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+
+ );
+ $form['server_settings']['simpletest_install_dir'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Staging Directory'),
+ '#default_value' => variable_get('simpletest_install_dir', '/var/www/testing_stage'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('A directory on the server that will be used to store test instances.'),
+ );
+ $form['server_settings']['simpletest_install_dir_url'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Staging Directory'),
+ '#default_value' => variable_get('simpletest_install_dir_url', 'http://testing_stage/'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('Url of install dir. With trailing slash.'),
+ );
+ $form['server_settings']['simpletest_http_host'] = array(
+ '#type' => 'textfield',
+ '#title' => t('HTTP Host'),
+ '#default_value' => variable_get('simpletest_http_host', $_SERVER['HTTP_HOST']),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('For multi-site installations'),
+ );
+ $form['server_settings']['simpletest_debug'] = array(
+ '#type' => 'radios',
+ '#title' => t('Debug'),
+ '#description' => t('set this to true if you want to see long debug messages if sth is not working correctly.'),
+ '#default_value' => variable_get('simpletest_debug', 0),
+ '#options' => array(0 => t('No'),1 => t('Yes')),
+ );
+ $form['server_bins'] = array(
+ '#title' => t('Server Binaries'),
+ '#type' => 'fieldset',
+ '#description' => t("Server binaries"),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+
+ );
+ $form['server_bins']['simpletest_bins_cvs'] = array(
+ '#type' => 'textfield',
+ '#title' => t('CVS'),
+ '#default_value' => variable_get('simpletest_bins_cvs', '/usr/bin/cvs'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('Path to CVS executable.'),
+ );
+ $form['server_bins']['simpletest_bins_mysql'] = array(
+ '#type' => 'textfield',
+ '#title' => t('MySQL'),
+ '#default_value' => variable_get('simpletest_bins_mysql', '/usr/bin/mysql'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('Path to MySQL executable.'),
+ );
+ $form['server_bins']['simpletest_bins_mysqladmin'] = array(
+ '#type' => 'textfield',
+ '#title' => t('MySQL Aministrator'),
+ '#default_value' => variable_get('simpletest_bins_mysqladmin', '/usr/bin/mysqladmin'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('Path to MySQL Administrator executable.'),
+ );
+ $form['server_bins']['simpletest_bins_patch'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Patch'),
+ '#default_value' => variable_get('simpletest_bins_mysqladmin', '/usr/bin/patch'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('Path to patch executable.'),
+ );
+ $form['server_bins']['simpletest_bins_phpexec'] = array(
+ '#type' => 'textfield',
+ '#title' => t('phpExec'),
+ '#default_value' => variable_get('simpletest_bins_phpexec', '/usr/bin/php'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('Path to php executable.'),
+ );
+ $form['server_bins']['simpletest_bins_phpnoexec'] = array(
+ '#type' => 'textfield',
+ '#title' => t('phpNoExec'),
+ '#default_value' => variable_get('simpletest_bins_phpnoexec', '/usr/bin/php'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('Path to executable.'),
+ );
+ $form['server_bins']['simpletest_bins_wget'] = array(
+ '#type' => 'textfield',
+ '#title' => t('wget'),
+ '#default_value' => variable_get('simpletest_bins_wget', '/usr/bin/wget'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('Path to executable.'),
+ );
+ $form['server_bins']['simpletest_bins_cp'] = array(
+ '#type' => 'textfield',
+ '#title' => t('copy'),
+ '#default_value' => variable_get('simpletest_bins_cp', '/usr/bin/cp'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('Path to executable.'),
+ );
+ $form['db_info'] = array(
+ '#title' => t('Test Database'),
+ '#type' => 'fieldset',
+ '#description' => t("Test database information"),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+
+ );
+ $form['db_info']['simpletest_db_user'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Test database user'),
+ '#default_value' => variable_get('simpletest_db_user', 'db_user'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('Test database user.'),
+ );
+ $form['db_info']['simpletest_db_pass'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Test Database Password'),
+ '#default_value' => variable_get('simpletest_db_pass', 'db_pass'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#description' => t('Test database password.'),
+ );
return system_settings_form($form);
}
@@ -194,7 +361,7 @@
* @param $status 0 means test passed, 1 means it failed.
* @param $site_url Url of the new site that was created when patch was tested.
*/
-function simpletestauto_writeResult($password, $nid, $result, $status, $site_url) {
+function simpletestauto_writeResult($password, $nid, $result, $status, $site_url, $test_xml) {
if ( $password == sha1(variable_get('simpletestauto_server_pwd', ''))) {
$node = node_load($nid);
if (!$node) {
@@ -216,6 +383,7 @@
$node->test_status = SIMPLETESTAUTO_ERROR;
}
$node->site_url = $site_url;
+ $node->test_xml = $test_xml;
node_save($node);
if ($node->test_status != SIMPLETESTAUTO_ERROR) {
@@ -364,7 +532,7 @@
function resend_form_validate($form_id, $form_values, $form) {
if ($form_values['test_status'] != SIMPLETESTAUTO_PASS && $form_values['test_status'] != SIMPLETESTAUTO_FAIL) {
- //form_set_error('resend', t('You can only resend tests that are finished.'));
+ form_set_error('resend', t('You can only resend tests that are finished.'));
}
}
Index: /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto_settings.php
===================================================================
--- /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto_settings.php (revision 20)
+++ /var/www/testing_reporter/sites/all/modules/simpletestauto/simpletestauto_settings.php (working copy)
@@ -7,35 +7,3 @@
//$simpletest_modules Additional modules that will be checked out from cvs and tested. image and simpletest are needed
-$simpletest_modules = array(
- 'simpletest',
-);
-
-//$simpletest_install_dir A directory on the server that will be used to store test instances
-$simpletest_install_dir = '/home/tests';
-
-//$simpletest_install_dir_url Url of install dir. With trailing slash
-$simpletest_install_dir_url = 'http://testing.drupal.org/test/';
-
-//variable $bins holds path to every executable needed by test_it script change them as needed
-$bins = array(
- 'cvs' => '/usr/bin/cvs',
- 'mysql' => '/usr/bin/mysql',
- 'mysqladmin' => '/usr/bin/mysqladmin',
- 'patch' => '/usr/bin/patch',
- 'phpExec' => '/usr/bin/php',
- 'phpNoExec' => '/usr/bin/php',
- 'wget' => '/usr/bin/wget',
- 'cp' => '/bin/cp',
-);
-
-
-
-//set this to true if you want to see long debug messages if sth is not working correctly
-$debug = FALSE;
-
-$_SERVER['HTTP_HOST'] = 'testing.drupal.org';
-
-//username and password of database user used to create db's and use them for test sites
-$db_user = 'drupalCHK';
-$db_pass = '1drup41chk';
\ No newline at end of file
Index: /var/www/testing_reporter/sites/all/modules/simpletestauto/test_it.php
===================================================================
--- /var/www/testing_reporter/sites/all/modules/simpletestauto/test_it.php (revision 20)
+++ /var/www/testing_reporter/sites/all/modules/simpletestauto/test_it.php (working copy)
@@ -4,7 +4,6 @@
include_once($test_it_path . '/simpletestauto_settings.php');
include_once($test_it_path . '/install_drupal.inc');
include_once($test_it_path . '/enable_module.inc');
-
chdir(realpath(dirname(__FILE__) . '/../../'));
if (file_exists('./includes/bootstrap.inc')) {
include_once './includes/bootstrap.inc';
@@ -24,14 +23,21 @@
*/
function test($node_id) {
global $simpletest_install_dir, $simpletest_install_dir_url, $simpletest_modules, $bins, $msg, $executed_commands, $install_url, $db_user, $db_pass;
-
// we get all the data we need through a xmlrpc call to main server where data is held
$node = xmlrpc(variable_get('simpletestauto_return_address', ''), 'simpletestauto_getTestData', sha1(variable_get('simpletestauto_server_pwd', '')), $node_id);
-
$patch_url = $node['patch_url'];
- $version = getVersion($node['version']);
- if (!$version) return terminateTesting(1, "$version is not yet supported");
+ $version = $node['version'];
+ if(strstr($version, '.') !== FALSE) {
+ $version = version_to_tag($version);
+ }
+ if($version == 'HEAD') {
+ $version_major = 7;
+ } else {
+ $version_major = preg_split("/[-]/", $version);
+ $version_major = $version_major[1];
+ }
+ $version_major = (int) $version_major;
$msg = "";
$executed_commands = array();
$module_dir = drupal_get_path('module', 'simpletestauto');
@@ -39,7 +45,6 @@
// Generate a unique instance name.
$instance = "test_" . time() . rand(0, 32767);
- print_r($instance);
$instance_dir = $install_dir."/".$instance;
$install_url = $simpletest_install_dir_url . $instance;
if (!chdir($install_dir)) return terminateTesting(STA_ERROR, "Unable to chdir to $install_dir");
@@ -45,8 +50,8 @@
if (!chdir($install_dir)) return terminateTesting(STA_ERROR, "Unable to chdir to $install_dir");
//Check out drupal core from cvs
- $exec_cmd = $bins['cvs'] . ' -z6 -Q -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal co -d' . $instance .' -r ' . $version['min'] . ' drupal';
- if (execute($exec_cmd, "Unable to check Drupal branch " . $version['min'] . " out of CVS.", STA_ERROR) === FALSE) return FALSE;
+ $exec_cmd = $bins['cvs'] . ' -z6 -Q -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal co -d' . $instance .' -r ' . $version . ' drupal';
+ if (execute($exec_cmd, "Unable to check Drupal branch " . $version . " out of CVS.", STA_ERROR) === FALSE) return FALSE;
if (!mkdir($instance_dir.'/files', 0777)) return terminateTesting(STA_ERROR, "Unable to crate files dir\n");
@@ -51,7 +56,7 @@
if (!mkdir($instance_dir.'/files', 0777)) return terminateTesting(STA_ERROR, "Unable to crate files dir\n");
if (!chdir($instance_dir)) return terminateTesting(STA_ERROR, "Unable to chdir to $instance_dir");
- if ($version['core'] != '4.7') {
+ if ($version_major > 4) {
if (!mkdir($instance_dir.'/sites/all/modules', 0777)) return terminateTesting(STA_ERROR, "Unable to crate modules dir\n");
}
@@ -56,7 +61,7 @@
}
//Check out needed modules
- if ($versiong['core'] = '4.7') {
+ if ($version_major < 5) {
$modules_dir = 'modules/';
}
else {
@@ -68,12 +73,13 @@
$exec_cmd = $bins['cvs'] . ' -z6 -Q -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib co -d ' . $modules_dir . $module.' -r ' . $module_tag . ' contributions/modules/' . $module;
if (execute($exec_cmd, "Unable to check $module module branch " . $version['maj'] . " out of CVS.", STA_ERROR) === FALSE) return FALSE;
}
-
- //applying patch
- $exec_cmd = $bins['wget'] . ' -q -O - '.$patch_url.' | ' . $bins['patch'] . ' -p0 -d ' . $instance_dir;
- if (execute($exec_cmd, "Unable to patch file.") === FALSE) return FALSE;
+ if($node['patch_url']) {
+ //applying patch
+ $exec_cmd = $bins['wget'] . ' -q -O - '.$patch_url.' | ' . $bins['patch'] . ' -p0 -d ' . $instance_dir;
+ if (execute($exec_cmd, "Unable to patch file.") === FALSE) return FALSE;
- if (!checkSyntax($patch_url)) return FALSE;
+ if (!checkSyntax($patch_url)) return FALSE;
+ }
//create database for this site
$exec_cmd = $bins['mysqladmin'] . ' -u ' . $db_user .' -p' . $db_pass . ' create ' . $instance;
@@ -81,12 +87,11 @@
//chmod($instance_dir . '/sites/default/settings.php', 0777);
//call to installDrupal function in install_drupal.inc
- if (!installDrupal($version['core'], $instance)) return FALSE;
-
-
+ if (!installDrupal($version_major, $instance)) return FALSE;
+
//if everything is OK we check out simpletest libraries and run the tests
// Check out simpletest library from their cvs
- if ($version['core'] == '4.7') {
+ if ($version_major < 5) {
// we use 1.0.1 alpha version of simpletest with 4.7
$source = '/var/www/simpletestlib/simpletest1.0.1alpha3';
}
@@ -97,27 +102,26 @@
// simpletest libs alpha3 and beta2 are stored on server for easier access in $source
$exec_cmd = $bins['cp'] . ' -r '. $source . ' ' . $modules_dir . 'simpletest/simpletest';
if (execute($exec_cmd, "Unable to copy simpletest libs.", STA_ERROR) === FALSE) return FALSE;
-
+
//enable simpletest module
- if (!enableModule($version['core'], 'simpletest', $instance)) return FALSE;
-
-
- //TODO: remove this line when we get image tests working
- unlink($instance_dir . '/' . $modules_dir . '/simpletest/tests/image_module.test');
- if ($version['core'] == '4.7') {
- //remove taxonomy test in 4.7
- unlink($instance_dir . '/' . $modules_dir . '/simpletest/tests/taxonomy.module.test');
+ if (!enableModule($version_major, 'simpletest', $instance)) return FALSE;
+ if ($version_major < 7) {
+ //TODO: remove this line when we get image tests working
+ unlink($instance_dir . '/' . $modules_dir . '/simpletest/tests/image_module.test');
+ if ($version_major < 5) {
+ //remove taxonomy test in 4.7
+ unlink($instance_dir . '/' . $modules_dir . '/simpletest/tests/taxonomy.module.test');
+ }
}
-
//simpletest call
- $exec_cmd = $bins['phpNoExec'] . ' ' . $instance_dir . '/' . $modules_dir . '/simpletest/run_all_tests.php';
- $output = execute($exec_cmd, 'Simpletest failed', STA_FAIL, FALSE);
- $result_text = implode('
', $output);
-
- // pass and fail count
- $pf_count = parseResults($result_text);
-
- if ($pf_count[1] > 0) {
+ $st_url = $install_url .'/'. $modules_dir .'simpletest/run_all_tests.php?reporter=xml';
+ $response = drupal_http_request($st_url);
+ $xmlstr = $response->data;
+
+ $parser = &new SimpleTestXmlParser(new SimpleReporter());
+ $parser->parse($xmlstr);
+
+ if ($parser->_listener->_fails != 0 || $parser->_listener->_exceptions != 0) {
$status = STA_FAIL;
}
else {
@@ -123,8 +127,7 @@
else {
$status = STA_PASS;
}
- $msg .= '
' . $result_text;
- return terminateTesting($status, $msg);
+ return terminateTesting($status, $msg, $xmlstr);
}
/**
@@ -132,9 +135,8 @@
* @param exit_status arguemnt for exit call
* @param msg message string for sending to test server
*/
-function terminateTesting($exit_status, $terminate_msg) {
+function terminateTesting($exit_status, $terminate_msg, $xml = '') {
global $drupal_dir, $nid, $executed_commands, $debug, $test_it_path, $install_url;
- fopen('clean','w');
chdir($drupal_dir);
$msg = $terminate_msg;
if ($debug) {
@@ -141,7 +143,7 @@
$commands = implode("
", $executed_commands);
$msg = "
Executed commands:
" . $commands . "
" . $msg ;
}
- $msg = xmlrpc(variable_get('simpletestauto_return_address', ''), 'simpletestauto.writeResult', sha1(variable_get('simpletestauto_server_pwd', '')), $nid, $msg, $exit_status, $install_url);
+ $msg = xmlrpc(variable_get('simpletestauto_return_address', ''), 'simpletestauto.writeResult', sha1(variable_get('simpletestauto_server_pwd', '')), $nid, $msg, $exit_status, $install_url, $xml);
if ($exit_status == STA_PASS) {
return TRUE;
}
@@ -150,7 +152,6 @@
}
}
-
/**
* Checks if all files in array are where they are supposed to be. If not terminates
* testing with a proper msg
@@ -197,33 +198,6 @@
}
/**
- * Returns Drupal major version. Basically this function strips down minor Drupal versions.
- * @return major drupal version
- */
-function getVersion($v) {
- // TODO: change this so it latest head is configurable from settings page
- if ($v == '6.x-dev') {
- $version['min'] = 'HEAD';
- $version['maj'] = 'HEAD';
- $version['core'] = '6';
- }
- else {
- $version['min'] = version_to_tag($v);
- $version['maj'] = $version['min'];
- //string magic to get core version 5, 6 or 4.7
- $pieces = explode('-', $v);
- $pieces = explode('.', $pieces[0]);
- $ver = array();
- for($i = 0; $i < count($pieces) -1; $i++) {
- $ver[] = $pieces[$i];
- }
- // core version is 6, 5 or 4.7
- $version['core'] = implode('.', $ver);
- }
- return $version;
-}
-
-/**
* Converts human readable patch version to drupal tag or branch
*/
function version_to_tag($version) {
@@ -232,8 +206,12 @@
$version = preg_replace('/\./', '-', $version);
$version = preg_replace('/beta/', 'BETA-', $version);
$version = preg_replace('/rc/', 'RC-', $version);
-
- return 'DRUPAL-' . $version;
+ if($version == 7) {
+ $output = 'HEAD';
+ } else {
+ $output = 'DRUPAL-' . $version;
+ }
+ return $output;
}
/**
@@ -240,16 +218,32 @@
* Turns module name and Drupal version into the correct CVS tag for the given module, favors stable tags over branches
*/
function get_latest_tag($module, $version) {
- switch ($version['core']) {
- case '6':
- return 'HEAD';
- case '5':
- return 'DRUPAL-5';
- case '4.7':
- return 'DRUPAL-4-7';
- default:
- return FALSE;
+ $sticky = 'HEAD';
+ switch ($module) {
+ case 'simpletest':
+ if(stristr($version, 'DRUPAL-6') !== FALSE) {
+ $sticky = 'DRUPAL-6--1';
+ }
+ if(stristr($version, 'DRUPAL-5') !== FALSE) {
+ $sticky = 'DRUPAL-5';
+ }
+ if(stristr($version, 'DRUPAL-4') !== FALSE) {
+ if(stristr($version, 'DRUPAL-4-7') !== FALSE) {
+ $sticky = 'DRUPAL-4-7';
+ }
+ if(stristr($version, 'DRUPAL-4-6') !== FALSE) {
+ $sticky = 'DRUPAL-4-6';
+ }
+ if(stristr($version, 'DRUPAL-4-5') !== FALSE) {
+ $sticky = 'DRUPAL-4-5';
+ }
+ if(stristr($version, 'DRUPAL-4-4') !== FALSE) {
+ $sticky = 'DRUPAL-4-4';
+ }
+ }
+ break;
}
+ return $sticky;
}
/**
@@ -298,7 +292,24 @@
}
return $test_status;
}
-
+function set_vars() {
+ global $simpletest_install_dir, $simpletest_install_dir_url, $simpletest_modules, $bins, $msg, $executed_commands, $install_url, $db_user, $db_pass;
+ $simpletest_install_dir = variable_get('simpletest_install_dir', '/var/www/testing_stage');
+ $simpletest_install_dir_url = variable_get('simpletest_install_dir_url', 'http://testing_stage/');
+ $simpletest_modules = array('simpletest');
+ $bins = array(
+ 'cvs' => variable_get('simpletest_bins_cvs', '/usr/bin/cvs'),
+ 'mysql' => variable_get('simpletest_bins_mysql', '/usr/bin/mysql'),
+ 'mysqladmin' => variable_get('simpletest_bins_mysqladmin', '/usr/bin/mysqladmin'),
+ 'patch' => variable_get('simpletest_bins_patch', '/usr/bin/patch'),
+ 'phpExec' => variable_get('simpletest_bins_phpexec', '/usr/bin/php'),
+ 'phpNoExec' => variable_get('simpletest_bins_phpnoexec', '/usr/bin/php'),
+ 'wget' => variable_get('simpletest_bins_wget', '/usr/bin/wget'),
+ 'cp' => variable_get('simpletest_bins_cp', '/usr/bin/cp'),
+ );
+ $db_user = variable_get('simpletest_db_user', 'db_user');
+ $db_pass = variable_get('simpletest_db_pass', 'db_pass');
+}
// Script starts here
$drupal_dir = getcwd();
@@ -303,6 +314,7 @@
$drupal_dir = getcwd();
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+set_vars();
if (!variable_get('simpletest_in_progress', 0)) {
variable_set('simpletest_in_progress', 1);
@@ -310,7 +322,6 @@
else {
exit("Test already in progress\n");
}
-check_bins($bins);
//gets the test queue from db, all tests that need testing
//$current_tests = variable_get('simpletestauto_tests', array());