• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP generate_diff函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中generate_diff函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_diff函数的具体用法?PHP generate_diff怎么用?PHP generate_diff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了generate_diff函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: run_test


//.........这里部分代码省略.........
        */
        if (preg_match("/^{$wanted_re}\$/s", $output)) {
            $passed = true;
            if (!$cfg['keep']['php']) {
                @unlink($test_file);
            }
            if (!$leaked && !$failed_headers) {
                if (isset($section_text['XFAIL'])) {
                    $warn = true;
                    $info = " (warn: XFAIL section but test passes)";
                } else {
                    show_result("PASS", $tested, $tested_file, '', $temp_filenames);
                    junit_mark_test_as('PASS', $shortname, $tested);
                    return 'PASSED';
                }
            }
        }
    } else {
        $wanted = trim($section_text['EXPECT']);
        $wanted = preg_replace('/\\r\\n/', "\n", $wanted);
        show_file_block('exp', $wanted);
        // compare and leave on success
        if (!strcmp($output, $wanted)) {
            $passed = true;
            if (!$cfg['keep']['php']) {
                @unlink($test_file);
            }
            if (!$leaked && !$failed_headers) {
                if (isset($section_text['XFAIL'])) {
                    $warn = true;
                    $info = " (warn: XFAIL section but test passes)";
                } else {
                    show_result("PASS", $tested, $tested_file, '', $temp_filenames);
                    junit_mark_test_as('PASS', $shortname, $tested);
                    return 'PASSED';
                }
            }
        }
        $wanted_re = null;
    }
    // Test failed so we need to report details.
    if ($failed_headers) {
        $passed = false;
        $wanted = $wanted_headers . "\n--HEADERS--\n" . $wanted;
        $output = $output_headers . "\n--HEADERS--\n" . $output;
        if (isset($wanted_re)) {
            $wanted_re = preg_quote($wanted_headers . "\n--HEADERS--\n", '/') . $wanted_re;
        }
    }
    if ($leaked) {
        $restype[] = 'LEAK';
    }
    if ($warn) {
        $restype[] = 'WARN';
    }
    if (!$passed) {
        if (isset($section_text['XFAIL'])) {
            $restype[] = 'XFAIL';
            $info = '  XFAIL REASON: ' . rtrim($section_text['XFAIL']);
        } else {
            $restype[] = 'FAIL';
        }
    }
    if (!$passed) {
        // write .exp
        if (strpos($log_format, 'E') !== false && file_put_contents($exp_filename, $wanted, FILE_BINARY) === false) {
            error("Cannot create expected test output - {$exp_filename}");
        }
        // write .out
        if (strpos($log_format, 'O') !== false && file_put_contents($output_filename, $output, FILE_BINARY) === false) {
            error("Cannot create test output - {$output_filename}");
        }
        // write .diff
        $diff = generate_diff($wanted, $wanted_re, $output);
        if (is_array($IN_REDIRECT)) {
            $diff = "# original source file: {$shortname}\n" . $diff;
        }
        show_file_block('diff', $diff);
        if (strpos($log_format, 'D') !== false && file_put_contents($diff_filename, $diff, FILE_BINARY) === false) {
            error("Cannot create test diff - {$diff_filename}");
        }
        // write .sh
        if (strpos($log_format, 'S') !== false && file_put_contents($sh_filename, "#!/bin/sh\n\n{$cmd}\n", FILE_BINARY) === false) {
            error("Cannot create test shell script - {$sh_filename}");
        }
        chmod($sh_filename, 0755);
        // write .log
        if (strpos($log_format, 'L') !== false && file_put_contents($log_filename, "\n---- EXPECTED OUTPUT\n{$wanted}\n---- ACTUAL OUTPUT\n{$output}\n---- FAILED\n", FILE_BINARY) === false) {
            error("Cannot create test log - {$log_filename}");
            error_report($file, $log_filename, $tested);
        }
    }
    show_result(implode('&', $restype), $tested, $tested_file, $info, $temp_filenames);
    foreach ($restype as $type) {
        $PHP_FAILED_TESTS[$type . 'ED'][] = array('name' => $file, 'test_name' => (is_array($IN_REDIRECT) ? $IN_REDIRECT['via'] : '') . $tested . " [{$tested_file}]", 'output' => $output_filename, 'diff' => $diff_filename, 'info' => $info);
    }
    $diff = empty($diff) ? '' : preg_replace('/\\e/', '<esc>', $diff);
    junit_mark_test_as($restype, str_replace($cwd . '/', '', $tested_file), $tested, null, $info, $diff);
    return $restype[0] . 'ED';
}
开发者ID:jimjag,项目名称:php-src,代码行数:101,代码来源:run-tests.php


