mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-32961 try to use native grep when searching for DONOT...COMMIT tags
This commit is contained in:
parent
08ad325702
commit
b136a25b16
1 changed files with 21 additions and 0 deletions
|
@ -33,6 +33,27 @@ class code_testcase extends advanced_testcase {
|
||||||
|
|
||||||
public function test_dnc() {
|
public function test_dnc() {
|
||||||
global $CFG;
|
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) . ')$/';
|
$regexp = '/\.(' . implode('|', $this->extensions_to_ignore) . ')$/';
|
||||||
$this->badstrings = array();
|
$this->badstrings = array();
|
||||||
$this->badstrings['DONOT' . 'COMMIT'] = 'DONOT' . 'COMMIT'; // If we put the literal string here, it fails the test!
|
$this->badstrings['DONOT' . 'COMMIT'] = 'DONOT' . 'COMMIT'; // If we put the literal string here, it fails the test!
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue