[Fusionforge-commits] r11265 - in trunk: src/www/survey/admin tests/code/deprecations tests/code/syntax

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Fri Oct 29 20:08:31 CEST 2010


Author: aljeux
Date: 2010-10-29 20:08:31 +0200 (Fri, 29 Oct 2010)
New Revision: 11265

Modified:
   trunk/src/www/survey/admin/show_results.php
   trunk/tests/code/deprecations/DeprecationsTest.php
   trunk/tests/code/syntax/SyntaxTest.php
Log:
code tests no longer depends on current working dir.

Modified: trunk/src/www/survey/admin/show_results.php
===================================================================
--- trunk/src/www/survey/admin/show_results.php	2010-10-29 18:08:25 UTC (rev 11264)
+++ trunk/src/www/survey/admin/show_results.php	2010-10-29 18:08:31 UTC (rev 11265)
@@ -44,7 +44,7 @@
     exit_no_group();
 }
 
-$g = group_get_object($group_id);
+$g =& group_get_object($group_id);
 if (!$g || !is_object($g) || $g->isError()) {
     exit_no_group();
 }

Modified: trunk/tests/code/deprecations/DeprecationsTest.php
===================================================================
--- trunk/tests/code/deprecations/DeprecationsTest.php	2010-10-29 18:08:25 UTC (rev 11264)
+++ trunk/tests/code/deprecations/DeprecationsTest.php	2010-10-29 18:08:31 UTC (rev 11265)
@@ -17,7 +17,8 @@
 	 */
 	public function testdb_query()
 	{
-		$output = `cd .. ; find src tests -name '*.php' -type f | xargs pcregrep -l '\bdb_m?query\b' \
+		$root = dirname(dirname(dirname(dirname(__FILE__))));
+		$output = `cd $root; find src tests -name '*.php' -type f | xargs pcregrep -l '\bdb_m?query\b' \
 					   | grep -v ^tests/code/deprecations/DeprecationsTest.php \
 					   | grep -v ^src/db/upgrade-db.php \
 					   | grep -v ^src/www/include/database-oci8.php \
@@ -125,11 +126,12 @@
 
 		$pattern = implode ('|', $vars) ;
 		
-		$output = `cd .. ; find src tests -name '*.php' -type f | xargs pcregrep -n '\\$($pattern)\b(?! *=[^=])' \
+		$root = dirname(dirname(dirname(dirname(__FILE__))));
+		$output = `cd $root ; find src tests -name '*.php' -type f | xargs pcregrep -n '\\$($pattern)\b(?! *=[^=])' \
 					   | grep -v ^src/common/include/config-vars.php`;
 		$this->assertEquals('', $output, "Found deprecated \$var for var in ($pattern):");
 
-		$output = `cd .. ; find src tests -name '*.php' -type f | xargs pcregrep -n '\\\$GLOBALS\\[.?($pattern).?\\](?! *=[^=])' \
+		$output = `cd $root ; find src tests -name '*.php' -type f | xargs pcregrep -n '\\\$GLOBALS\\[.?($pattern).?\\](?! *=[^=])' \
 					   | grep -v ^src/common/include/config-vars.php`;
 		$this->assertEquals('', $output, "Found deprecated \$GLOBALS['\$var'] for var in ($pattern):");
 	}