示例2: run_test


//.........这里部分代码省略.........
            $wanted_re = str_replace('%s', '[^\\r\\n]+', $wanted_re);
            $wanted_re = str_replace('%a', '.+', $wanted_re);
            $wanted_re = str_replace('%w', '\\s*', $wanted_re);
            $wanted_re = str_replace('%i', '[+-]?\\d+', $wanted_re);
            $wanted_re = str_replace('%d', '\\d+', $wanted_re);
            $wanted_re = str_replace('%x', '[0-9a-fA-F]+', $wanted_re);
            $wanted_re = str_replace('%f', '[+-]?\\.?\\d+\\.?\\d*(?:[Ee][+-]?\\d+)?', $wanted_re);
            $wanted_re = str_replace('%c', '.', $wanted_re);
            // %f allows two points "-.0.0" but that is the best *simple* expression
        }
        /* DEBUG YOUR REGEX HERE
        		var_dump($wanted_re);
        		print(str_repeat('=', 80) . "\n");
        		var_dump($output);
        */
        if (preg_match((string) "/^{$wanted_re}\$/s", $output)) {
            $passed = true;
            if (!$cfg['keep']['php']) {
                @unlink($test_file);
            }
            if (isset($old_php)) {
                $php = $old_php;
            }
            if (!$leaked && !$failed_headers) {
                show_result("PASS", $tested, $tested_file, '', $temp_filenames);
                return 'PASSED';
            }
        }
    } else {
        $wanted = trim($section_text['EXPECT']);
        $wanted = preg_replace('/\\r\\n/', "\n", $wanted);
        show_file_block('exp', $wanted);
        // compare and leave on success
        if (!strcmp($output, $wanted)) {
            $passed = true;
            if (!$cfg['keep']['php']) {
                @unlink($test_file);
            }
            if (isset($old_php)) {
                $php = $old_php;
            }
            if (!$leaked && !$failed_headers) {
                show_result("PASS", $tested, $tested_file, '', $temp_filenames);
                return 'PASSED';
            }
        }
        $wanted_re = null;
    }
    // Test failed so we need to report details.
    if ($failed_headers) {
        $passed = false;
        $wanted = $wanted_headers . "\n--HEADERS--\n" . $wanted;
        $output = $output_headers . "\n--HEADERS--\n" . $output;
        if (isset($wanted_re)) {
            $wanted_re = preg_quote($wanted_headers . "\n--HEADERS--\n", '/') . $wanted_re;
        }
    }
    if ($leaked) {
        $restype[] = 'LEAK';
    }
    if ($warn) {
        $restype[] = 'WARN';
    }
    if (!$passed) {
        if (isset($section_text['XFAIL'])) {
            $restype[] = 'XFAIL';
        } else {
            $restype[] = 'FAIL';
        }
    }
    if (!$passed) {
        // write .exp
        if (strpos($log_format, 'E') !== false && file_put_contents($exp_filename, (string) $wanted, FILE_BINARY) === false) {
            error("Cannot create expected test output - {$exp_filename}");
        }
        // write .out
        if (strpos($log_format, 'O') !== false && file_put_contents($output_filename, (string) $output, FILE_BINARY) === false) {
            error("Cannot create test output - {$output_filename}");
        }
        // write .diff
        $diff = generate_diff($wanted, $wanted_re, $output);
        show_file_block('diff', $diff);
        if (strpos($log_format, 'D') !== false && file_put_contents($diff_filename, (string) $diff, FILE_BINARY) === false) {
            error("Cannot create test diff - {$diff_filename}");
        }
        // write .log
        if (strpos($log_format, 'L') !== false && file_put_contents($log_filename, "\n---- EXPECTED OUTPUT\n{$wanted}\n---- ACTUAL OUTPUT\n{$output}\n---- FAILED\n", FILE_BINARY) === false) {
            error("Cannot create test log - {$log_filename}");
            error_report($file, $log_filename, $tested);
        }
    }
    show_result(implode('&', $restype), $tested, $tested_file, $info, $temp_filenames);
    foreach ($restype as $type) {
        $PHP_FAILED_TESTS[$type . 'ED'][] = array('name' => $file, 'test_name' => (is_array($IN_REDIRECT) ? $IN_REDIRECT['via'] : '') . $tested . " [{$tested_file}]", 'output' => $output_filename, 'diff' => $diff_filename, 'info' => $info);
    }
    if (isset($old_php)) {
        $php = $old_php;
    }
    return $restype[0] . 'ED';
}
开发者ID:wgy0323,项目名称:ffmpeg-php,代码行数:101,代码来源:run-tests.php


