2 #########################################################################
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: qa_comparator.pl,v $
16 # This file is part of OpenOffice.org.
18 # OpenOffice.org is free software: you can redistribute it and/or modify
19 # it under the terms of the GNU Lesser General Public License version 3
20 # only, as published by the Free Software Foundation.
22 # OpenOffice.org is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU Lesser General Public License version 3 for more details
26 # (a copy is included in the LICENSE file that accompanied this code).
28 # You should have received a copy of the GNU Lesser General Public License
29 # version 3 along with OpenOffice.org. If not, see
30 # <http://www.openoffice.org/license.html>
31 # for a copy of the LGPLv3 License.
33 #*************************************************************************
35 $compare_home = $ENV{'QA_COMPARATOR_HOME'};
37 if ($ENV{'CLASSPATH'})
39 $classpath_val = "$compare_home:$ENV{'CLASSPATH'}";
43 $classpath_val = "$compare_home";
46 print "classpath is $classpath_val\n";
53 ####### BEGIN MAIN ##############
55 if ($cmdline_len <= 0)
61 process_cmdline
(@ARGV);
63 open (LOGFILE
, ">$logfile") || die "Cannot open log file $logfile";
66 open (TESTLIST
, $test_list) || die "Couldn't open diff list file $test_list";
71 process_diff
(get_file_title
($_));
77 ####### END MAIN ##############
81 # $_[0] =~ tr/A-Z/a-z/;
83 # chdir to the output directory so the temporary files created by
84 # the java programs are put in the right place.
88 if ($diff_type eq "xml")
90 # Ugly hack, probably a way to tell xerces directly that the dtd's
91 # are in $compare_home/dtd.
93 `cp $compare_home/dtd/* $xml_new`;
95 # $cmd = "java -classpath $classpath_val XmlWrapper $xml_orig/$_[0].sxw $xml_new/$_[0].sxw";
96 $cmd = "java -classpath $classpath_val XmlWrapper $xml_orig/$_[0] $xml_new/$_[0]";
97 print "Executing: $cmd\n";
98 $val = system($cmd)/256;
101 # print LOGFILE "$_[0]|TRUE|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n";
102 print LOGFILE
"$_[0]|TRUE|$xml_orig/$_[0]|$xml_new/$_[0]\n";
106 # print LOGFILE "$_[0]|FALSE|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n";
107 print LOGFILE
"$_[0]|FALSE|$xml_orig/$_[0]|$xml_new/$_[0]\n";
111 # print LOGFILE "$_[0]|ERROR|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n";
112 print LOGFILE
"$_[0]|ERROR|$xml_orig/$_[0]|$xml_new/$_[0]\n";
115 elsif ($diff_type eq "pdb")
117 # $cmd = "java -classpath $classpath_val SimplePdbCompare $pdb_orig/$_[0].pdb $pdb_new/$_[0].pdb\n";
118 $cmd = "java -classpath $classpath_val SimplePdbCompare $pdb_orig/$_[0] $pdb_new/$_[0]\n";
119 print "Executing: $cmd\n";
120 $val = system($cmd)/256;
123 # print LOGFILE "$_[0]|TRUE|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n";
124 print LOGFILE
"$_[0]|TRUE|$pdb_orig/$_[0]|$pdb_new/$_[0]\n";
128 # print LOGFILE "$_[0]|FALSE|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n";
129 print LOGFILE
"$_[0]|FALSE|$pdb_orig/$_[0]|$pdb_new/$_[0]\n";
133 # print LOGFILE "$_[0]|ERROR|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n";
134 print LOGFILE
"$_[0]|ERROR|$pdb_orig/$_[0]|$pdb_new/$_[0]\n";
139 die "Don't understand test type of $diff_type.";
147 @arg= split('=', $i);
148 @arg[0] =~ tr/A-Z/a-z/;
150 if (@arg[0] eq "-pdb-orig")
154 elsif (@arg[0] eq "-pdb-new")
158 elsif (@arg[0] eq "-xml-orig")
162 elsif (@arg[0] eq "-xml-new")
166 elsif (@arg[0] eq "-env")
168 set_env_from_props
($arg[1]);
170 elsif (@arg[0] eq "-list")
172 $test_list = $arg[1];
174 elsif (@arg[0] eq "-one")
178 elsif (@arg[0] eq "-type")
180 $diff_type = $arg[1];
183 elsif (@arg[0] eq "-log")
190 die "Incorrect command line. Don't understand $i";
195 sub set_env_from_props
197 open(PROPSFILE
, $_[0]) || die "Could not open properties file";
202 @arg = split('=', $_);
203 @arg[0] =~ tr/a-z/A-Z/;
207 die "Malformed property in $ARGV[0]";
210 if (@arg[0] eq "PDB_ORIG")
214 elsif (@arg[0] eq "PDB_NEW")
218 elsif (@arg[0] eq "XML_ORIG")
222 elsif (@arg[0] eq "XML_NEW")
233 print "Usage : compartor.pl - compare Office or pdb files\n";
234 print "\t-one=<file> :\t\t individual test case file to run\n";
235 print "\t-list=<file> :\t\t list of test case files\n";
236 print "\t-env=<file> :\t\t Properites like file defining env\n";
237 print "\t-pdb-orig=<path> :\t directory to hold original pdb files\n";
238 print "\t-pdb-new=<path> :\t directory to hold new pdb files\n";
239 print "\t-xml-orig=<path> :\t directory to hold original office documents\n";
240 print "\t-xml-new=<path> :\t directory to hold new office documents\n";
241 print "\t-type=<xml|pdb> :\t Invokes the merge option when converting\n";
242 print "\t-log=<logfile> :\t Save results to logfile.\n";
247 print "Using the following environment:\n";
248 print "\tPDB_ORIG = $pdb_orig\n";
249 print "\tPDB_NEW = $pdb_new\n";
250 print "\tXML_ORIG = $xml_orig\n";
251 print "\tXML_NEW = $xml_new\n\n";
256 @paths = split('\/', $_[0]);
258 return @paths[$len-1];
259 # @names = split('\.', @paths[$len-1]);