2011-03-06 08:11:20 +01:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2011-03-06 17:23:03 +01:00
|
|
|
use Test::More tests => 2;
|
2011-03-06 08:15:06 +01:00
|
|
|
use Text::Diff;
|
2011-03-06 08:11:20 +01:00
|
|
|
|
|
|
|
sub shell (@);
|
|
|
|
sub cd ($);
|
|
|
|
|
|
|
|
my $ver = `bash util/ver`;
|
|
|
|
chomp $ver;
|
|
|
|
|
2011-03-06 17:11:15 +01:00
|
|
|
#shell "make";
|
2011-03-06 08:11:20 +01:00
|
|
|
|
|
|
|
cd "ngx_openresty-$ver";
|
|
|
|
|
2011-03-06 17:23:03 +01:00
|
|
|
{
|
|
|
|
shell "./configure --help > help.txt 2>&1";
|
2011-03-06 08:11:20 +01:00
|
|
|
|
2011-03-06 17:23:03 +01:00
|
|
|
open my $in, "help.txt" or
|
|
|
|
die "Cannot open help.txt for reading: $!\n";
|
|
|
|
my $got = do { local $/; <$in> };
|
|
|
|
close $in;
|
2011-03-06 08:11:20 +01:00
|
|
|
|
2011-03-06 17:23:03 +01:00
|
|
|
open $in, "../t/help.txt" or
|
|
|
|
die "Cannot open ../t/help.txt for reading: $!\n";
|
|
|
|
my $expected = do { local $/; <$in> };
|
|
|
|
close $in;
|
|
|
|
|
|
|
|
is_diff($got, $expected, "--help ok");
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
shell "./configure --dry-run > default.txt 2>&1";
|
|
|
|
open my $in, "default.txt" or
|
|
|
|
die "Cannot open default.txt for reading: $!\n";
|
|
|
|
my $got = do { local $/; <$in> };
|
|
|
|
close $in;
|
|
|
|
|
|
|
|
open $in, "../t/default.txt" or
|
|
|
|
die "Cannot open ../t/default.txt for reading: $!\n";
|
|
|
|
my $expected = do { local $/; <$in> };
|
|
|
|
close $in;
|
|
|
|
|
|
|
|
is_diff($got, $expected, "default configure ok");
|
|
|
|
}
|
2011-03-06 08:11:20 +01:00
|
|
|
|
|
|
|
sub shell (@) {
|
|
|
|
print "@_\n";
|
|
|
|
system(@_) == 0 or die "failed to run command @_\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub cd ($) {
|
|
|
|
my $dir = shift;
|
|
|
|
print("cd $dir\n");
|
|
|
|
chdir $dir or die "failed to cd $dir: $!\n";
|
|
|
|
}
|
|
|
|
|
2011-03-06 08:15:06 +01:00
|
|
|
sub is_diff {
|
|
|
|
my ($actual, $expected, $name) = @_;
|
|
|
|
|
|
|
|
if (!defined $name) {
|
|
|
|
$name = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
ok $actual eq $expected,
|
|
|
|
$name . "\n" . Text::Diff::diff(\$expected, \$actual);
|
|
|
|
}
|
|
|
|
|