Skip to content

Commit

Permalink
Fix PHP tests. TODO(hkarau): Add support for notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
holdenk committed Sep 16, 2013
1 parent 2a9837a commit 3bc4a6f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -23,6 +23,7 @@ auto-save-list
tramp
.\#*
*.pyc
3rdparty
# Org-mode
.org-id-locations
*_archive
9 changes: 9 additions & 0 deletions README
@@ -1,3 +1,12 @@

Requirements:
* Ocaml >= 4
* opam (if not installed might result in The constructor Tpat_construct expects 4 argument(s), but is applied here to 5 argument(s))
* Recent[ish] version of Perl 5 (was built against 5.14.2)
- Perl depdencies are brought in through the make file
* Recent[ish] version of Python (was built against 2.7.3)
* pfff [auto installed under 3rd party]
*
A very simple github bot. Uses an accout of the same name. It provides spelling corrections for README files and other simple suggestions.
Requires pfff & php for the php code fixing to work.
The current method it works is find_targets[*].pl finds possible files on github that might have something we could do to them.
Expand Down
12 changes: 7 additions & 5 deletions backend/Unicorn/PHP.pm
Expand Up @@ -4,8 +4,9 @@ use File::Basename;
use File::Slurp qw (slurp);

my $spatchexec = "./bin/php_spatch";
my $phpFunctionDir = "./php_functions/";
my $spatchdir = "php_spatches";
my $phpFunctionDir = "./php/functions/";
my $spatchDir = "./php/spatches";
my $spatchVerifyDir = "./php/spatches_verify_only";

sub check_php {
my $file = shift @_;
Expand All @@ -16,14 +17,15 @@ sub check_php {
}
return 0;
}

sub fix_php {
my $file = shift @_;
#Run the spatches
opendir (my $spatch_files, "$spatchdir") || "can't opendir $!\n";
opendir (my $spatch_files, "$spatchDir") || "can't opendir $!\n";
while (my $spatch_file = readdir($spatch_files)) {
chomp ($spatch_file);
if (-f $spatchdir."/".$spatch_file && $spatch_file =~ /\.spatch$/) {
`$spatchexec --apply-patch -f $spatchdir/$spatch_file $file`;
if (-f $spatchDir."/".$spatch_file && $spatch_file =~ /\.spatch$/) {
`$spatchexec --apply-patch -f $spatchDir/$spatch_file $file`;
}
}
closedir($spatch_files);
Expand Down
5 changes: 1 addition & 4 deletions backend/t/PHP.t
@@ -1,5 +1,5 @@
#Test the php script thing
use Test::More tests => 4;
use Test::More tests => 3;
use File::Temp;
use Unicorn::PHP qw(fix_php check_php);
use File::Slurp qw (slurp);
Expand Down Expand Up @@ -27,9 +27,6 @@ while (my $file = readdir($php_input_files)) {
slurp("$dirname/php_evaluated/$file.out"));
is(slurp("$dirname/php_output/$file"),
slurp("$dirname/php_expected/$file"));
#Make sure we git added the file
my $gstatus = `cd $dirname/php_output;git status`;
is($gstatus =~ /new file:\s*magicSecureStringCompare\.php/,1);
}
}

Expand Down
8 changes: 4 additions & 4 deletions backend/t/php_expected/a.php
@@ -1,7 +1,7 @@
<?
include_once("magicSecureStringCompare.php");
$a = explode("www", "coffeewwwpandas",1);
$b= explode("/www/", "coffeewwwpandas");
$q = explode("www", "coffeewwwpandas");
$b= split("/www/", "coffeewwwpandas");
$c = preg_split("/www/i", "coffeewwwpandas");
$d = spliti("www", "coffeewwwpandas",1);
print $a[0];
Expand All @@ -12,11 +12,11 @@
$date = "04/30/1973";
list($month, $day, $year) = split('[/.-]', $date);
echo "Month: $month; Day: $day; Year: $year<br />\n";
if (magicSecureStringCompare(hash_hmac("md5",$date,"panda"),$date)) {
if (hash_hmac("md5",$date,"panda") == $date) {
echo "sad pandas\n";
}
$date_md5_hmac = hash_hmac("md5",$date,"panda");
if (magicSecureStringCompare(hash_hmac("md5",$date,"panda"),$date_md5_hmac)) {
if (hash_hmac("md5",$date,"panda") == $date_md5_hmac) {
echo "happy pandas\n";
}
?>
1 change: 1 addition & 0 deletions backend/t/php_input/a.php
@@ -1,5 +1,6 @@
<?
$a = split("www", "coffeewwwpandas",1);
$q = split("www", "coffeewwwpandas");
$b= split("/www/", "coffeewwwpandas");
$c = preg_split("/www/i", "coffeewwwpandas");
$d = spliti("www", "coffeewwwpandas",1);
Expand Down

0 comments on commit 3bc4a6f

Please sign in to comment.