MDL-32961 try to use native grep when searching for DONOT...COMMIT tags

This commit is contained in:
Petr Skoda 2012-05-12 23:05:42 +02:00
parent 08ad325702
commit b136a25b16

View File

@ -33,6 +33,27 @@ class code_testcase extends advanced_testcase {
public function test_dnc() {
global $CFG;
if ($CFG->ostype === 'UNIX') {
// try it the faster way
$oldcwd = getcwd();
chdir($CFG->dirroot);
$output = null;
$exclude = array();
foreach ($this->extensions_to_ignore as $ext) {
$exclude[] = '--exclude="*.'.$ext.'"';
}
$exclude = implode(' ', $exclude);
exec('grep -r '.$exclude.' DONOT'.'COMMIT .', $output, $code);
chdir($oldcwd);
// return code 0 means found, return code 1 means NOT found, 127 is grep not found
if ($code == 1) {
// executed only if no file failed the test
$this->assertTrue(true);
return;
}
}
$regexp = '/\.(' . implode('|', $this->extensions_to_ignore) . ')$/';
$this->badstrings = array();
$this->badstrings['DONOT' . 'COMMIT'] = 'DONOT' . 'COMMIT'; // If we put the literal string here, it fails the test!