示例3: run_test


//.........这里部分代码省略.........
         echo "OUTPUT: \n{$out}\n";
     }
     // Does the output match what is expected?
     $output = trim($out);
     $output = preg_replace('/\\r\\n/', "\n", $output);
     $failed = FALSE;
     if (isset($section_text['EXPECTF']) || isset($section_text['EXPECTREGEX'])) {
         if (isset($section_text['EXPECTF'])) {
             $wanted = $section_text['EXPECTF'];
         } else {
             $wanted = $section_text['EXPECTREGEX'];
         }
         $wanted_re = preg_replace('/\\r\\n/', "\n", $wanted);
         if (isset($section_text['EXPECTF'])) {
             $wanted_re = preg_quote($wanted_re, '/');
             // Stick to basics
             $wanted_re = str_replace("%s", ".+?", $wanted_re);
             //not greedy
             $wanted_re = str_replace("%i", "[+\\-]?[0-9]+", $wanted_re);
             $wanted_re = str_replace("%d", "[0-9]+", $wanted_re);
             $wanted_re = str_replace("%x", "[0-9a-fA-F]+", $wanted_re);
             $wanted_re = str_replace("%f", "[+\\-]?\\.?[0-9]+\\.?[0-9]*(E-?[0-9]+)?", $wanted_re);
             $wanted_re = str_replace("%c", ".", $wanted_re);
             // %f allows two points "-.0.0" but that is the best *simple* expression
         }
         /* DEBUG YOUR REGEX HERE
         			var_dump($wanted_re);
         			print(str_repeat('=', 80) . "\n");
         			var_dump($output);
         	*/
         $failed = !preg_match("/^{$wanted_re}\$/s", $output);
     }
     $skipexpect = false;
     if (!$failed && $this->conf['TEST_WEB'] && isset($section_text['EXPECTHEADERS'])) {
         $want = array();
         $lines = preg_split("/[\n\r]+/", $section_text['EXPECTHEADERS']);
         $wanted = '';
         foreach ($lines as $line) {
             if (strpos($line, ':') !== false) {
                 $line = explode(":", $line, 2);
                 $want[trim($line[0])] = trim($line[1]);
                 $wanted .= trim($line[0]) . ': ' . trim($line[1]) . "\n";
             }
         }
         $output = '';
         foreach ($want as $k => $v) {
             $output .= "{$k}: {$headers[$k]}\n";
             if (!isset($headers[$k]) || $headers[$k] != $v) {
                 $failed = TRUE;
             }
         }
         // different servers may do different things on non-200 results
         // for instance, IIS will deliver it's own error pages, so we
         // cannot expect to match up the EXPECT section.  We may however,
         // want to match EXPECT on more than 200 results, so this may
         // need to change later.
         $skipexpect = isset($headers['Status']) && $headers['Status'] != 200;
     }
     if (!$failed && !$skipexpect && isset($section_text['EXPECT'])) {
         $wanted = $section_text['EXPECT'];
         $wanted = preg_replace('/\\r\\n/', "\n", $wanted);
         $failed = 0 != strcmp($output, $wanted);
     }
     if (!$failed) {
         @unlink($tmp_file);
         $this->showstatus($tested, 'PASSED');
         return 'PASSED';
     }
     // Test failed so we need to report details.
     $this->showstatus($tested, 'FAILED');
     $this->failed_tests[] = array('name' => $file, 'test_name' => $tested, 'output' => ereg_replace('\\.phpt$', '.log', $file), 'diff' => ereg_replace('\\.phpt$', '.diff', $file));
     if ($this->conf['TEST_PHP_DETAILED']) {
         $this->writemsg(generate_diff($wanted, $output) . "\n");
     }
     // write .exp
     if (strpos($this->conf['TEST_PHP_LOG_FORMAT'], 'E') !== FALSE) {
         $logname = ereg_replace('\\.phpt$', '.exp', $file);
         save_to_file($logname, $wanted);
     }
     // write .out
     if (strpos($this->conf['TEST_PHP_LOG_FORMAT'], 'O') !== FALSE) {
         $logname = ereg_replace('\\.phpt$', '.out', $file);
         save_to_file($logname, $output);
     }
     // write .diff
     if (strpos($this->conf['TEST_PHP_LOG_FORMAT'], 'D') !== FALSE) {
         $logname = ereg_replace('\\.phpt$', '.diff', $file);
         save_to_file($logname, generate_diff($wanted, $output));
     }
     // write .log
     if (strpos($this->conf['TEST_PHP_LOG_FORMAT'], 'L') !== FALSE) {
         $logname = ereg_replace('\\.phpt$', '.log', $file);
         save_to_file($logname, "\n---- EXPECTED OUTPUT\n{$wanted}\n" . "---- ACTUAL OUTPUT\n{$output}\n" . "---- FAILED\n");
         // display emacs/msvc error output
         if (strpos($this->conf['TEST_PHP_LOG_FORMAT'], 'C') !== FALSE) {
             $this->error_report($file, $logname, $tested);
         }
     }
     return 'FAILED';
 }
