[phc-internals] [phc commit] r1129 - trunk/test/framework

codesite-noreply at google.com codesite-noreply at google.com
Tue Apr 1 19:09:08 IST 2008


Author: paul.biggar
Date: Tue Apr  1 11:05:25 2008
New Revision: 1129

Modified:
   trunk/test/framework/reduce

Log:
Support -F flag in reduce, for reducing limit_assignment and other plugins.


Modified: trunk/test/framework/reduce
==============================================================================
--- trunk/test/framework/reduce	(original)
+++ trunk/test/framework/reduce	Tue Apr  1 11:05:25 2008
@@ -39,7 +39,7 @@

 $cg = new Console_Getopt();
 $command_line = join (" ", $cg->readPHPArgv());
-$opt_result = $cg->getopt($cg->readPHPArgv(), "vhc:rdDf:i:Uu");
+$opt_result = $cg->getopt($cg->readPHPArgv(), "vhc:rdDf:i:UuF:");
 if (!is_array ($opt_result))
 	die ($opt_result->message."\n");

@@ -51,6 +51,7 @@
 $opt_interpret = false;
 $opt_dont_upper = false;
 $opt_upper = false;
+$opt_failure = false;
 foreach ($opts as $opt)
 {
 	switch ($opt[0])
@@ -65,10 +66,11 @@
  		case 'D': $opt_command .= "--run plugins/tools/demi_eval.la 
--r-option=false --xdump=plugins/tools/demi_eval.la"; break;
 		case 'f': $opt_file = $opt[1]; break;
 		case 'i': $opt_interpret = $opt[1]; break;
+		case 'F': $opt_failure = $opt[1]; break;
 	}
 }
 if ($opt_command === "")
-	$opt_command = "--xdump=AST-to-HIR";
+	$opt_command = "--xdump=AST-to-HIR --no-xml-attrs";

 if ($opt_help || count ($arguments) < 1)
 {
@@ -90,11 +92,14 @@
      -i     Mnemonic: Interpret. Instead of compiling the script, dump 
it at the specified pass and interpret it.
     -U     Don't print 'upper' debug files (not related to -u)
     -u     Used with -i, 'upper's before dumping (not related to -U)
+    -F     Mnemonic: Failure. Used for plugins which print "Failure" 
to indicate error. Run phc with the plugin to determine failure.
+    -X     No XML attrs (pass --no-xml-attrs with --xdumps)

 Sample commands:
     reduce -v test/subjects/codegen/0001.php
      reduce "-c--run plugins/tools/debug_zval.la 
-xdump=plugins/tools/debug_zval.la" test/subjects/codegen/0001.php
     reduce -v 0001.uhir.php
+    reduce -F plugins/tests/limit_assignments.la test/subjects/codegen/bench_simple.php

 EOL
 	);
@@ -247,7 +252,7 @@
 # reduced program otherwise.
 function do_main_step ($xprogram, $start, $num, $filename)
 {
-	global $num_steps, $opt_interpret;
+	global $num_steps, $opt_interpret, $opt_failure;
 	$num_steps++;

 	# Reduce
@@ -266,6 +271,24 @@
 		// if $num == 0, then this is intentional
 		debug (1, "The two programs are identical. Skip.");
 		return false;
+	}
+
+	# do this all here to avoid littering the function with it
+	if ($opt_failure)
+	{
+		debug (2, "Getting output when run with failure plugin");
+		list ($phc_out, $phc_err, $phc_exit) = run ("src/phc --read-xml=ast 
--run $opt_failure", $xnew_program);
+		if (preg_match ("/Failure$/", $phc_out))
+		{
+			debug (2, "Success, bug kept in");
+			dump ("$filename.phc_out_$id", $phc_out);
+			dump ("$filename.xsuccess_$id", $xnew_program);
+			dump ("$filename.psuccess_$id", $pnew_program);
+			dump ("$filename.usuccess_$id", $unew_program);
+			return $xnew_program;
+		}
+		else
+			return false;
 	}

 	# Run through PHP


More information about the phc-internals mailing list