*/
class Syntax_Tests extends PHPUnit_Framework_TestCase
{
- /**
- * First, make sure pcregrep is installed
- */
- public function testPcRegrepInstalled()
- {
- $output = `type pcregrep >/dev/null; echo $?`;
- $rc = trim($output);
- if ($rc != '0') {
- $output = `type pcregrep`;
- $this->fail('You should probably install "pcregrep" : `type pcregrep` reports "'.$output);
- }
- }
+ /**
+ * First, make sure pcregrep is installed
+ */
+ public function testPcRegrepInstalled()
+ {
+ $output = `type pcregrep >/dev/null; echo $?`;
+ $rc = trim($output);
+ if ($rc != '0') {
+ $output = `type pcregrep`;
+ $this->fail('You should probably install "pcregrep" : `type pcregrep` reports "'.$output);
+ }
+ }
- /**
- * Validate all php code with php -l.
- */
- public function testPhpSyntax()
- {
+ /**
+ * Validate all php code with php -l.
+ */
+ public function testPhpSyntax()
+ {
$root = dirname(dirname(dirname(dirname(__FILE__))));
$output = `find $root/src $root/tests -name '*.php' -type f -exec php -l {} \; | grep -v '^No syntax errors detected'`;
- $this->assertEquals('', $output);
- }
+ $this->assertEquals('', $output);
+ }
- /**
- * Validate all scripts with isutf8.
- */
- public function testUTF8Chars()
- {
+ /**
+ * Validate all scripts with isutf8.
+ */
+ public function testUTF8Chars()
+ {
$root = dirname(dirname(dirname(dirname(__FILE__))));
- $output = `find $root/src $root/tests -name '*.php' -type f | xargs isutf8`;
+ // We don't pass syntax tests on 3rd party libraries in src/lib/vendor
+ $exclude_third_party_libs="-path '$root/src/lib/vendor' -prune -o ";
+ $output = `find $root/src $root/tests $exclude_third_party_libs -name '*.php' -type f -print | xargs isutf8`;
+ $this->assertEquals('', $output);
+ $output = `find $root/src $root/tests $exclude_third_party_libs -name '*.css' -type f -print | xargs isutf8`;
$this->assertEquals('', $output);
- $output = `find $root/src $root/tests -name '*.css' -type f | xargs isutf8`;
+ $output = `find $root/src $root/tests $exclude_third_party_libs -name '*.sql' -type f -print | xargs isutf8`;
$this->assertEquals('', $output);
- $output = `find $root/src $root/tests -name '*.sql' -type f | xargs isutf8`;
+ $output = `find $root/src $root/tests $exclude_third_party_libs -name '*.sh' -type f -print | xargs isutf8`;
$this->assertEquals('', $output);
- $output = `find $root/src $root/tests -name '*.sh' -type f | xargs isutf8`;
+ $output = `find $root/src $root/tests $exclude_third_party_libs -name '*.pl' -type f -print | xargs isutf8`;
$this->assertEquals('', $output);
- $output = `find $root/src $root/tests -name '*.pl' -type f | xargs isutf8`;
+ $output = `find $root/src $root/tests $exclude_third_party_libs -name '*.tmpl' -type f -print | xargs isutf8`;
$this->assertEquals('', $output);
- $output = `find $root/src $root/tests -name '*.tmpl' -type f | xargs isutf8`;
+ $output = `find $root/src $root/tests $exclude_third_party_libs -name '*.xml' -type f -print | xargs isutf8`;
$this->assertEquals('', $output);
- $output = `find $root/src $root/tests -name '*.xml' -type f | xargs isutf8`;
- $this->assertEquals('', $output);
- }
+ }
- /**
- * Ensure all scripts use Unix-style line endings
- */
- public function testUnixLineEndings()
- {
+ /**
+ * Ensure all scripts use Unix-style line endings
+ */
+ public function testUnixLineEndings()
+ {
$root = dirname(dirname(dirname(dirname(__FILE__))));
+ // to see individual lines + line nums : find src tests -name '*.php' -type f | xargs pcregrep -n '\r$'
$output = `find $root/src $root/tests -name '*.php' -type f | xargs pcregrep -l '\r$'`;
- $this->assertEquals('', $output);
+ $this->assertEquals('', $output);
$output = `find $root/src $root/tests -name '*.sql' -type f | xargs pcregrep -l '\r$'`;
- $this->assertEquals('', $output);
+ $this->assertEquals('', $output);
$output = `find $root/src $root/tests -name '*.sh' -type f | xargs pcregrep -l '\r$'`;
- $this->assertEquals('', $output);
+ $this->assertEquals('', $output);
$output = `find $root/src $root/tests -name '*.pl' -type f | xargs pcregrep -l '\r$'`;
- $this->assertEquals('', $output);
- }
+ $this->assertEquals('', $output);
+ }
- /**
- * Ensure no scripts have SVN conflicts markers
- */
- public function testSVNConflicts()
- {
- $root = dirname(dirname(dirname(dirname(__FILE__))));
- $output = `find $root/src $root/tests -type f | xargs grep -l '^<<<<<<'`;
- $this->assertEquals('', $output);
- $output = `find $root/src $root/tests -type f | xargs grep -l '^>>>>>>'`;
- $this->assertEquals('', $output);
- }
+ /**
+ * Ensure no scripts have SVN conflicts markers
+ */
+ public function testSVNConflicts()
+ {
+ $root = dirname(dirname(dirname(dirname(__FILE__))));
+ $output = `find $root/src $root/tests -type f | xargs grep -l '^<<<<<<'`;
+ $this->assertEquals('', $output);
+ $output = `find $root/src $root/tests -type f | xargs grep -l '^>>>>>>'`;
+ $this->assertEquals('', $output);
+ }
- /**
- * Ensure no script has an empty last line
- */
- public function testEmptyLastLine()
- {
+ /**
+ * Ensure no script has an empty last line
+ */
+ public function testEmptyLastLine()
+ {
$root = dirname(dirname(dirname(dirname(__FILE__))));
- $output = `find $root/src $root/tests -name '*.php' -type f | while read i ; do [ -s \$i ] && [ -z "\$(tail -n 1 \$i)" ] && echo \$i ; done`;
- $this->assertEquals('', $output);
- }
+ // We don't pass syntax tests on 3rd party libraries in src/lib/vendor
+ $exclude_third_party_libs="-path '$root/src/lib/vendor' -prune -o ";
+ $output = `find $root/src $root/tests $exclude_third_party_libs -name '*.php' -type f -print | while read i ; do [ -s \$i ] && [ -z "\$(tail -n 1 \$i)" ] && echo \$i ; done`;
+ $this->assertEquals('', $output);
+ }
- /**
- * Validate syntax of gettextfiles
- */
- public function testGettextSyntax()
- {
+ /**
+ * Validate syntax of gettextfiles
+ */
+ public function testGettextSyntax()
+ {
$root = dirname(dirname(dirname(dirname(__FILE__))));
$output = `cd $root/src ; ./utils/manage-translations.sh check 2>&1`;
- $this->assertEquals('', $output);
- }
+ $this->assertEquals('', $output);
+ }
}
// Local Variables: