xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame^] | 1 | #*************************************************************************** |
| 2 | # _ _ ____ _ |
| 3 | # Project ___| | | | _ \| | |
| 4 | # / __| | | | |_) | | |
| 5 | # | (__| |_| | _ <| |___ |
| 6 | # \___|\___/|_| \_\_____| |
| 7 | # |
| 8 | # Copyright (C) 2020-2022, Daniel Stenberg, <daniel@haxx.se>, et al. |
| 9 | # Copyright (C) 2020-2022, Marc Hoersken, <info@marc-hoersken.de> |
| 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.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 | # SPDX-License-Identifier: curl |
| 23 | # |
| 24 | ########################################################################### |
| 25 | |
| 26 | use strict; |
| 27 | use warnings; |
| 28 | |
| 29 | my %APPVEYOR_TEST_NAMES; |
| 30 | |
| 31 | sub appveyor_check_environment { |
| 32 | if(defined $ENV{'APPVEYOR_API_URL'} && $ENV{'APPVEYOR_API_URL'}) { |
| 33 | return 1; |
| 34 | } |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | sub appveyor_create_test_result { |
| 39 | my ($curl, $testnum, $testname)=@_; |
| 40 | $testname =~ s/\\/\\\\/g; |
| 41 | $testname =~ s/\'/\\\'/g; |
| 42 | $testname =~ s/\"/\\\"/g; |
| 43 | my $appveyor_baseurl="$ENV{'APPVEYOR_API_URL'}"; |
| 44 | my $appveyor_result=`$curl --silent --noproxy "*" \\ |
| 45 | --header "Content-Type: application/json" \\ |
| 46 | --data " |
| 47 | { |
| 48 | 'testName': '$testname', |
| 49 | 'testFramework': 'runtests.pl', |
| 50 | 'fileName': 'tests/data/test$testnum', |
| 51 | 'outcome': 'Running' |
| 52 | } |
| 53 | " \\ |
| 54 | "$appveyor_baseurl/api/tests"`; |
| 55 | print "AppVeyor API result: $appveyor_result\n" if ($appveyor_result); |
| 56 | $APPVEYOR_TEST_NAMES{$testnum}=$testname; |
| 57 | } |
| 58 | |
| 59 | sub appveyor_update_test_result { |
| 60 | my ($curl, $testnum, $error, $start, $stop)=@_; |
| 61 | my $testname=$APPVEYOR_TEST_NAMES{$testnum}; |
| 62 | if(!defined $testname) { |
| 63 | return; |
| 64 | } |
| 65 | if(!defined $stop) { |
| 66 | $stop = $start; |
| 67 | } |
| 68 | my $appveyor_duration = sprintf("%.0f", ($stop-$start)*1000); |
| 69 | my $appveyor_outcome; |
| 70 | my $appveyor_category; |
| 71 | if($error == 2) { |
| 72 | $appveyor_outcome = 'Ignored'; |
| 73 | $appveyor_category = 'Error'; |
| 74 | } |
| 75 | elsif($error < 0) { |
| 76 | $appveyor_outcome = 'NotRunnable'; |
| 77 | $appveyor_category = 'Warning'; |
| 78 | } |
| 79 | elsif(!$error) { |
| 80 | $appveyor_outcome = 'Passed'; |
| 81 | $appveyor_category = 'Information'; |
| 82 | } |
| 83 | else { |
| 84 | $appveyor_outcome = 'Failed'; |
| 85 | $appveyor_category = 'Error'; |
| 86 | } |
| 87 | my $appveyor_baseurl="$ENV{'APPVEYOR_API_URL'}"; |
| 88 | my $appveyor_result=`$curl --silent --noproxy "*" --request PUT \\ |
| 89 | --header "Content-Type: application/json" \\ |
| 90 | --data " |
| 91 | { |
| 92 | 'testName': '$testname', |
| 93 | 'testFramework': 'runtests.pl', |
| 94 | 'fileName': 'tests/data/test$testnum', |
| 95 | 'outcome': '$appveyor_outcome', |
| 96 | 'durationMilliseconds': $appveyor_duration, |
| 97 | 'ErrorMessage': 'Test $testnum $appveyor_outcome' |
| 98 | } |
| 99 | " \\ |
| 100 | "$appveyor_baseurl/api/tests"`; |
| 101 | print "AppVeyor API result: $appveyor_result\n" if ($appveyor_result); |
| 102 | if($appveyor_category eq 'Error') { |
| 103 | $appveyor_result=`$curl --silent --noproxy "*" \\ |
| 104 | --header "Content-Type: application/json" \\ |
| 105 | --data " |
| 106 | { |
| 107 | 'message': '$appveyor_outcome: $testname', |
| 108 | 'category': '$appveyor_category', |
| 109 | 'details': 'Test $testnum $appveyor_outcome' |
| 110 | } |
| 111 | " \\ |
| 112 | "$appveyor_baseurl/api/build/messages"`; |
| 113 | print "AppVeyor API result: $appveyor_result\n" if ($appveyor_result); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | 1; |