[LTP] [PATCH 6/7] docparse: Group data to 'testsuite' and 'defaults'

Cyril Hrubis
2021-10-18T15:48:19Z

Group all data belonging to testsuite info to 'testsuite' object and
move default timeout to 'defaults' object. This makes the JSON structure
a bit cleaner and easier to understand.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
docparse/parse.sh | 16 ++++++++++------
docparse/testinfo.pl | 16 ++++++++--------
2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/docparse/parse.sh b/docparse/parse.sh
index 2ace34fa0..52d9a5cbf 100755
--- a/docparse/parse.sh
+++ b/docparse/parse.sh
@@ -15,12 +15,16 @@ if [ -d .git ]; then
fi

echo '{'
-echo ' "testsuite": "Linux Test Project",'
-echo ' "testsuite_short": "LTP",'
-echo ' "url": "https://github.com/linux-test-project/ltp/",'
-echo ' "scm_url_base": "https://github.com/linux-test-project/ltp/tree/master/",'
-echo ' "timeout": 300,'
-echo " \"version\": \"$version\","
+echo ' "testsuite": {'
+echo ' "name": "Linux Test Project",'
+echo ' "short_name": "LTP",'
+echo ' "url": "https://github.com/linux-test-project/ltp/",'
+echo ' "scm_url_base": "https://github.com/linux-test-project/ltp/tree/master/",'
+echo " \"version\": \"$version\""
+echo ' },'
+echo ' "defaults": {'
+echo ' "timeout": 300'
+echo ' },'
echo ' "tests": {'

first=1
diff --git a/docparse/testinfo.pl b/docparse/testinfo.pl
index c11064c05..891619532 100755
--- a/docparse/testinfo.pl
+++ b/docparse/testinfo.pl
@@ -164,9 +164,9 @@ sub content_about
my $json = shift;
my $content;

- $content .= print_defined("URL", $json->{'url'});
- $content .= print_defined("Version", $json->{'version'});
- $content .= print_defined("Default timeout", $json->{'timeout'}, "seconds");
+ $content .= print_defined("URL", $json->{'testsuite'}->{'url'});
+ $content .= print_defined("Version", $json->{'testsuite'}->{'version'});
+ $content .= print_defined("Default timeout", $json->{'defaults'}->{'timeout'}, "seconds");

return $content;
}
@@ -360,10 +360,10 @@ sub content_all_tests
$content .= h3($name);
$content .= $letters;

- if (defined($json->{'scm_url_base'}) &&
+ if (defined($json->{'testsuite'}->{'scm_url_base'}) &&
defined($json->{'tests'}{$name}{fname})) {
$content .= paragraph(html_a(tag_url("fname", $json->{'tests'}{$name}{fname},
- $json->{'scm_url_base'}), "source"));
+ $json->{'testsuite'}->{'scm_url_base'}), "source"));
}

if (defined $json->{'tests'}{$name}{doc}) {
@@ -386,7 +386,7 @@ sub content_all_tests
$content .= paragraph("Test timeout is $json->{'tests'}{$name}{timeout} seconds");
}
} else {
- $content .= paragraph("Test timeout defaults to $json->{'timeout'} seconds");
+ $content .= paragraph("Test timeout defaults to $json->{'defaults'}->{'timeout'} seconds");
}

my $tmp2 = undef;
@@ -463,7 +463,7 @@ my $json = decode_json(load_json($ARGV[0]));
my $config = [
{
file => "about.txt",
- title => h2("About $json->{'testsuite'}"),
+ title => h2("About $json->{'testsuite'}->{'name'}"),
content => \&content_about,
},
{
@@ -495,7 +495,7 @@ EOL
for my $c (@{$config}) {
$content .= "include::$c->{'file'}\[\]\n";
}
- print_asciidoc_page($fh, $json, h1($json->{'testsuite_short'} . " test catalog"), $content);
+ print_asciidoc_page($fh, $json, h1($json->{'testsuite'}->{'short_name'} . " test catalog"), $content);
}

for my $c (@{$config}) {
--
2.32.0