diff options
author | Karl Berry <karl@freefriends.org> | 2021-02-25 19:22:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-02-25 19:22:25 +0000 |
commit | ad547a6b5986815fda458221149728d9d9ab1d87 (patch) | |
tree | 16296910eb3eca724371474ea9aea3994dc69614 /Build/source/texk/tests/common-test.pl | |
parent | 947b43de3dd21d58ccc2ffadefc4441ea1c2a813 (diff) |
restore Build,TODO from r57911
git-svn-id: svn://tug.org/texlive/trunk@57915 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/tests/common-test.pl')
-rw-r--r-- | Build/source/texk/tests/common-test.pl | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Build/source/texk/tests/common-test.pl b/Build/source/texk/tests/common-test.pl new file mode 100644 index 00000000000..c936f24f656 --- /dev/null +++ b/Build/source/texk/tests/common-test.pl @@ -0,0 +1,64 @@ +# $Id: common-test.pl 16695 2010-01-13 01:18:02Z karl $ +# Public domain. Originally written 2010, Karl Berry. +# Common definitions for Perl tests in TeX Live. We want to use Perl to +# have a chance of running the tests on Windows. + +# absolute path +chomp (my $TL_TESTS_DIR = `cd "$srcdir/../tests" && pwd`); + +# srcdir must be a sibling dir to kpathsea, e.g., web2c. +$ENV{"TEXMFCNF"} = "$srcdir/../kpathsea"; +$ENV{"AFMFONTS"} + = $ENV{"BIBINPUTS"} + = $ENV{"BSTINPUTS"} + = $ENV{"TEXINPUTS"} + = ".:$srcdir/tests:$srcdir/../tests/texmf//"; + + +# Run PROG with ARGS. Return the exit status. +# Die if PROG is not executable. +# +sub test_run { + my ($prog, @args) = @_; + + # Possibly we should check that $prog starts with ./, since we always + # want to run out of the build dir. I think. + die "$0: no program $prog in " . `pwd` if ! -x $prog; + + # use local pm files and kpsewhich. + $ENV{"PERL5LIB"} = $TL_TESTS_DIR; + $ENV{"PATH"} = "../kpathsea:$ENV{PATH}"; + + # Won't be copyable with weird names, but should get the info across. + print "$0: running ", $prog, " ", join (" ", @args), "\n"; + + # Run it. + my $ret = system ($prog, @args); + return $ret; +} + +sub test_file_copy { + my ($srcfile,$dstfile) = @_; + + # don't copy onto itself. + chomp (my $srcdir = `dirname $srcfile`); + chomp ($srcdir = `cd $srcdir && pwd`); + # + chomp (my $dstdir = `dirname $dstfile`); + chomp ($dstdir = `cd $dstdir && pwd`); + return if $srcdir eq $dstdir; + + local *IN; + $IN = "<$srcfile"; + open (IN) || die "open($srcfile) failed: $!"; + my @in = <IN>; + close (IN) || warn "close($srcfile) failed: $!"; + + local *OUT; + $OUT = ">$dstfile"; + open (OUT) || die "open($dstfile) failed: $!"; + print (OUT @in) || die "print($dstfile) failed: $!"; + close (OUT) || warn "close($dstfile) failed: $!"; + + return 0; +} |