package JQPTest; BEGIN { use vars qw($VERSION); chomp($VERSION = `cat ../../VERSION.txt`); $VERSION =~ s/^v//; $VERSION =~ s/_/./g; #print "$VERSION\n"; } use warnings; use strict; my $exe = "scripts/jqp"; # we get the binary copied here, so it gets into blib/.. for testing my $delete_tmp_files = 0; sub get_parsed_query { my $query = shift; my $outfile = "/tmp/jqpout.$$.tmp"; my $infile = "/tmp/jqpin.$$.tmp"; open(FILE, "> $infile") || die "Can't open $infile: $!"; print FILE $query; close(FILE) || die "Couldn't close $infile: $!"; unlink($infile) if $delete_tmp_files; die "$0: Can't find exe $exe" unless -x $exe; my $cmd = "$exe 2>&1 < $infile > $outfile"; my @ret = `$cmd`; # abuse of backticks, I know open( FILE, $outfile) || die "Can't read $outfile: $!"; my @lines = ; close(FILE) || die "Couldn't close $outfile: $!"; unlink($outfile) if $delete_tmp_files; #print @lines; chomp(@lines); #print "For '$query': got '$lines[-1]'\n"; return $lines[-1]; # the last line } =pod =head1 NAME JQPTest - Tests jpq one directory above =head1 Synopsis Tests jpq (Josh's Query Parser) one directory above =head1 Export =head2 get_parsed_query Returns the output from ../jpq on the given query =head1 None =head1 Author joshr, C<< >> =head1 Bugs =head1 Copyright & License Copyright 2005 joshr, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of JQPTest