fix parser tests

I was quite stupid in my rewrite and totally broke this. Wow, it runs fast!

I had to switch to `HHVM_BIN` as the env var, since it seems we force `HHVM` to 1 all the time...
Esse commit está contido em:
Paul Tarjan
2013-06-03 14:34:19 -07:00
commit de Sara Golemon
commit 9519cefd00
3 arquivos alterados com 70 adições e 33 exclusões
+8 -2
Ver Arquivo
@@ -226,7 +226,7 @@ function mode_cmd($options) {
function hhvm_cmd($options, $test) {
$cmd = implode(" ", array(
idx_file($_ENV, 'HHVM', bin_root().'/hphp/hhvm/hhvm'),
idx_file($_ENV, 'HHVM_BIN', bin_root().'/hphp/hhvm/hhvm'),
'--config',
find_config($test, 'config.hdf'),
mode_cmd($options),
@@ -243,7 +243,7 @@ function hhvm_cmd($options, $test) {
function hphp_cmd($options, $test) {
return implode(" ", array(
idx_file($_ENV, 'HPHP', bin_root().'/hphp/hhvm/hphp'),
idx_file($_ENV, 'HPHP_BIN', bin_root().'/hphp/hhvm/hphp'),
'--config',
find_config($test, 'hphp_config.hdf'),
read_file("$test.hphp_opts"),
@@ -388,6 +388,12 @@ function run_test($options, $test) {
file_put_contents("$test.out", $output);
// Needed for testing non-hhvm binaries that don't actually run the code
// e.g. util/parser/test/parse_tester.cpp
if ($output == "FORCE PASS") {
return true;
}
if (file_exists("$test.expect")) {
$diff_cmds = "--text -u";
exec("diff --text -u $test.expect $test.out > $test.diff 2>&1", $_, $status);
+25 -31
Ver Arquivo
@@ -34,42 +34,36 @@ namespace HPHP { namespace Test {
* If a parse error occurs, it says why.
*/
int main(int argc, char** argv) try {
if (argc >= 2 && !strcmp(argv[1], "--verify")) {
HPHP::Test::g_verifyMode = true;
--argc, ++argv;
}
HPHP::Test::g_verifyMode = true;
if (argc != 2) {
std::cerr << "usage: " << argv[0] << " [--verify] filename\n";
std::exit(1);
}
std::ifstream in(argv[1]);
if (!in.is_open()) {
std::cerr << argv[0] << ": couldn't open file: "
<< strerror(errno) << '\n';
}
std::cout << "1..1\n";
try {
using HPHP::Scanner;
using HPHP::Test::Parser;
Scanner scan(in, Scanner::AllowShortTags |
Scanner::AllowHipHopSyntax);
Parser parser(scan, argv[1]);
parser.parse();
} catch (const std::exception& e) {
if (HPHP::Test::g_verifyMode) {
std::cout << "not ";
} else {
throw;
char* filename = nullptr;
for (int i = 1; i < argc - 1; i++) {
if (!strcmp(argv[i], "--file")) {
filename = argv[i+1];
}
}
std::cout << "ok 1\n";
if (filename == nullptr) {
std::cerr << argv[0] << ": no --file 'filename' passed" << '\n';
return 1;
}
std::ifstream in(filename);
if (!in.is_open()) {
std::cerr << argv[0] << ": couldn't open file " << filename << " "
<< strerror(errno) << '\n';
return 1;
}
using HPHP::Scanner;
using HPHP::Test::Parser;
Scanner scan(in, Scanner::AllowShortTags |
Scanner::AllowHipHopSyntax);
Parser parser(scan, argv[1]);
parser.parse();
std::cout << "FORCE PASS";
}
catch (const std::runtime_error& e) {
catch (const std::exception& e) {
std::cerr << argv[0] << ": " << e.what() << '\n';
return 1;
}
+37
Ver Arquivo
@@ -0,0 +1,37 @@
#!/bin/bash
#
# Run verify checking only parsing works as expected.
#
# Usage:
#
# % fbconfig hphp/util/parser/test && fbmake dbg && \
# ./hphp/util/parser/test/run_verify_parse.sh
#
HPHP_HOME=$(git rev-parse --show-toplevel)
: ${FBMAKE_BIN_ROOT=_bin}
cd $HPHP_HOME
VERIFY_SCRIPT=./hphp/test/run
HHVM_BIN=$FBMAKE_BIN_ROOT/hphp/util/parser/test/parse_tester
# some tests are expected not to parse
PARSE_SKIP='dv_i0.php hh_bad_end.php hh_bad_start.php hh_numbers.php
strict_bad_end.php strict_bad_start.php
strict_numbers.php syntax-error.php xhp-malformed.php Xhp.php
trailing_comma_bad1.php trailing_comma_bad2.php trailing_comma_bad3.php
trailing_comma_bad4.php trailing_comma_bad5.php trailing_comma_bad6.php'
PARSE_SKIP="$PARSE_SKIP $(cd hphp/test/quick && ls parse_fail_*.php)"
######################################################################
skip_list=
for x in $PARSE_SKIP ; do
skip_list="$skip_list hphp/test/quick/$x"
done
qtests=$(comm -23 \
<(find hphp/test/quick -maxdepth 1 -name \*.php | sort) \
<(echo $skip_list|sed -e 's/ /\n/g'|sort))
HHVM_BIN=$HHVM_BIN $VERIFY_SCRIPT $qtests