##// END OF EJS Templates
run_tests.pl: do not return error code when there are failed tests
Jani Honkonen -
r2079:7d9cfff99e14
parent child
Show More
@@ -1,95 +1,95
1 use Cwd;
1 use Cwd;
2 use Cwd 'abs_path';
2 use Cwd 'abs_path';
3 use File::Basename;
3 use File::Basename;
4 use File::Copy;
4 use File::Copy;
5 use feature "switch";
5 use feature "switch";
6 use lib 'tools';
6 use lib 'tools';
7 use Jobs;
7 use Jobs;
8
8
9 # read command line params
9 # read command line params
10 my $jobname = shift;
10 my $jobname = shift;
11
11
12 # read ini file
12 # read ini file
13 my $inifile = File::Basename::dirname($0) . "/jobs.ini";
13 my $inifile = File::Basename::dirname($0) . "/jobs.ini";
14 my %job = Jobs::get($inifile, $jobname);
14 my %job = Jobs::get($inifile, $jobname);
15
15
16 # set/get paths
16 # set/get paths
17 my $root_path = abs_path();
17 my $root_path = abs_path();
18 my $bin_path = "$root_path/bin/" . $job{'Config'} . "/";
18 my $bin_path = "$root_path/bin/" . $job{'Config'} . "/";
19 my $reports_path = "test-reports";
19 my $reports_path = "test-reports";
20
20
21 # create reports path
21 # create reports path
22 mkdir $reports_path;
22 mkdir $reports_path;
23
23
24 # setup environment for running tests
24 # setup environment for running tests
25 given ($job{'Platform'}) {
25 given ($job{'Platform'}) {
26
26
27 when ("Win7") {
27 when ("Win7") {
28 # Add qtdir to path
28 # Add qtdir to path
29 $ENV{'PATH'} .= ";" . $job{'QtDir'} . "\\bin";
29 $ENV{'PATH'} .= ";" . $job{'QtDir'} . "\\bin";
30
30
31 # replace / -> \
31 # replace / -> \
32 $ENV{'PATH'} =~ s/\//\\/g;
32 $ENV{'PATH'} =~ s/\//\\/g;
33 }
33 }
34
34
35 when ("Linux") {
35 when ("Linux") {
36 # Add qtdir to path
36 # Add qtdir to path
37 $ENV{'PATH'} = $job{'QtDir'} . "/bin:" . $ENV{'PATH'};
37 $ENV{'PATH'} = $job{'QtDir'} . "/bin:" . $ENV{'PATH'};
38
38
39 # If this is not set we get "cannot connect to X server" errors
39 # If this is not set we get "cannot connect to X server" errors
40 $ENV{'DISPLAY'} = ":0.0";
40 $ENV{'DISPLAY'} = ":0.0";
41 }
41 }
42
42
43 when ("Mac") {
43 when ("Mac") {
44 # Set QML_IMPORT_PATH point to QML plugin dir
44 # Set QML_IMPORT_PATH point to QML plugin dir
45 $ENV{'QML_IMPORT_PATH'} = $bin_path;
45 $ENV{'QML_IMPORT_PATH'} = $bin_path;
46 }
46 }
47 }
47 }
48
48
49 # Go through all the files in the test folder
49 # Go through all the files in the test folder
50 # autotest is an executable beginning with "tst_"
50 # autotest is an executable beginning with "tst_"
51 my $script_exit_status = 0;
51 my $script_exit_status = 0;
52 opendir (TESTAPPDIR, "$bin_path") or die "Couldn't open test app dir";
52 opendir (TESTAPPDIR, "$bin_path") or die "Couldn't open test app dir";
53 @files = <TESTAPPDIR>;
53 @files = <TESTAPPDIR>;
54 while ($testapp = readdir TESTAPPDIR) {
54 while ($testapp = readdir TESTAPPDIR) {
55 if (index($testapp, "tst_") == 0) {
55 if (index($testapp, "tst_") == 0) {
56 if (-x "$bin_path$testapp") {
56 if (-x "$bin_path$testapp") {
57 my $status = executeTestApp($testapp);
57 my $status = executeTestApp($testapp);
58 if ($status != 0) {
58 if ($status != 0) {
59 $script_exit_status = $status;
59 $script_exit_status = $status;
60 }
60 }
61 } else {
61 } else {
62 #print "file $testapp not executable\n";
62 #print "file $testapp not executable\n";
63 }
63 }
64 }
64 }
65 }
65 }
66 closedir TESTAPPDIR;
66 closedir TESTAPPDIR;
67
67
68 print "\n*** script exit status : $script_exit_status ***\n\n";
68 # Do not return error codes for bamboo.
69 exit($script_exit_status);
69 # Bamboo will determine test failures by parsing the xml logs.
70 exit(0);
70
71
71
72
72 sub executeTestApp($) {
73 sub executeTestApp($) {
73 my $testapp = $_[0];
74 my $testapp = $_[0];
74
75
75 # On OSX the actual test binary is in a sub folder
76 # On OSX the actual test binary is in a sub folder
76 my $cmd_postfix = "";
77 my $cmd_postfix = "";
77 if ($^O eq "darwin") {
78 if ($^O eq "darwin") {
78 $cmd_postfix = "/Contents/MacOS/$testapp";
79 $cmd_postfix = "/Contents/MacOS/$testapp";
79 $cmd_postfix = substr($cmd_postfix, 0, rindex($cmd_postfix, ".app"));
80 $cmd_postfix = substr($cmd_postfix, 0, rindex($cmd_postfix, ".app"));
80 }
81 }
81
82
82 my $cmd = "$bin_path$testapp$cmd_postfix -xunitxml -o $reports_path/$testapp.xml";
83 my $cmd = "$bin_path$testapp$cmd_postfix -xunitxml -o $reports_path/$testapp.xml";
83 print "executing: $cmd\n";
84 print "executing: $cmd\n";
84 system($cmd);
85 system($cmd);
85
86
86 # From http://perldoc.perl.org/perlvar.html about $?:
87 # From http://perldoc.perl.org/perlvar.html about $?:
87 # The upper eight bits reflect specific error conditions encountered by the
88 # The upper eight bits reflect specific error conditions encountered by the
88 # program (the program's exit() value). The lower eight bits reflect
89 # program (the program's exit() value). The lower eight bits reflect
89 # mode of failure, like signal death and core dump information.
90 # mode of failure, like signal death and core dump information.
90 # See wait(2) for details.
91 # See wait(2) for details.
91 my $exit_status = $? >> 8;
92 my $exit_status = $? >> 8;
92 print "\texit status: $exit_status\n";
93 print "\texit status: $exit_status\n";
93
94 return $exit_status;
94 return $exit_status;
95 }
95 }
General Comments 0
You need to be logged in to leave comments. Login now