Skip to content

Commit

Permalink
Improve no_tabs test to print out a complete list of files + line num…
Browse files Browse the repository at this point in the history
…bers + line snippet.
  • Loading branch information
andyst committed Aug 30, 2009
1 parent 22aa0b3 commit b5813f9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions modules/gallery/tests/File_Structure_Test.php
Expand Up @@ -177,10 +177,20 @@ public function no_tabs_in_our_code_test() {
new GalleryCodeFilterIterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(DOCROOT))));
$errors = array();
foreach ($dir as $file) {
$this->assert_false(
preg_match('/\t/', file_get_contents($file)),
"{$file->getPathname()} has tabs in it");
$file_as_string = file_get_contents($file);
if (preg_match('/\t/', $file_as_string)) {
foreach (split("\n", $file_as_string) as $l => $line) {
if (preg_match('/\t/', $line)) {
$errors[] = "$file:$l has tab(s) ($line)";
}
}
}
$file_as_string = null;
}
if ($errors) {
$this->assert_false(true, "tab(s) found:\n" . join("\n", $errors));
}
}

Expand Down

0 comments on commit b5813f9

Please sign in to comment.