less/backport-makecheck-0003-Some-runtest-tweaks.patch

118 lines
3.1 KiB
Diff
Raw Normal View History

From ec292147336a4b5194af50edb282c6923aa0101e Mon Sep 17 00:00:00 2001
From: Mark Nudelman <markn@greenwoodsoftware.com>
Date: Tue, 4 Oct 2022 12:47:02 -0700
Subject: [PATCH] Some runtest tweaks.
---
lesstest/run.c | 1 +
lesstest/{run => runtest} | 31 ++++++++++++++++++++-----------
2 files changed, 21 insertions(+), 11 deletions(-)
rename lesstest/{run => runtest} (58%)
diff --git a/lesstest/run.c b/lesstest/run.c
index da306e8..c07048e 100644
--- a/lesstest/run.c
+++ b/lesstest/run.c
@@ -152,6 +152,7 @@ int run_test(TestSetup* setup, FILE* testfd) {
return ok;
}
+// Should run in empty directory.
int run_testfile(const char* testfile, const char* less) {
FILE* testfd = fopen(testfile, "r");
if (testfd == NULL) {
diff --git a/lesstest/run b/lesstest/runtest
similarity index 58%
rename from lesstest/run
rename to lesstest/runtest
index 04e8a4f..42b8cae 100755
--- a/lesstest/run
+++ b/lesstest/runtest
@@ -3,11 +3,13 @@ use strict;
# Run one or more test files.
-my $usage = "usage: run [-l less.exe] [-o lesstest-opts] [file.lt | dir]...\n";
+my $usage = "usage: run [-l less.exe] [-r temp_dir] [-o lesstest-opts] [file.lt | dir]...\n";
use Getopt::Std;
+use Cwd;
my $testdir = ".";
+my $rundir = ".runtest_dir";
my $lesstest = "$testdir/lesstest";
my $less = "$testdir/../obj/less";
my $lesstest_opts = "";
@@ -15,43 +17,50 @@ my %opt;
exit (main() ? 0 : 1);
sub main {
- die $usage if not getopts('l:o:v', \%opt);
+ die $usage if not getopts('l:o:r:v', \%opt);
die $usage if not @ARGV;
$less = $opt{l} if $opt{l};
- $lesstest_opts = $opt{o};
+ $lesstest_opts = $opt{o} if $opt{o};
$lesstest_opts =~ s/^\s*//;
$lesstest_opts =~ s/\s*$//;
$lesstest_opts = '-'.$lesstest_opts if $lesstest_opts and $lesstest_opts !~ /^-/;
+ my $odir = getcwd();
+ $rundir = $opt{r} if $opt{r};
+ system "rm -rf $rundir ; mkdir -p $rundir";
+ die "cannot chdir to $rundir: $!" if not chdir $rundir;
my $errs = 0;
foreach my $file (@ARGV) {
+ $file = "$odir/$file" unless $file =~ m|^/|;
$errs += run($file);
}
if ($errs > 0) {
- print STDERR "ERRS $errs errors\n";
+ print "ERRS $errs errors\n";
return 0;
}
return 1;
}
+# Run a xxx.lt file.
sub run {
my ($file) = @_;
if (-d $file) {
return run_dir($file);
}
if ($file !~ /\.lt$/) {
- print "$0: WARNING skipping $file: not .lt file\n";
+ print "SKIP unknown file suffix: $file\n";
return 0;
}
if (not -f $file) {
- print STDERR "ERR cannot open $file\n";
+ print "ERR cannot open $file\n";
return 1;
}
- ##print STDERR "FILE $file\n";
+ ##print "FILE $file\n";
my $cmd = "$lesstest -s $testdir/lt_screen -t $file $lesstest_opts $less";
- print STDERR "RUN $cmd\n" if $opt{v};
- if (system $cmd) {
- print STDERR "ERR running $cmd\n";
+ print "RUN $cmd\n" if $opt{v};
+ my $err = system $cmd;
+ if ($err) {
+ print "ERR status $err from $cmd\n";
return 1;
}
return 0;
@@ -62,7 +71,7 @@ sub run_dir {
my $errs = 0;
my $dd;
if (not opendir($dd, $dir)) {
- print STDERR "ERR cannot open directory $dir\n";
+ print "ERR cannot open directory $dir: $!\n";
return 1;
}
while (my $entry = readdir($dd)) {
--
2.27.0