1
0
mirror of https://github.com/openresty/openresty synced 2024-11-09 18:35:51 +01:00
openresty/t/sanity.t

52 lines
924 B
Perl
Raw Normal View History

use strict;
use warnings;
use Test::More tests => 1;
2011-03-06 08:15:06 +01:00
use Text::Diff;
sub shell (@);
sub cd ($);
my $ver = `bash util/ver`;
chomp $ver;
shell "make";
cd "ngx_openresty-$ver";
shell "./configure --help > help.txt";
open my $in, "help.txt" or
die "Cannot open help.txt for reading: $!\n";
my $got = do { local $/; <$in> };
close $in;
open $in, "../t/help.txt" or
die "Cannot open ../t/help.txt for reading: $!\n";
my $expected = do { local $/; <$in> };
close $in;
2011-03-06 08:15:06 +01:00
is_diff($got, $expected, "--help ok");
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);
}