#! /usr/local/bin/perl -w
sub
test_harness;
my
$here
= dirname ($0);
my
$test_dir
=
$here
.
'/tests'
;
my
@lib_dirs
= (
$here
.
'/blib/lib'
,
$here
.
'/blib/arch'
);
local
*DIR
;
opendir
DIR,
$test_dir
or
die
"cannot open test directory '$test_dir': $!"
;
@ARGV
=
sort
map
$test_dir
.
'/'
.
$_
,
grep
/\.t$/,
readdir
DIR;
closedir
DIR;
eval
{
};
unless
($@) {
print
"# Encode revision used is $Encode::VERSION.\n"
;
}
test_harness (
$ENV
{TEST_HARNESS} || 0,
@lib_dirs
);
sub
test_harness
{
$Test::Harness::verbose
=
shift
;
local
@INC
=
@INC
;
unshift
@INC
,
map
{ File::Spec->rel2abs(
$_
) }
@_
;
my
$name
= $0;
$name
=~ s,test\.pl$,xs_disabled,;
local
*HANDLE
;
open
HANDLE,
"<$name"
or
die
"cannot open '$name': $!"
;
my
$xs_disabled
= <HANDLE>;
close
HANDLE;
eval
{
POSIX::setlocale(POSIX::LC_ALL());
};
my
$has_locales
= !$@;
if
(!
$has_locales
) {
$xs_disabled
= 1;
print
<<EOF;
The translation features of libintl-perl cannot be tested on your system
because it lacks locale support.
EOF
}
if
(!
$xs_disabled
&& !
$ENV
{TEST_LIBINTL_PERL_XS_VERSION}) {
$xs_disabled
= 1;
print
<<EOF;
The XS version of libintl-perl will normally not be tested extensively
because it depends on local configurations not under control of the module
installation. You can enable them by setting the environment variable
"TEST_LIBINTL_PERL_XS_VERSION" to a Perl truth variable.
EOF
}
if
(!
$xs_disabled
&&
$has_locales
) {
Locale::Messages::nl_putenv (
"LANGUAGE=de_AT"
);
Locale::Messages::nl_putenv (
"LC_ALL=de_AT"
);
Locale::Messages::nl_putenv (
"LANG=de_AT"
);
Locale::Messages::nl_putenv (
"LC_MESSAGES=de_AT"
);
Locale::Messages::nl_putenv (
"OUTPUT_CHARSET=iso-8859-1"
);
my
$has_de_locale
= POSIX::setlocale (POSIX::LC_ALL() =>
''
);
unless
(
$has_de_locale
) {
$has_de_locale
=
Locale::Util::set_locale (POSIX::LC_ALL(),
'de'
);
undef
$has_de_locale
unless
(
$has_de_locale
&&
$has_de_locale
=~ /(?:germany|de)/i);
}
unless
(
$has_de_locale
) {
$xs_disabled
= 1;
print
<<EOF;
The translation features of libintl-perl cannot be tested on your
system because the locale definitions for German do not exist.
EOF
}
$xs_disabled
= !
$has_de_locale
;
}
if
(!
$has_locales
) {
Test::Harness::runtests (
grep
{ ! /0[34][a-z_]+_(?:pp|xs)\.t$/ }
sort
{
lc
$a
cmp
lc
$b
}
@ARGV
);
}
elsif
(
$xs_disabled
) {
Test::Harness::runtests (
grep
{ ! /0[34][a-z_]+_xs\.t$/ }
sort
{
lc
$a
cmp
lc
$b
}
@ARGV
);
}
else
{
Test::Harness::runtests (
sort
{
lc
$a
cmp
lc
$b
}
@ARGV
);
}
}