- Timestamp:
- 04/06/10 12:25:44 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/www/app/vendors/shells/validators.php
r341 r342 54 54 55 55 /** 56 * Add missing validators to the test suites 57 */ 58 public function missing() 59 { 60 $suite_id = $this->_getSuite(); 61 $validator = $this->_getValidator(); 62 63 if ($validator == 'all') { 64 $validators = Configure::read('Validator'); 65 } else { 66 $validators = array(); 67 $validators[$validator] = Configure::read('Validator.' . $validator); 68 } 69 70 var_dump($validators); 71 $count = 0; 72 73 // Find all requests 74 $requests = $this->Testsuite->getRequests($suite_id, array( 75 'Validator' => array('fields' => 'name'), 76 'Job', 77 'Job.Result', 78 'Job.Result.Validator' => array('fields' => 'name'), 79 )); 80 81 // Loop through the requests and add missing validators 82 foreach ($requests as $request) { 83 foreach ($validators as $validator_name => $validator_config) { 84 if (!$validator_config) { 85 continue; 86 } 87 88 $existing = Set::extract('/Validator/name', $request); 89 if (!in_array($validator_name, $existing)) { 90 $this->Validator->create(); 91 $this->Validator->save(array('Validator' => array( 92 'name' => $validator_name, 93 'parent_id' => $request['Request']['id'], 94 ))); 95 $this->Validator->defer('run'); 96 $count++; 97 } 98 } 99 } 100 101 // Find all the results 102 $results = Set::extract('/Job/Result', $requests); 103 foreach ($results as $result) { 104 if (empty($result['Result'])) { 105 continue; 106 } 107 108 foreach ($validators as $validator_name => $validator_config) { 109 if (!$validator_config) { 110 continue; 111 } 112 113 $existing = Set::extract('/Result/Validator/name', $result); 114 if (!in_array($validator_name, $existing)) { 115 $this->Validator->create(); 116 $this->Validator->save(array('Validator' => array( 117 'name' => $validator_name, 118 'parent_id' => $result['Result']['id'], 119 ))); 120 $this->Validator->defer('run'); 121 $count++; 122 } 123 } 124 } 125 126 $this->out(sprintf('Created and scheduled %d validators to run in the background.', $count)); 127 } 128 129 /** 56 130 * Ask for a test suite 57 131 */ … … 68 142 } 69 143 70 $this->out(' For which test suite do you want to regenerate the validator results?');144 $this->out('Please coose a test suite.'); 71 145 $this->hr(); 72 146 foreach ($options as $index => $option) { … … 106 180 { 107 181 $options = array(1 => 'All validators'); 108 $validators = $this->Validator->find('all', array( 109 'fields' => array('DISTINCT Validator.name'), 110 'order' => 'Validator.name ASC', 111 'recursive' => -1, 112 )); 113 114 foreach ($validators as $validator) { 115 $options[] = $validator['Validator']['name']; 116 } 117 118 $this->out('For which validator do you want to re-run the results?'); 182 183 $validators = Configure::read('Validator'); 184 foreach ($validators as $validator_name => $validator_config) { 185 $options[] = $validator_name; 186 } 187 188 $this->out('Please choose a validator.'); 119 189 $this->hr(); 120 190 foreach ($options as $index => $option) { … … 176 246 * Get all validators based on test suite, validator name and state 177 247 */ 178 private function _getValidators($suite, $name, $state) 179 { 180 181 $conditions = array('Validator.state' => $state); 248 private function _getValidators($suite, $name, $state = array()) 249 { 250 $conditions = array(); 251 252 if ($state) { 253 $conditions['Validator.state'] = $state; 254 } 255 182 256 if ($name != 'all') { 183 257 $conditions['Validator.name'] = $name;
Note: See TracChangeset
for help on using the changeset viewer.