开发者ID:browniebraun,项目名称:php-src,代码行数:101,代码来源:server-tests.php


示例4: run_test


//.........这里部分代码省略.........
    $out = system_with_timeout($cmd);
    if (!empty($section_text['ENV'])) {
        foreach (explode("\n", $section_text['ENV']) as $env) {
            $env = explode('=', $env);
            putenv($env[0] . '=');
        }
    }
    @unlink($tmp_post);
    // Does the output match what is expected?
    $output = trim($out);
    $output = preg_replace('/\\r\\n/', "\n", $output);
    /* when using CGI, strip the headers from the output */
    if (isset($old_php) && ($pos = strpos($output, "\n\n")) !== FALSE) {
        $output = substr($output, $pos + 2);
    }
    if (isset($section_text['EXPECTF']) || isset($section_text['EXPECTREGEX'])) {
        if (isset($section_text['EXPECTF'])) {
            $wanted = trim($section_text['EXPECTF']);
        } else {
            $wanted = trim($section_text['EXPECTREGEX']);
        }
        $wanted_re = preg_replace('/\\r\\n/', "\n", $wanted);
        if (isset($section_text['EXPECTF'])) {
            $wanted_re = preg_quote($wanted_re, '/');
            // Stick to basics
            $wanted_re = str_replace("%e", '\\' . DIRECTORY_SEPARATOR, $wanted_re);
            $wanted_re = str_replace("%s", ".+?", $wanted_re);
            //not greedy
            $wanted_re = str_replace("%i", "[+\\-]?[0-9]+", $wanted_re);
            $wanted_re = str_replace("%d", "[0-9]+", $wanted_re);
            $wanted_re = str_replace("%x", "[0-9a-fA-F]+", $wanted_re);
            $wanted_re = str_replace("%f", "[+\\-]?\\.?[0-9]+\\.?[0-9]*(E-?[0-9]+)?", $wanted_re);
            $wanted_re = str_replace("%c", ".", $wanted_re);
            // %f allows two points "-.0.0" but that is the best *simple* expression
        }
        /* DEBUG YOUR REGEX HERE
        		var_dump($wanted_re);
        		print(str_repeat('=', 80) . "\n");
        		var_dump($output);
        */
        if (preg_match("/^{$wanted_re}\$/s", $output)) {
            @unlink($tmp_file);
            echo "PASS {$tested}\n";
            if (isset($old_php)) {
                $php = $old_php;
            }
            return 'PASSED';
        }
    } else {
        $wanted = trim($section_text['EXPECT']);
        $wanted = preg_replace('/\\r\\n/', "\n", $wanted);
        // compare and leave on success
        $ok = 0 == strcmp($output, $wanted);
        if ($ok) {
            @unlink($tmp_file);
            echo "PASS {$tested}\n";
            if (isset($old_php)) {
                $php = $old_php;
            }
            return 'PASSED';
        }
        $wanted_re = NULL;
    }
    // Test failed so we need to report details.
    if ($warn) {
        echo "WARN {$tested}{$info}\n";
    } else {
        echo "FAIL {$tested}{$info}\n";
    }
    $PHP_FAILED_TESTS['FAILED'][] = array('name' => $file, 'test_name' => (is_array($IN_REDIRECT) ? $IN_REDIRECT['via'] : '') . $tested, 'output' => $output_filename, 'diff' => $diff_filename, 'info' => $info);
    // write .exp
    if (strpos($log_format, 'E') !== FALSE) {
        $log = fopen($exp_filename, 'w') or error("Cannot create test log - {$exp_filename}");
        fwrite($log, $wanted);
        fclose($log);
    }
    // write .out
    if (strpos($log_format, 'O') !== FALSE) {
        $log = fopen($output_filename, 'w') or error("Cannot create test log - {$output_filename}");
        fwrite($log, $output);
        fclose($log);
    }
    // write .diff
    if (strpos($log_format, 'D') !== FALSE) {
        $log = fopen($diff_filename, 'w') or error("Cannot create test log - {$diff_filename}");
        fwrite($log, generate_diff($wanted, $wanted_re, $output));
        fclose($log);
    }
    // write .log
    if (strpos($log_format, 'L') !== FALSE) {
        $log = fopen($log_filename, 'w') or error("Cannot create test log - {$log_filename}");
        fwrite($log, "\n---- EXPECTED OUTPUT\n{$wanted}\n---- ACTUAL OUTPUT\n{$output}\n---- FAILED\n");
        fclose($log);
        error_report($file, $log_filename, $tested);
    }
    if (isset($old_php)) {
        $php = $old_php;
    }
    return $warn ? 'WARNED' : 'FAILED';
}
开发者ID:BackupTheBerlios,项目名称:php-qt-svn,代码行数:101,代码来源:run-tests.php


