| 1 |
#!/usr/bin/perl |
| 2 |
use warnings; |
| 3 |
use strict; |
| 4 |
use Cwd 'abs_path'; |
| 5 |
$|++; |
| 6 |
|
| 7 |
# Test table resolving given a complicated LOUIS_TABLEPATH |
| 8 |
# |
| 9 |
# Copyright (C) 2011 by Swiss Library for the Blind, Visually Impaired and Print Disabled |
| 10 |
# |
| 11 |
# Copying and distribution of this file, with or without modification, |
| 12 |
# are permitted in any medium without royalty provided the copyright |
| 13 |
# notice and this notice are preserved. |
| 14 |
|
| 15 |
|
| 16 |
my $abs_top_srcdir = abs_path("$ENV{srcdir}/.."); |
| 17 |
|
| 18 |
my @paths = ( |
| 19 |
"$abs_top_srcdir/tables", |
| 20 |
"$abs_top_srcdir/tests/tables", |
| 21 |
"$abs_top_srcdir/tests/tables/moreTables", |
| 22 |
"$abs_top_srcdir/tests/tablesWithMetadata", |
| 23 |
"$abs_top_srcdir/tests/tables/emphclass", |
| 24 |
); |
| 25 |
|
| 26 |
$ENV{"LOUIS_TABLEPATH"} = join(",", @paths); |
| 27 |
|
| 28 |
my @tables = ( |
| 29 |
# a global table |
| 30 |
"en-us-g2.ctb", |
| 31 |
# a local table |
| 32 |
"loop.ctb", |
| 33 |
# a table with a relative path |
| 34 |
"$ENV{srcdir}/tables/loop.ctb", |
| 35 |
# a list of tables with a relative path |
| 36 |
"$ENV{srcdir}/../tables/en-us-g2.ctb,en-us-g1.ctb", |
| 37 |
# a table with an absolute path |
| 38 |
abs_path("$ENV{srcdir}/tables/loop.ctb"), |
| 39 |
# a list of tables with an absolute path |
| 40 |
abs_path("$ENV{srcdir}/../tables/en-us-g2.ctb") . ",en-us-g1.ctb", |
| 41 |
# table combinations |
| 42 |
# all global tables |
| 43 |
"en-us-g2.ctb,braille-patterns.cti", |
| 44 |
# a global and a local table |
| 45 |
"braille-patterns.cti,pass2.ctb", |
| 46 |
# a local and a global table |
| 47 |
"pass2.ctb,braille-patterns.cti", |
| 48 |
# a relative, a local and a global table |
| 49 |
"$ENV{srcdir}/tables/loop.ctb,pass2.ctb,braille-patterns.cti", |
| 50 |
# a table which includes local and global tables |
| 51 |
"include.utb", |
| 52 |
# a relative table and a table which includes local and global tables |
| 53 |
# currently fails |
| 54 |
# "$ENV{srcdir}/tables/loop.ctb,include.utb", |
| 55 |
); |
| 56 |
|
| 57 |
# ensure existing tables are found |
| 58 |
foreach my $table (@tables) { |
| 59 |
system("../tools/lou_checktable $table --quiet") == 0 or die; |
| 60 |
} |
| 61 |
|
| 62 |
# ensure a non-existing table is not found |
| 63 |
system("../tools/lou_checktable nonexistent.ctb 2> /dev/null") != 0 or die; |