mirror of
https://github.com/curl/curl.git
synced 2026-04-15 01:05:56 +08:00
Change the format of error messages sent to stderr from tests and test
servers. As a workaround to avoid triggering Visual Studio's MSBuild
tool's built-in regexp matcher, and making it mark builds failed for
reasons we don't want them to hard fail.
Roughly, the pattern to avoid is the word "error" (case-insensitive)
in the same line with a colon `:`.
It affected GHA/windows MSVC CI jobs, causing flakiness:
```
CUSTOMBUILD : fopen() failed with error : 13 Permission denied [D:\a\curl\curl\bld\tests\test-ci.vcxproj]
Error opening file: log/4/smtp_sockfilt.log
[...]
CUSTOMBUILD : fopen() failed with error : 13 Permission denied [D:\a\curl\curl\bld\tests\test-ci.vcxproj]
Error opening file: log/8/imap_sockfilt.log
Msg not logged: 00:18:10.656000 > 178 bytes data, server => client
[...]
TESTDONE: 1629 tests out of 1634 reported OK: 99%
Building Custom Rule D:/a/curl/curl/tests/CMakeLists.txt
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): error MSB8066: Custom build for 'D:\a\curl\curl\bld\CMakeFiles\621f80ddbb0fa48179f056ca77842ff0\test-ci.rule;D:\a\curl\curl\tests\CMakeLists.txt' exited with code -1. [D:\a\curl\curl\bld\tests\test-ci.vcxproj]
Error: Process completed with exit code 1.
```
Ref: https://github.com/curl/curl/actions/runs/13643149623/job/38137076210?pr=16490#step:14:3125
Ref: https://github.com/curl/curl/actions/runs/13688765792/job/38277961720?pr=16582#step:14:1717
The `IgnoreStandardErrorWarningFormat="true"` MSBuild Exec option
controls this behavior:
https://learn.microsoft.com/visualstudio/msbuild/exec-task#parameters
I couldn't figure out a way to apply it to CMake builds.
MSBuid pattern matching rules:
353c0f3d37/src/Shared/CanonicalError.cs
https://learn.microsoft.com/visualstudio/msbuild/msbuild-diagnostic-format-for-tasks
Note: There may be further error messages output from runtests scripts,
that use this format, which are not explicitly fatal. They may need
future fixes.
Thanks-to: Dion Williams
Ref: https://github.com/curl/curl/discussions/14854#discussioncomment-12382190
Ref: https://github.com/curl/curl/discussions/14854#discussioncomment-12395224
Closes #16583
86 lines
2.4 KiB
C
86 lines
2.4 KiB
C
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
*
|
|
* This software is licensed as described in the file COPYING, which
|
|
* you should have received as part of this distribution. The terms
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
*
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
* SPDX-License-Identifier: curl
|
|
*
|
|
***************************************************************************/
|
|
#include "test.h"
|
|
|
|
/* test case and code based on https://github.com/curl/curl/issues/3927 */
|
|
|
|
#include "testutil.h"
|
|
#include "warnless.h"
|
|
#include "memdebug.h"
|
|
|
|
static int dload_progress_cb(void *a, curl_off_t b, curl_off_t c,
|
|
curl_off_t d, curl_off_t e)
|
|
{
|
|
(void)a;
|
|
(void)b;
|
|
(void)c;
|
|
(void)d;
|
|
(void)e;
|
|
return 0;
|
|
}
|
|
|
|
static size_t write_cb(char *d, size_t n, size_t l, void *p)
|
|
{
|
|
/* take care of the data here, ignored in this example */
|
|
(void)d;
|
|
(void)p;
|
|
return n*l;
|
|
}
|
|
|
|
static CURLcode run(CURL *hnd, long limit, long time)
|
|
{
|
|
curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_LIMIT, limit);
|
|
curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_TIME, time);
|
|
return curl_easy_perform(hnd);
|
|
}
|
|
|
|
CURLcode test(char *URL)
|
|
{
|
|
CURLcode ret;
|
|
CURL *hnd;
|
|
char buffer[CURL_ERROR_SIZE];
|
|
curl_global_init(CURL_GLOBAL_ALL);
|
|
hnd = curl_easy_init();
|
|
curl_easy_setopt(hnd, CURLOPT_URL, URL);
|
|
curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, write_cb);
|
|
curl_easy_setopt(hnd, CURLOPT_ERRORBUFFER, buffer);
|
|
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 0L);
|
|
curl_easy_setopt(hnd, CURLOPT_XFERINFOFUNCTION, dload_progress_cb);
|
|
|
|
ret = run(hnd, 1, 2);
|
|
if(ret)
|
|
fprintf(stderr, "error (%d) %s\n", ret, buffer);
|
|
|
|
ret = run(hnd, 12000, 1);
|
|
if(ret != CURLE_OPERATION_TIMEDOUT)
|
|
fprintf(stderr, "error (%d) %s\n", ret, buffer);
|
|
else
|
|
ret = CURLE_OK;
|
|
|
|
curl_easy_cleanup(hnd);
|
|
curl_global_cleanup();
|
|
|
|
return ret;
|
|
}
|