Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
docu-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
docu-tools
Commits
8f67bcbe
Commit
8f67bcbe
authored
Jan 1, 2014
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
evolving test suite
parent
824ce588
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
perl/Gnome-Tomboy/s1.pl
+171
-24
171 additions, 24 deletions
perl/Gnome-Tomboy/s1.pl
with
171 additions
and
24 deletions
perl/Gnome-Tomboy/s1.pl
+
171
−
24
View file @
8f67bcbe
...
@@ -14,19 +14,73 @@ use strict;
...
@@ -14,19 +14,73 @@ use strict;
use
lib
'
lib
';
use
lib
'
lib
';
use
Tomboy::Note::
Simple
;
use
Data::
Dumper
;
use
Data::
Dumper
;
$
Data::Dumper::
Indent
=
1
;
$
Data::Dumper::
Indent
=
1
;
use
Util::
XML_Parser_Tree
;
use
Tomboy::Note::
Simple
;
die
"
no note filename specified
"
unless
(
@ARGV
);
die
"
no note filename specified
"
unless
(
@ARGV
);
open
(
FO
,
'
>:utf8
',
'
do_verify.sh
');
my
@tests
=
(
'
process_note
',
'
test_text_accessor
',
'
test_lines_accessor
',
);
my
$test_num
=
0
;
my
$verbose
=
0
;
my
@notes
=
();
while
(
my
$arg
=
shift
(
@ARGV
))
while
(
my
$arg
=
shift
(
@ARGV
))
{
{
process_note
(
$arg
);
if
(
$arg
=~
/^-/
)
{
if
(
$arg
eq
'
-t
')
{
$test_num
=
shift
(
@ARGV
);
}
else
{
&usage
();
}
}
else
{
push
(
@notes
,
$arg
);
}
}
my
@diff_failed
=
();
my
$test
=
$tests
[
$test_num
];
my
%rc
;
foreach
my
$arg
(
@notes
)
{
print
'
=
'
x90
,
"
\n
";
print
"
$test
note_fnm=[
$arg
]
\n
";
my
$rc
;
if
(
$test
eq
'
process_note
')
{
$rc
=
process_note
(
$arg
);
}
elsif
(
$test
eq
'
test_text_accessor
')
{
$rc
=
test_text_accessor
(
$arg
);
}
elsif
(
$test
eq
'
test_lines_accessor
')
{
$rc
=
test_lines_accessor
(
$arg
);
}
$rc
{
$rc
}
++
;
print
"
\n
";
}
}
if
(
@diff_failed
)
{
open
(
FO
,
'
>:utf8
',
'
do_verify.sh
');
print
FO
<<EOX;
#!/bin/sh
#
# shell script generated by test script
#
EOX
print
FO
'
#
',
scalar
localtime
(),
"
\n\n
";
foreach
(
@diff_failed
)
{
print
FO
$_
,
"
\n
";
}
close
(
FO
);
close
(
FO
);
}
print
"
statistics:
",
scalar
@diff_failed
,
"
times 'diff' returned non-zero return codes
\n
";
print
"
return codes
",
Dumper
(
\
%rc
);
exit
(
0
);
exit
(
0
);
...
@@ -34,9 +88,6 @@ sub process_note
...
@@ -34,9 +88,6 @@ sub process_note
{
{
my
$note_fnm
=
shift
;
my
$note_fnm
=
shift
;
print
'
=
'
x90
,
"
\n
";
print
"
process_note note_fnm=[
$note_fnm
]
\n
";
# V1:
# V1:
my
$n
=
parse
Tomboy::Note::
Simple
(
$note_fnm
);
my
$n
=
parse
Tomboy::Note::
Simple
(
$note_fnm
);
...
@@ -48,20 +99,116 @@ $n->text_to_lines ();
...
@@ -48,20 +99,116 @@ $n->text_to_lines ();
$n
->
parse_lines
();
$n
->
parse_lines
();
# print "n: ", Dumper ($n);
# print "n: ", Dumper ($n);
my
$saved
=
$n
->
save
();
my
$saved
=
$n
->
save
('
tmp
');
# print "saved=[$saved]\n";
perform_diff
(
$note_fnm
,
$saved
);
}
=head2 test_text_accessor
Access the text element as parse tree, convert it into string, parse that and place it back into the note.
If all goes well, the note file should not be different.
=cut
sub
test_text_accessor
{
my
$note_fnm
=
shift
;
my
$note
=
parse
Tomboy::Note::
Simple
(
$note_fnm
);
# print "note: ", Dumper ($note);
my
$pt1
=
$note
->
get_text
();
print
"
pt1:
",
Dumper
(
$pt1
);
my
$xml_str
=
Util::XML_Parser_Tree::
to_string
(
@$pt1
);
print
"
xml_str=[
$xml_str
]
\n
";
my
$pt2
=
Tomboy::Note::Simple::
parse_string
(
$xml_str
);
print
"
pt2:
",
Dumper
(
$pt2
);
my
$rc
=
$note
->
set_text
(
$pt2
);
print
"
set_text: rc=[
$rc
]
\n
";
my
$saved
=
$note
->
save
('
tmp
');
perform_diff
(
$note_fnm
,
$saved
);
}
=head2 test_lines_accessor
Access the text element as parse tree, convert it into string, parse that and place it back into the note.
If all goes well, the note file should not be different.
=cut
sub
test_lines_accessor
{
my
$note_fnm
=
shift
;
my
$note
=
parse
Tomboy::Note::
Simple
(
$note_fnm
);
# print "note: ", Dumper ($note);
my
$l1
=
$note
->
get_lines
();
# print "l1: ", Dumper ($l1);
my
$wrapped
=
Tomboy::Note::Simple::
wrap_lines
(
$l1
);
# print "wrapped=[$wrapped]\n";
my
$pt1
=
Tomboy::Note::Simple::
parse_string
(
$wrapped
);
# print "pt1: ", Dumper ($pt1);
my
@note_content
=
@
{
$pt1
->
[
1
]
->
[
2
]};
# print "note_content: ", Dumper (\@note_content);
shift
(
@note_content
);
# print "note_content: ", Dumper (\@note_content);
my
$xml_str
=
Util::XML_Parser_Tree::
to_string
(
@note_content
);
# print "xml_str=[$xml_str]\n";
# my @lines= split (/\n/, $xml
my
$rc
=
$note
->
set_lines
(
$xml_str
);
print
"
set_lines: rc=[
$rc
]
\n
";
my
$saved
=
$note
->
save
('
tmp
');
perform_diff
(
$note_fnm
,
$saved
);
}
sub
generator
{
my
$title
=
shift
||
'
test note
'
.
scalar
localtime
();
my
$note
=
new
Tomboy::Note::
Simple
('
title
'
=>
$title
);
print
"
note:
",
Dumper
(
$note
);
$note
->
save
(
undef
,
'
tmp/s3-v001.note
');
$note
->
text_to_lines
();
$note
->
save
(
undef
,
'
tmp/s3-v002.note
');
print
"
note:
",
Dumper
(
$note
);
$note
->
empty_text
('
now empty
');
print
"
note:
",
Dumper
(
$note
);
$note
->
save
(
undef
,
'
tmp/s3-v003.note
');
}
sub
perform_diff
{
my
$note_fnm
=
shift
;
my
$saved
=
shift
;
print
"
saved=[
$saved
]
\n
";
my
@cmd
=
('
diff
',
'
-u
',
$note_fnm
,
$saved
);
my
@cmd
=
('
diff
',
'
-u
',
$note_fnm
,
$saved
);
print
join
('
',
@cmd
),
"
\n
";
print
join
('
',
@cmd
),
"
\n
";
my
$rc
=
system
(
@cmd
);
my
$rc
=
system
(
@cmd
);
print
"
rc=[
$rc
]
\n
\n
";
print
"
rc=[
$rc
]
\n
";
if
(
$rc
!=
0
)
if
(
$rc
!=
0
)
{
{
p
rint
FO
join
('
',
@cmd
)
,
"
\n
"
;
p
ush
(
@diff_failed
,
join
('
',
@cmd
)
)
;
}
}
$rc
;
$rc
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment