update dev300-m58
[ooovba.git] / sc / source / ui / vba / testvba / runTests.pl
blob1f449e58621e89def0677c8cae23c31407682ffc
1 #!/usr/bin/perl -w
2 use URI::Escape;
3 use File::Basename;
4 use Cwd;
5 use Cwd 'abs_path';
7 $numArgs = $#ARGV + 1;
8 print "thanks, you gave me $numArgs command-line arguments.\n";
10 foreach $argnum (0 .. $#ARGV) {
11 print "$ARGV[$argnum]\n";
15 my $binDir = abs_path( dirname($0) );
17 my $sysDir = "unix";
18 my $fileSep = "/";
19 my $theResult;
20 my $officepath = shift || die "please specify path to office installation program dir";
21 my $DocName = shift || "";
22 my $programpath = "$officepath"."3/program:$officepath/program:";
23 my $basiclibrarypath = "$officepath/basis3.2/program";
24 my $urelibpath = "$officepath/ure/lib";
25 my $binext = "";
26 my $testDocDir = "$binDir/TestDocuments";
27 my $testLogDir = "$binDir/Logs";
28 my $testclientname = "testclient";
29 my $buildtestclient = "../../../../unxlngi6.pro/bin/$testclientname";
31 # test testclient
32 if ( -e "$buildtestclient" )
34 print "use the latest build\n";
35 system( "cp $buildtestclient ." );
37 elsif ( !( -e "$testclientname" ) )
39 print "$testclientname do not exist\n";
40 exit;
43 # test for uname
44 system("uname");
45 $exit_value = $? >> 8;
46 $signal_num = $? & 127;
47 $dumped_core = $? & 128;
49 $failed = ( $exit_value || $signal_num || $dumped_core );
51 print "$failed = ( $exit_value || $signal_num || $dumped_core )\n";
53 if ( !$failed && open(UNAME, "uname -a|") ) {
54 $theResult = <UNAME>;
55 close(UNAME);
56 if ( $theResult =~ /^CYGWIN/ ) {
57 # windows under cygwin
58 $sysDir = "win" ;
59 $tmpPath=$ENV{"PATH"};
60 $ENV{"PATH"} = "$officepath:$tmpPath";
61 $testDocDir=`cygpath -m $testDocDir`;
62 uri_escape($testDocDir);
63 # hacky windows url construction
64 $testDocDir="file:///$testDocDir";
66 chomp($testDocDir);
67 #print "*** doc dir is $testDocDir\n";
68 $testLogDir = `cygpath -m "$testLogDir"`;
69 uri_escape($testLogDir);
70 $testLogDir="file:///$testLogDir";
71 chomp($testLogDir);
72 #print "*** log dir is $testLogDir\n";
73 $binext = ".exe";
75 else{
76 # unix we need to find sal etc. ( from the office path )
77 my $tmpPath=$ENV{"PATH"};
78 $ENV{"PATH"} = "$programpath:$basiclibrarypath:$urelibpath/../bin:$tmpPath";
79 $tmpPATH = $ENV{"LD_LIBRARY_PATH"};
80 $ENV{"LD_LIBRARY_PATH"} = "$officepath:$programpath:$basiclibrarypath:$urelibpath:$urelibpath../bin/javaldx:$urelibpath/../bin:$tmpPATH";
81 $ENV{"LD_LIBRARY_PATH"} = "$officepath:$programpath:$basiclibrarypath:$urelibpath:$tmpPATH";
82 my $testPath = $ENV{"LD_LIBRARY_PATH"};
83 print "$testPath\n";
84 $testPath = $ENV{"PATH"};
85 print "$testPath\n";
86 $ENV{"STAR_RESOURCEPATH"} = "$officepath/basis3.0/program/resource";
87 $ENV{"SAL_ALLOW_LINKOO_SYMLINKS"} = "1";
88 $testPath = $ENV{"LANG"};
89 print "$testPath\n";
92 else
94 # ordinary windows, not sure if this will actually work
95 $sysDir = "win" ;
96 $tmpPath=$ENV{"PATH"};
97 $ENV{"PATH"} = "$tmpPath;$officepath";
98 $binext = ".exe";
101 # the exe needs system paths or urls ( urls are by far the least troublesome )
103 my $runCmd = "";
104 my $analyseCmd = "";
106 if ( "$DocName" eq "" )
108 $runCmd = "$binDir/testclient$binext $testDocDir $testLogDir";
109 $analyseCmd = "perl $binDir/testResults.pl $binDir/Logs $binDir/TestDocuments/logs/$sysDir";
111 else
113 $runCmd = "$binDir/testclient$binext $testDocDir $testLogDir $testDocDir/$DocName";
114 $analyseCmd = "perl $binDir/testResult.pl $binDir/Logs $binDir/TestDocuments/logs/$sysDir $DocName";
116 print "runCmd = $runCmd\n";
118 system ("rm -rf $testLogDir/*");
119 my $status = system( $runCmd );
120 print "analyseCmd = $analyseCmd\n";
121 $status = system( $analyseCmd );