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
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
11 years ago
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
evolving test suite
parent
824ce588
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide 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;
use
lib
'
lib
';
use
Tomboy::Note::
Simple
;
use
Data::
Dumper
;
$
Data::Dumper::
Indent
=
1
;
use
Util::
XML_Parser_Tree
;
use
Tomboy::Note::
Simple
;
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
))
{
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
);
...
...
@@ -34,34 +88,127 @@ sub process_note
{
my
$note_fnm
=
shift
;
print
'
=
'
x90
,
"
\n
";
print
"
process_note note_fnm=[
$note_fnm
]
\n
"
;
# V1:
my
$n
=
parse
Tomboy::Note::
Simple
(
$note_fnm
)
;
# V
1
:
my
$n
=
parse
Tomboy::Note::
Simple
(
$note_fnm
);
# V
2
:
#
my $n=
new
Tomboy::Note::Simple
; $n->parse
($note_fnm);
# V2:
# my $n= new Tomboy::Note::Simple; $n->parse ($note_fnm);
$n
->
text_to_lines
();
# print "lines: ", Dumper ($n->{'lines'});
$n
->
parse_lines
();
# print "n: ", Dumper ($n);
my
$saved
=
$n
->
save
('
tmp
');
# print "saved=[$saved]\n";
perform_diff
(
$note_fnm
,
$saved
);
}
$n
->
text_to_lines
();
# print "lines: ", Dumper ($n->{'lines'});
$n
->
parse_lines
();
# print "n: ", Dumper ($n);
=head2 test_text_accessor
my
$saved
=
$n
->
save
();
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.
print
"
saved=[
$saved
]
\n
";
my
@cmd
=
('
diff
',
'
-u
',
$note_fnm
,
$saved
);
print
join
('
',
@cmd
),
"
\n
";
my
$rc
=
system
(
@cmd
);
print
"
rc=[
$rc
]
\n\n
";
=cut
if
(
$rc
!=
0
)
sub
test_text_accessor
{
print
FO
join
('
',
@cmd
),
"
\n
";
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
);
}
$rc
;
=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
;
my
@cmd
=
('
diff
',
'
-u
',
$note_fnm
,
$saved
);
print
join
('
',
@cmd
),
"
\n
";
my
$rc
=
system
(
@cmd
);
print
"
rc=[
$rc
]
\n
";
if
(
$rc
!=
0
)
{
push
(
@diff_failed
,
join
('
',
@cmd
));
}
$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