示例5: run_test


//.........这里部分代码省略.........
            $length = strlen($wanted_re);
            while ($startOffset < $length) {
                $start = strpos($wanted_re, $r, $startOffset);
                if ($start !== false) {
                    // we have found a start tag
                    $end = strpos($wanted_re, $r, $start + 2);
                    if ($end === false) {
                        // unbalanced tag, ignore it.
                        $end = $start = $length;
                    }
                } else {
                    // no more %r sections
                    $start = $end = $length;
                }
                // quote a non re portion of the string
                $temp = $temp . preg_quote(substr($wanted_re, $startOffset, $start - $startOffset), '/');
                // add the re unquoted.
                if ($end > $start) {
                    $temp = $temp . '(' . substr($wanted_re, $start + 2, $end - $start - 2) . ')';
                }
                $startOffset = $end + 2;
            }
            $wanted_re = $temp;
            $wanted_re = str_replace(array('%binary_string_optional%'), version_compare(PHP_VERSION, '6.0.0-dev') == -1 ? 'string' : 'binary string', $wanted_re);
            $wanted_re = str_replace(array('%unicode_string_optional%'), version_compare(PHP_VERSION, '6.0.0-dev') == -1 ? 'string' : 'Unicode string', $wanted_re);
            $wanted_re = str_replace(array('%unicode\\|string%', '%string\\|unicode%'), version_compare(PHP_VERSION, '6.0.0-dev') == -1 ? 'string' : 'unicode', $wanted_re);
            $wanted_re = str_replace(array('%u\\|b%', '%b\\|u%'), version_compare(PHP_VERSION, '6.0.0-dev') == -1 ? '' : 'u', $wanted_re);
            // Stick to basics
            $wanted_re = str_replace('%e', '\\' . '\\', $wanted_re);
            $wanted_re = str_replace('%s', '[^\\r\\n]+', $wanted_re);
            $wanted_re = str_replace('%S', '[^\\r\\n]*', $wanted_re);
            $wanted_re = str_replace('%a', '.+', $wanted_re);
            $wanted_re = str_replace('%A', '.*', $wanted_re);
            $wanted_re = str_replace('%w', '\\s*', $wanted_re);
            $wanted_re = str_replace('%i', '[+-]?\\d+', $wanted_re);
            $wanted_re = str_replace('%d', '\\d+', $wanted_re);
            $wanted_re = str_replace('%x', '[0-9a-fA-F]+', $wanted_re);
            $wanted_re = str_replace('%f', '[+-]?\\.?\\d+\\.?\\d*(?:[Ee][+-]?\\d+)?', $wanted_re);
            $wanted_re = str_replace('%c', '.', $wanted_re);
            // %f allows two points "-.0.0" but that is the best *simple* expression
        }
        /* DEBUG YOUR REGEX HERE
        		var_dump($wanted_re);
        		print(str_repeat('=', 80) . "\n");
        		var_dump($output);
        */
        if (preg_match("/^{$wanted_re}\$/s", $output)) {
            @unlink($phpfile);
            show_result("<span class='pass'>PASS</span>", "{$file}", '');
        }
    } else {
        $wanted = (string) trim($section_text['EXPECT']);
        $wanted = preg_replace('/\\r\\n/', "\n", $wanted);
        // compare and leave on success
        if (!strcmp($output, $wanted)) {
            @unlink($phpfile);
            show_result("<span class='pass'>PASS</span>", $file, '');
        }
        $wanted_re = null;
    }
    // Test failed so we need to report details.
    if ($failed_headers) {
        $passed = false;
        $wanted = (string) $wanted_headers . "\n--HEADERS--\n" . (string) $wanted;
        $output = (string) $output_headers . "\n--HEADERS--\n" . (string) $output;
        if (isset($wanted_re)) {
            $wanted_re = preg_quote($wanted_headers . "\n--HEADERS--\n", '/') . $wanted_re;
        }
    }
    // write .exp
    if (file_put_contents($file . '.exp', (string) $wanted, FILE_BINARY) === false) {
        error("Cannot create expected test output '{$file}.exp'");
    }
    // write .out
    if (file_put_contents($file . '.out', (string) $output, FILE_BINARY) === false) {
        error("Cannot create test output - '{$file}.out'");
    }
    // write .diff
    $diff = generate_diff($wanted, $wanted_re, $output);
    if (file_put_contents($file . '.diff', (string) $diff, FILE_BINARY) === false) {
        error("Cannot create test diff - '{$file}.diff'");
    }
    $resultid = "result_" . strlen($phpfile) . '_' . crc32($phpfile);
    $sourceid = "source_" . strlen($phpfile) . '_' . crc32($phpfile);
    show_result("<span class='fail'>FAIL</span>", $file, ", <a href='{$phpfile}' target='_blank'>Try the script</a>" . ", <a href='#' onclick='\$(\"#{$sourceid}\").slideToggle();return false;'>source</a>" . ", <a href='#' onclick='\$(\"#{$resultid}\").slideToggle();return false;'>details</a>" . "<div id='{$sourceid}' style='display:none;background:#eee;border:1px dashed #888;'><pre>" . htmlspecialchars(trim(_file_get_contents($file, false, null, &$dummyheaders))) . "</pre></div>" . "<div id='{$resultid}' style='display:none;'><table border='1'><tr><td><b>Output</b><br/><pre style='background:#fee;font-size:8px;'>" . htmlspecialchars($output) . "</pre></td><td><b>Expected</b><br/><pre  style='background:#efe;font-size:8px;'>" . htmlspecialchars($wanted) . "</pre></td></tr></table></div>");
    // write .sh
    //if (strpos($log_format, 'S') !== false && file_put_contents($sh_filename, b"#!/bin/sh{$cmd}", FILE_BINARY) === false) {
    //error("Cannot create test shell script - $sh_filename");
    //}
    //chmod($sh_filename, 0755);
    /*foreach ($restype as $type) {
    		$PHP_FAILED_TESTS[$type.'ED'][] = array (
    			'name'      => $file,
    			'test_name' => (is_array($IN_REDIRECT) ? $IN_REDIRECT['via'] : '') . $tested . " [$tested_file]",
    			'output'    => $output_filename,
    			'diff'      => $diff_filename,
    			'info'      => $info,
    		);
    	}*/
}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:101,代码来源:index.php


