summaryrefslogtreecommitdiffstats
path: root/kabc/vcardparser/checkvcard.pl
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kabc/vcardparser/checkvcard.pl
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kabc/vcardparser/checkvcard.pl')
-rwxr-xr-xkabc/vcardparser/checkvcard.pl75
1 files changed, 75 insertions, 0 deletions
diff --git a/kabc/vcardparser/checkvcard.pl b/kabc/vcardparser/checkvcard.pl
new file mode 100755
index 000000000..67160ea4a
--- /dev/null
+++ b/kabc/vcardparser/checkvcard.pl
@@ -0,0 +1,75 @@
+#!/usr/bin/perl
+
+if ( @ARGV != 1 ) {
+ print STDERR "Missing arg: filename\n";
+ exit 1;
+}
+
+$file = $ARGV[0];
+
+if ( !open( IN, "$file" ) ) {
+ print STDERR "Unable to open '$file'\n";
+ exit 1;
+}
+
+while( <IN> ) {
+ if (/^VERSION:(.*)$/ ) {
+ $version = $1;
+ if ( $version eq "2.1" ) { $options = "--vcard21"; }
+ }
+}
+
+close IN;
+
+$ref = "$file.ref";
+
+if ( !open( REF, "$ref" ) ) {
+ print STDERR "Unable to open $ref\n";
+ exit 1;
+}
+
+while( <REF> ) {
+ push @ref, $_;
+}
+
+close REF;
+
+if ( !open( READ, "./testread $file $options 2> /dev/null |" ) ) {
+ print STDERR "Unable to open testread\n";
+ exit 1;
+}
+
+print "Checking '$file':\n";
+
+$gotsomething = 0;
+$error = 0;
+$i = 0;
+while( <READ> ) {
+ $gotsomething = 1;
+ $out = $_;
+ $ref = @ref[$i++];
+
+ if ( $out ne $ref ) {
+ if ( $ref =~ /^UID/ && $out =~ /^UID/ ) { next; }
+ $error++;
+ print " Expected : $ref";
+ print " Parser output : $out";
+ }
+}
+
+close READ;
+
+if ( $gotsomething == 0 ) {
+ print "\n FAILED: testread didn't output anything\n";
+ system "touch FAILED";
+ exit 1;
+}
+if ( $error > 0 ) {
+ print "\n FAILED: $error errors found.\n";
+ system "touch FAILED";
+ exit 1;
+} else {
+ print " OK\n";
+}
+
+exit 0;