[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Fri, 24 May 2024 13:35:46 -0400 (EDT) |
branch: master
commit fea3e9851c318555bbfda8d15f6f06dc6a6f1543
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri May 24 19:28:18 2024 +0200
* tp/Texinfo/Tests.pm (@EXPORT_OK, create_group_directory)
(prepare_format_directories), tp/t/no_structure_test.t
(_do_format_test_file): add a Package declaration in Texinfo/Tests.pm.
Add create_group_directory, move _prepare_test_directory to
Texinfo::Tests, renaming as prepare_format_directories. Rename
_run_file_test as _do_format_test_file.
---
ChangeLog | 9 +++++++
tp/Texinfo/Tests.pm | 60 ++++++++++++++++++++++++++++++++++++++++++-
tp/t/no_structure_test.t | 66 ++++++++++++++++--------------------------------
3 files changed, 90 insertions(+), 45 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c342721f07..f0029a079b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-05-24 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Tests.pm (@EXPORT_OK, create_group_directory)
+ (prepare_format_directories), tp/t/no_structure_test.t
+ (_do_format_test_file): add a Package declaration in Texinfo/Tests.pm.
+ Add create_group_directory, move _prepare_test_directory to
+ Texinfo::Tests, renaming as prepare_format_directories. Rename
+ _run_file_test as _do_format_test_file.
+
2024-05-24 Patrice Dumas <pertusus@free.fr>
* tp/Makefile.am, tp/t/test_utils.pl, tp/Texinfo/Tests.pm
diff --git a/tp/Texinfo/Tests.pm b/tp/Texinfo/Tests.pm
index fe0b37e0ae..3da3583eff 100644
--- a/tp/Texinfo/Tests.pm
+++ b/tp/Texinfo/Tests.pm
@@ -17,12 +17,23 @@
#
# Original author: Patrice Dumas <pertusus@free.fr>
-use strict;
+package Texinfo::Tests;
use 5.006;
+use strict;
+
use File::Compare qw(compare); # standard since 5.004
+require Exporter;
+our @ISA = qw(Exporter);
+
+our @EXPORT_OK = qw(
+compare_dirs_files
+unlink_dir_files
+prepare_format_directories
+);
+
# not that subdirectories are not compared, so subdirectories generated
# by INFO_JS_DIR, if different, will not trigger an error in test, but
# will lead to different directories and files in diffs.
@@ -113,4 +124,51 @@ sub unlink_dir_files($;$)
}
}
+my $default_result_base = 't/results/';
+
+sub create_group_directory($;$)
+{
+ my $test_group = shift;
+ my $result_base = shift;
+
+ $result_base = $default_result_base if (!defined($result_base));
+
+ foreach my $dir ('t', $result_base,
+ File::Spec->catdir($result_base, $test_group)) {
+ my $error;
+ # to avoid a race conditon, first create the dir then test that it
+ # exists
+ mkdir $dir or $error = $!;
+ if (! -d $dir) {
+ die "mkdir $dir: $error\n";
+ }
+ }
+}
+
+sub prepare_format_directories($$$$;$)
+{
+ my $srcdir = shift;
+ my $test_group = shift;
+ my $test_name = shift;
+ my $format_type = shift;
+ my $result_base = shift;
+
+ $result_base = $default_result_base if (!defined($result_base));
+
+ my $base = File::Spec->catdir($result_base, $test_group, $test_name);
+
+ my $test_out_dir = File::Spec->catdir($base, 'out_'.$format_type);
+ my $reference_dir = File::Spec->catdir($srcdir, $base, 'res_'.$format_type);
+
+ mkdir ($base)
+ if (! -d $base);
+ if (! -d $test_out_dir) {
+ mkdir ($test_out_dir);
+ } else {
+ # remove any files from previous runs
+ unlink glob ("$test_out_dir/*");
+ }
+ return ($test_out_dir, $reference_dir);
+}
+
1;
diff --git a/tp/t/no_structure_test.t b/tp/t/no_structure_test.t
index 14197a96f4..d8199887a4 100644
--- a/tp/t/no_structure_test.t
+++ b/tp/t/no_structure_test.t
@@ -9,7 +9,8 @@ BEGIN { plan tests => 8; }
use File::Spec;
-use Texinfo::Tests qw(compare_dirs_files unlink_dir_files);
+use Texinfo::Tests qw(compare_dirs_files unlink_dir_files
+ prepare_format_directories);
use Texinfo::Parser;
use Texinfo::Convert::Texinfo;
@@ -20,34 +21,16 @@ use Texinfo::Convert::LaTeX;
use Texinfo::Convert::DocBook;
use Texinfo::Convert::TexinfoXML;
-# The test in this file tests outputing with converters without
-# calling the Texinfo Structuring code. In general we ae not that
+# The test in this file tests outputting with converters without
+# calling the Texinfo Structuring code. In general we are not that
# interested by the results themselves, more by the errors.
-
-
-sub _prepare_test_directory($$$$)
-{
- my $test_name = shift;
- my $format_type = shift;
- my $srcdir = shift;
- my $base = shift;
+# NOTE the references need to be updated manually, by copying
+# out_* directories files or cut and pasting.
- my $test_out_dir = $base.'out_'.$format_type;
- my $reference_dir = "$srcdir$base".'res_'.$format_type;
-
- mkdir ($base)
- if (! -d $base);
- if (! -d $test_out_dir) {
- mkdir ($test_out_dir);
- } else {
- # remove any files from previous runs
- unlink glob ("$test_out_dir/*");
- }
- return ($test_out_dir, $reference_dir);
-}
+
-sub _run_file_test($$$$$$)
+sub _do_format_test_file($$$$$$)
{
my $test_name = shift;
my $format = shift;
@@ -87,7 +70,7 @@ my $srcdir = $ENV{'srcdir'};
if (defined($srcdir)) {
$srcdir =~ s/\/*$/\//;
} else {
- $srcdir = '';
+ $srcdir = '.';
}
my $debug = 0;
@@ -95,6 +78,12 @@ my $debug = 0;
ok(1, "modules loading");
+my $test_group = 'no_structure_test';
+
+#Texinfo::Tests::create_group_directory($test_group);
+
+
+
my $texi = '@contents
@top First File
@@ -140,22 +129,11 @@ foreach my $error_message (@$test_parser_errors) {
;# if ($debug);
}
-foreach my $dir ('t', 't/results', 't/results/no_structure_test') {
- my $error;
- # to avoid a race conditon, first create the dir then test that it
- # exists
- mkdir $dir or $error = $!;
- if (! -d $dir) {
- die "mkdir $dir: $error\n";
- }
-}
-
my $test_name = 'one';
-my $base = "t/results/no_structure_test/$test_name/";
my $format = 'html';
my ($html_test_out_dir, $html_reference_dir)
- = _prepare_test_directory($test_name, $format, $srcdir, $base);
+ = prepare_format_directories($srcdir, $test_group, $test_name, $format);
my $html_converter = Texinfo::Convert::HTML->converter(
@@ -164,9 +142,9 @@ my $html_converter = Texinfo::Convert::HTML->converter(
'SUBDIR' => $html_test_out_dir,
'SPLIT' => ''});
-# Note that there are no contents, as there is not sections_list
-_run_file_test($test_name, $format, $html_converter, $document,
- $html_test_out_dir, $html_reference_dir);
+# Note that there are no contents, as there is no sections_list
+_do_format_test_file($test_name, $format, $html_converter, $document,
+ $html_test_out_dir, $html_reference_dir);
my $plaintext_converter = Texinfo::Convert::Plaintext->converter();
my $plaintext_text = $plaintext_converter->convert($document);
@@ -194,13 +172,13 @@ subsec
$format = 'info';
my ($info_test_out_dir, $info_reference_dir)
- = _prepare_test_directory($test_name, $format, $srcdir, $base);
+ = prepare_format_directories($srcdir, $test_group, $test_name, $format);
my $info_converter
= Texinfo::Convert::Info->converter({'SUBDIR' => $info_test_out_dir});
-_run_file_test($test_name, $format, $info_converter, $document,
- $info_test_out_dir, $info_reference_dir);
+_do_format_test_file($test_name, $format, $info_converter, $document,
+ $info_test_out_dir, $info_reference_dir);
my $latex_converter = Texinfo::Convert::LaTeX->converter();