2 eval 'exec perl -wS $0 ${1+"$@"}'
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: cwsattach.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 # cwstestresult.pl - publish results of CWS tests to EIS
45 if ( !defined($ENV{SOLARENV
}) ) {
46 die "No environment found (environment variable SOLARENV is undefined)";
48 push(@lib_dirs, "$ENV{SOLARENV}/bin/modules");
49 push(@lib_dirs, "$ENV{COMMON_ENV_TOOLS}/modules") if defined($ENV{COMMON_ENV_TOOLS
});
56 ( my $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/;
58 my $is_debug = 1; # enable debug
59 my $opt_master; # option: master workspace
60 my $opt_child; # option: child workspace
61 my $opt_milestone; # option: milestone
62 my $opt_testrunName; # option: testrunName
63 my $opt_testrunPlatform; # option: testrunPlatfrom
64 my $opt_resultPage; # option: resultPage
69 my $arg_status= parse_options
();
70 testresult
($arg_status);
78 # get master and child workspace
79 my $masterws = $opt_master ?
uc($opt_master) : $ENV{WORK_STAMP
};
80 my $milestone = $opt_milestone ?
$opt_milestone : $ENV{UPDMINOR
};
81 my $childws = $opt_milestone ?
undef : ( $opt_child ?
$opt_child : $ENV{CWS_WORK_STAMP
} );
83 if ( !defined($masterws) ) {
84 print_error
("Can't determine master workspace environment.\n"
85 . "Please initialize environment with setsolar ...", 1);
88 if ( !defined($childws) && !defined($milestone) ) {
89 print_error
("Can't determine child workspace environment or milestone.\n"
90 . "Please initialize environment with setsolar ...", 1);
92 if ( !defined($opt_resultPage) ) {
96 if ( defined($childws) ) {
97 $cws->child($childws);
99 $cws->master($masterws);
100 my $eis = $cws->eis();
105 if ( defined($childws) ) {
106 $opt_resultPage=SOAP
::Data
->type(string
=> $opt_resultPage);
107 my $id = $cws->eis_id();
108 if ( is_valid_cws
($cws) ) {
109 $result=$eis->submitTestResult($id,$opt_testrunName,$opt_testrunPlatform, $opt_resultPage, $status);
111 print STDERR
"cws is not valid";
114 $opt_resultPage=SOAP
::Data
->type(string
=> $opt_resultPage);
115 $result=$eis->submitTestResultMWS($masterws,$milestone,$opt_testrunName,$opt_testrunPlatform, $opt_resultPage, $status);
126 my $masterws = $cws->master();
127 my $childws = $cws->child();
128 # check if we got a valid child workspace
129 my $id = $cws->eis_id();
131 print_error
("Child workspace '$childws' for master workspace '$masterws' not found in EIS database.", 2);
138 # parse options and do some sanity checks
139 Getopt
::Long
::Configure
("no_ignore_case");
141 my $success = GetOptions
('h' => \
$help, 'M=s' => \
$opt_master, 'm=s' => \
$opt_milestone, 'c=s' => \
$opt_child, 'n=s' => \
$opt_testrunName, 'p=s' => \
$opt_testrunPlatform , 'r=s' => \
$opt_resultPage );
142 if ( $help || !$success || $#ARGV < 0 || (!defined($opt_testrunName)) || ( !defined($opt_testrunPlatform)) ) {
146 if ( defined($opt_milestone) && defined($opt_child) ) {
147 print_error
("-m and -c are mutually exclusive options",1);
157 print STDERR
"$script_name: ";
158 print STDERR
"$message\n";
165 my $error_code = shift;
167 print STDERR
"$script_name: ";
168 print STDERR
"ERROR: $message\n";
171 print STDERR
"\nFAILURE: $script_name aborted.\n";
179 print STDERR
"Usage: cwstestresult[-h] [-m masterws] [-m milestone|-c childws] <-n testrunName> <-p testrunPlatform> <-r resultPage> statusName\n";
181 print STDERR
"Publish result of CWS- or milestone-test to EIS\n";
183 print STDERR
"Options:\n";
184 print STDERR
"\t-h\t\t\thelp\n";
185 print STDERR
"\t-M master\t\toverride MWS specified in environment\n";
186 print STDERR
"\t-m milestone\t\toverride milestone specified in environment\n";
187 print STDERR
"\t-c child\t\toverride CWS specified in environment\n";
188 print STDERR
"\t-n testrunName\t\tspecifiy name of the test\n";
189 print STDERR
"\t-p testrunPlatform\tspecify platform where the test ran on\n";
190 print STDERR
"\t-r resultPage\t\tspecify name of attachment or hyperlink\n";
191 print STDERR
"\t\t\t\tfor resultPage\n";
194 print STDERR
"\nExample:\n";
195 print STDERR
"\tcwstestresult -c mycws -n Performance -p Windows -r PerfomanceTestWindows.html ok\n";