| 1 |
#*************************************************************************** |
| 2 |
# _ _ ____ _ |
| 3 |
# Project ___| | | | _ \| | |
| 4 |
# / __| | | | |_) | | |
| 5 |
# | (__| |_| | _ <| |___ |
| 6 |
# \___|\___/|_| \_\_____| |
| 7 |
# |
| 8 |
# Copyright (C) 2020, Daniel Stenberg, <[email protected]>, et al. |
| 9 |
# Copyright (C) 2020, Marc Hoersken, <[email protected]> |
| 10 |
# |
| 11 |
# This software is licensed as described in the file COPYING, which |
| 12 |
# you should have received as part of this distribution. The terms |
| 13 |
# are also available at https://curl.haxx.se/docs/copyright.html. |
| 14 |
# |
| 15 |
# You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 16 |
# copies of the Software, and permit persons to whom the Software is |
| 17 |
# furnished to do so, under the terms of the COPYING file. |
| 18 |
# |
| 19 |
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 20 |
# KIND, either express or implied. |
| 21 |
# |
| 22 |
########################################################################### |
| 23 |
|
| 24 |
use strict; |
| 25 |
use warnings; |
| 26 |
|
| 27 |
my %APPVEYOR_TEST_NAMES; |
| 28 |
|
| 29 |
sub appveyor_check_environment { |
| 30 |
if(defined $ENV{'APPVEYOR_API_URL'} && $ENV{'APPVEYOR_API_URL'}) { |
| 31 |
return 1; |
| 32 |
} |
| 33 |
return 0; |
| 34 |
} |
| 35 |
|
| 36 |
sub appveyor_create_test_result { |
| 37 |
my ($testnum, $testname)=@_; |
| 38 |
$testname =~ s/\\/\\\\/g; |
| 39 |
$testname =~ s/\'/\\\'/g; |
| 40 |
$testname =~ s/\"/\\\"/g; |
| 41 |
my $appveyor_baseurl="$ENV{'APPVEYOR_API_URL'}"; |
| 42 |
my $appveyor_result=`curl --silent --noproxy "*" \\ |
| 43 |
--header "Content-Type: application/json" \\ |
| 44 |
--data " |
| 45 |
{ |
| 46 |
'testName': '$testname', |
| 47 |
'testFramework': 'runtests.pl', |
| 48 |
'fileName': 'tests/data/test$testnum', |
| 49 |
'outcome': 'Running' |
| 50 |
} |
| 51 |
" \\ |
| 52 |
"$appveyor_baseurl/api/tests"`; |
| 53 |
print $appveyor_result; |
| 54 |
$APPVEYOR_TEST_NAMES{$testnum}=$testname; |
| 55 |
} |
| 56 |
|
| 57 |
sub appveyor_update_test_result { |
| 58 |
my ($testnum, $error, $start, $stop)=@_; |
| 59 |
my $testname=$APPVEYOR_TEST_NAMES{$testnum}; |
| 60 |
if(!defined $testname) { |
| 61 |
return; |
| 62 |
} |
| 63 |
if(!defined $stop) { |
| 64 |
$stop = $start; |
| 65 |
} |
| 66 |
my $appveyor_duration = sprintf("%.0f", ($stop-$start)*1000); |
| 67 |
my $appveyor_outcome; |
| 68 |
my $appveyor_category; |
| 69 |
if($error == 2) { |
| 70 |
$appveyor_outcome = 'Ignored'; |
| 71 |
$appveyor_category = 'Warning'; |
| 72 |
} |
| 73 |
elsif($error < 0) { |
| 74 |
$appveyor_outcome = 'NotRunnable'; |
| 75 |
$appveyor_category = 'Warning'; |
| 76 |
} |
| 77 |
elsif(!$error) { |
| 78 |
$appveyor_outcome = 'Passed'; |
| 79 |
$appveyor_category = 'Information'; |
| 80 |
} |
| 81 |
else { |
| 82 |
$appveyor_outcome = 'Failed'; |
| 83 |
$appveyor_category = 'Error'; |
| 84 |
} |
| 85 |
my $appveyor_baseurl="$ENV{'APPVEYOR_API_URL'}"; |
| 86 |
my $appveyor_result=`curl --silent --noproxy "*" --request PUT \\ |
| 87 |
--header "Content-Type: application/json" \\ |
| 88 |
--data " |
| 89 |
{ |
| 90 |
'testName': '$testname', |
| 91 |
'testFramework': 'runtests.pl', |
| 92 |
'fileName': 'tests/data/test$testnum', |
| 93 |
'outcome': '$appveyor_outcome', |
| 94 |
'durationMilliseconds': $appveyor_duration |
| 95 |
} |
| 96 |
" \\ |
| 97 |
"$appveyor_baseurl/api/tests"`; |
| 98 |
print $appveyor_result; |
| 99 |
if($appveyor_category eq 'Error') { |
| 100 |
$appveyor_result=`curl --silent --noproxy "*" \\ |
| 101 |
--header "Content-Type: application/json" \\ |
| 102 |
--data " |
| 103 |
{ |
| 104 |
'message': '$testname $appveyor_outcome', |
| 105 |
'category': '$appveyor_category', |
| 106 |
'details': 'Test $testnum $appveyor_outcome' |
| 107 |
} |
| 108 |
" \\ |
| 109 |
"$appveyor_baseurl/api/build/messages"`; |
| 110 |
print $appveyor_result; |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
1; |