示例6: run_test


//.........这里部分代码省略.........
    }
    if (DETAILED) {
        echo "\nCONTENT_LENGTH  = " . getenv("CONTENT_LENGTH") . "\nCONTENT_TYPE    = " . getenv("CONTENT_TYPE") . "\nPATH_TRANSLATED = " . getenv("PATH_TRANSLATED") . "\nQUERY_STRING    = " . getenv("QUERY_STRING") . "\nREDIRECT_STATUS = " . getenv("REDIRECT_STATUS") . "\nREQUEST_METHOD  = " . getenv("REQUEST_METHOD") . "\nSCRIPT_FILENAME = " . getenv("SCRIPT_FILENAME") . "\nCOMMAND {$cmd}\n";
    }
    $out = `{$cmd}`;
    @unlink($tmp_post);
    // Does the output match what is expected?
    $output = trim($out);
    $output = preg_replace('/\\r\\n/', "\n", $output);
    /* when using CGI, strip the headers from the output */
    if (isset($old_php) && ($pos = strpos($output, "\n\n")) !== FALSE) {
        $output = substr($output, $pos + 2);
    }
    if (isset($section_text['EXPECTF']) || isset($section_text['EXPECTREGEX'])) {
        if (isset($section_text['EXPECTF'])) {
            $wanted = trim($section_text['EXPECTF']);
        } else {
            $wanted = trim($section_text['EXPECTREGEX']);
        }
        $wanted_re = preg_replace('/\\r\\n/', "\n", $wanted);
        if (isset($section_text['EXPECTF'])) {
            $wanted_re = preg_quote($wanted_re, '/');
            // Stick to basics
            $wanted_re = str_replace("%s", ".+?", $wanted_re);
            //not greedy
            $wanted_re = str_replace("%i", "[+\\-]?[0-9]+", $wanted_re);
            $wanted_re = str_replace("%d", "[0-9]+", $wanted_re);
            $wanted_re = str_replace("%x", "[0-9a-fA-F]+", $wanted_re);
            $wanted_re = str_replace("%f", "[+\\-]?\\.?[0-9]+\\.?[0-9]*(E-?[0-9]+)?", $wanted_re);
            $wanted_re = str_replace("%c", ".", $wanted_re);
            // %f allows two points "-.0.0" but that is the best *simple* expression
        }
        /* DEBUG YOUR REGEX HERE
        		var_dump($wanted_re);
        		print(str_repeat('=', 80) . "\n");
        		var_dump($output);
        */
        if (preg_match("/^{$wanted_re}\$/s", $output)) {
            @unlink($tmp_file);
            echo "PASS {$tested}{$info}\n";
            if (isset($old_php)) {
                $php = $old_php;
            }
            return 'PASSED';
        }
    } else {
        $wanted = trim($section_text['EXPECT']);
        $wanted = preg_replace('/\\r\\n/', "\n", $wanted);
        // compare and leave on success
        $ok = 0 == strcmp($output, $wanted);
        if ($ok) {
            @unlink($tmp_file);
            echo "PASS {$tested}{$info}\n";
            if (isset($old_php)) {
                $php = $old_php;
            }
            return 'PASSED';
        }
    }
    // Test failed so we need to report details.
    if ($warn) {
        echo "WARN {$tested}{$info}\n";
    } else {
        echo "FAIL {$tested}{$info}\n";
    }
    $GLOBALS['__PHP_FAILED_TESTS__'][] = array('name' => $file, 'test_name' => $tested, 'output' => ereg_replace('\\.phpt$', '.log', $file), 'diff' => ereg_replace('\\.phpt$', '.diff', $file), 'info' => $info);
    // write .exp
    if (strpos($log_format, 'E') !== FALSE) {
        $logname = ereg_replace('\\.phpt$', '.exp', $file);
        $log = fopen($logname, 'w') or error("Cannot create test log - {$logname}");
        fwrite($log, $wanted);
        fclose($log);
    }
    // write .out
    if (strpos($log_format, 'O') !== FALSE) {
        $logname = ereg_replace('\\.phpt$', '.out', $file);
        $log = fopen($logname, 'w') or error("Cannot create test log - {$logname}");
        fwrite($log, $output);
        fclose($log);
    }
    // write .diff
    if (strpos($log_format, 'D') !== FALSE) {
        $logname = ereg_replace('\\.phpt$', '.diff', $file);
        $log = fopen($logname, 'w') or error("Cannot create test log - {$logname}");
        fwrite($log, generate_diff($wanted, $output));
        fclose($log);
    }
    // write .log
    if (strpos($log_format, 'L') !== FALSE) {
        $logname = ereg_replace('\\.phpt$', '.log', $file);
        $log = fopen($logname, 'w') or error("Cannot create test log - {$logname}");
        fwrite($log, "\n---- EXPECTED OUTPUT\n{$wanted}\n---- ACTUAL OUTPUT\n{$output}\n---- FAILED\n");
        fclose($log);
        error_report($file, $logname, $tested);
    }
    if (isset($old_php)) {
        $php = $old_php;
    }
    return $warn ? 'WARNED' : 'FAILED';
}
开发者ID:OTiZ,项目名称:osx,代码行数:101,代码来源:run-tests.php