@@ -139,7 +141,8 @@
 	 */
 	public function testsession_require()
 	{
-		$output = `cd .. ; find src tests -name '*.php' -type f | xargs pcregrep -l '\bsession_require[^_]' \
+		$root = dirname(dirname(dirname(dirname(__FILE__))));
+		$output = `cd $root ; find src tests -name '*.php' -type f | xargs pcregrep -l '\bsession_require[^_]' \
 					   | grep -v ^tests/code/deprecations/DeprecationsTest.php \
 					   | grep -v ^src/common/include/session.php`;
 		$this->assertEquals('', $output);

Modified: trunk/tests/code/syntax/SyntaxTest.php
===================================================================
--- trunk/tests/code/syntax/SyntaxTest.php	2010-10-29 18:08:25 UTC (rev 11264)
+++ trunk/tests/code/syntax/SyntaxTest.php	2010-10-29 18:08:31 UTC (rev 11265)
@@ -25,24 +25,13 @@
     }
   }
 
-  /**
-   * First, make sure it is run from inside the tests/ subdir
-   */
-  public function testPath()
-  {
-    $output = `ls ../src >/dev/null; echo $?`;
-    $rc = trim($output);
-    if ($rc != '0') {
-      $output = `ls ../src`;
-      $this->fail('Must be run from inside the "tests/" subdir : `ls ../src` reports "'.$output);
-    }
-  }
     /**
      * Validate all php code with php -l.
      */
     public function testPhpSyntax()
     {
-	    $output = `cd .. ; find src tests -name '*.php' -type f  -exec php -l {} \; | grep -v '^No syntax errors detected'`;
+		$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);
     }
 
@@ -51,14 +40,14 @@
      */
     public function testUTF8Chars()
     {
-	    // Skip the wiki part which is not UTF-8 encoded.
-	    $output = `cd .. ; find src tests -name '*.php' -not -path 'src/plugins/wiki/www/*' -type f | xargs isutf8`;
+		$root = dirname(dirname(dirname(dirname(__FILE__))));
+		$output = `find $root/src $root/tests -name '*.php' -type f | xargs isutf8`;
 	    $this->assertEquals('', $output);
-	    $output = `cd .. ; find src tests -name '*.sql' -type f | xargs isutf8`;
+	    $output = `find $root/src $root/tests -name '*.sql' -type f | xargs isutf8`;
 	    $this->assertEquals('', $output);
-	    $output = `cd .. ; find src tests -name '*.sh' -type f | xargs isutf8`;
+	    $output = `find $root/src $root/tests -name '*.sh' -type f | xargs isutf8`;
 	    $this->assertEquals('', $output);
-	    $output = `cd .. ; find src tests -name '*.pl' -type f | xargs isutf8`;
+	    $output = `find $root/src $root/tests -name '*.pl' -type f | xargs isutf8`;
 	    $this->assertEquals('', $output);
     }
 
@@ -67,13 +56,14 @@
      */
     public function testUnixLineEndings()
     {
-	    $output = `cd .. ; find src tests -name '*.php' -type f | xargs pcregrep -l '\r$'`;
+		$root = dirname(dirname(dirname(dirname(__FILE__))));
+		$output = `find $root/src $root/tests -name '*.php' -type f | xargs pcregrep -l '\r$'`;
 	    $this->assertEquals('', $output);
-	    $output = `cd .. ; find src tests -name '*.sql' -type f | xargs pcregrep -l '\r$'`;
+		$output = `find $root/src $root/tests -name '*.sql' -type f | xargs pcregrep -l '\r$'`;
 	    $this->assertEquals('', $output);
-	    $output = `cd .. ; find src tests -name '*.sh' -type f | xargs pcregrep -l '\r$'`;
+		$output = `find $root/src $root/tests -name '*.sh' -type f | xargs pcregrep -l '\r$'`;
 	    $this->assertEquals('', $output);
-	    $output = `cd .. ; find src tests -name '*.pl' -type f | xargs pcregrep -l '\r$'`;
+		$output = `find $root/src $root/tests -name '*.pl' -type f | xargs pcregrep -l '\r$'`;
 	    $this->assertEquals('', $output);
     }
 
@@ -82,7 +72,8 @@
      */
     public function testEmptyLastLine()
     {
-	    $output = `cd .. ; find src tests -name '*.php' -type f | while read i ; do [ -s \$i ] && [ -z "\$(tail -n 1 \$i)" ] && echo \$i ; done`;
+		$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);
     }
 
@@ -91,7 +82,8 @@
      */
     public function testGettextSyntax()
     {
-	    $output = `cd ../src ; ./utils/manage-translations.sh check 2>&1`;
+		$root = dirname(dirname(dirname(dirname(__FILE__))));
+		$output = `cd $root/src ; ./utils/manage-translations.sh check 2>&1`;
 	    $this->assertEquals('', $output);
     }
 }




More information about the Fusionforge-commits mailing list