示例7: run_test


//.........这里部分代码省略.........
    // Does the output match what is expected?
    $output = str_replace("\r\n", "\n", trim($out));
    /* when using CGI, strip the headers from the output */
    if (isset($old_php) && ($pos = strpos($output, "\n\n")) !== FALSE) {
        $output = substr($output, $pos + 2);
    }
    if (isset($section_text['EXPECTF']) || isset($section_text['EXPECTREGEX'])) {
        if (isset($section_text['EXPECTF'])) {
            $wanted = trim($section_text['EXPECTF']);
        } else {
            $wanted = trim($section_text['EXPECTREGEX']);
        }
        $wanted_re = preg_replace('/\\r\\n/', "\n", $wanted);
        if (isset($section_text['EXPECTF'])) {
            $wanted_re = preg_quote($wanted_re, '/');
            // Stick to basics
            $wanted_re = str_replace("%e", '\\' . DIRECTORY_SEPARATOR, $wanted_re);
            $wanted_re = str_replace("%s", ".+?", $wanted_re);
            //not greedy
            $wanted_re = str_replace("%w", "\\s*", $wanted_re);
            $wanted_re = str_replace("%i", "[+\\-]?[0-9]+", $wanted_re);
            $wanted_re = str_replace("%d", "[0-9]+", $wanted_re);
            $wanted_re = str_replace("%x", "[0-9a-fA-F]+", $wanted_re);
            $wanted_re = str_replace("%f", "[+\\-]?\\.?[0-9]+\\.?[0-9]*(E-?[0-9]+)?", $wanted_re);
            $wanted_re = str_replace("%c", ".", $wanted_re);
            // %f allows two points "-.0.0" but that is the best *simple* expression
        }
        /* DEBUG YOUR REGEX HERE
        		var_dump($wanted_re);
        		print(str_repeat('=', 80) . "\n");
        		var_dump($output);
        */
        if (preg_match("/^{$wanted_re}\$/s", $output)) {
            $passed = true;
            if (!$cfg['keep']['php']) {
                @unlink($test_file);
            }
            if (isset($old_php)) {
                $php = $old_php;
            }
            if (!$leaked) {
                show_result("PASS", $tested, $tested_file, '', $temp_filenames);
                return 'PASSED';
            }
        }
    } else {
        $wanted = trim($section_text['EXPECT']);
        $wanted = preg_replace('/\\r\\n/', "\n", $wanted);
        // compare and leave on success
        if (!strcmp($output, $wanted)) {
            $passed = true;
            if (!$cfg['keep']['php']) {
                @unlink($test_file);
            }
            if (isset($old_php)) {
                $php = $old_php;
            }
            if (!$leaked) {
                show_result("PASS", $tested, $tested_file, '', $temp_filenames);
                return 'PASSED';
            }
        }
        $wanted_re = NULL;
    }
    // Test failed so we need to report details.
    if ($leaked) {
        $restype = 'LEAK';
    } else {
        if ($warn) {
            $restype = 'WARN';
        } else {
            $restype = 'FAIL';
        }
    }
    if (!$passed) {
        // write .exp
        if (strpos($log_format, 'E') !== FALSE && file_put_contents($exp_filename, $wanted) === FALSE) {
            error("Cannot create expected test output - {$exp_filename}");
        }
        // write .out
        if (strpos($log_format, 'O') !== FALSE && file_put_contents($output_filename, $output) === FALSE) {
            error("Cannot create test output - {$output_filename}");
        }
        // write .diff
        if (strpos($log_format, 'D') !== FALSE && file_put_contents($diff_filename, generate_diff($wanted, $wanted_re, $output)) === FALSE) {
            error("Cannot create test diff - {$diff_filename}");
        }
        // write .log
        if (strpos($log_format, 'L') !== FALSE && file_put_contents($log_filename, "\n---- EXPECTED OUTPUT\n{$wanted}\n---- ACTUAL OUTPUT\n{$output}\n---- FAILED\n") === FALSE) {
            error("Cannot create test log - {$log_filename}");
            error_report($file, $log_filename, $tested);
        }
    }
    show_result($restype, $tested, $tested_file, $info, $temp_filenames);
    $PHP_FAILED_TESTS[$restype . 'ED'][] = array('name' => $file, 'test_name' => (is_array($IN_REDIRECT) ? $IN_REDIRECT['via'] : '') . $tested . " [{$tested_file}]", 'output' => $output_filename, 'diff' => $diff_filename, 'info' => $info);
    if (isset($old_php)) {
        $php = $old_php;
    }
    return $restype . 'ED';
}
开发者ID:akhan786,项目名称:LaunchDevelopment,代码行数:101,代码来源:run-tests.php



注:本文中的generate_diff函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP generate_display_field函数代码示例发布时间:2022-05-15
下一篇:
PHP generate_device_url函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap