Skip to content

Commit

Permalink
Merge branch 'main' into renovate/mockk
Browse files Browse the repository at this point in the history
  • Loading branch information
e5l authored Jan 13, 2025
2 parents 0eebf7e + 4da9f59 commit d55c5df
Show file tree
Hide file tree
Showing 25 changed files with 159 additions and 136 deletions.
44 changes: 25 additions & 19 deletions ktor-client/ktor-client-curl/desktop/interop/include/curl/curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
*/

#ifdef CURL_NO_OLDIES
#define CURL_STRICTER
#define CURL_STRICTER /* not used since 8.11.0 */
#endif

/* Compile-time deprecation macros. */
#if (defined(__GNUC__) && \
((__GNUC__ > 12) || ((__GNUC__ == 12) && (__GNUC_MINOR__ >= 1 ))) || \
defined(__IAR_SYSTEMS_ICC__)) && \
!defined(__INTEL_COMPILER) && \
#if (defined(__GNUC__) && \
((__GNUC__ > 12) || ((__GNUC__ == 12) && (__GNUC_MINOR__ >= 1))) || \
(defined(__clang__) && __clang_major__ >= 3) || \
defined(__IAR_SYSTEMS_ICC__)) && \
!defined(__INTEL_COMPILER) && \
!defined(CURL_DISABLE_DEPRECATION) && !defined(BUILDING_LIBCURL)
#define CURL_DEPRECATED(version, message) \
__attribute__((deprecated("since " # version ". " message)))
Expand Down Expand Up @@ -113,13 +114,8 @@
extern "C" {
#endif

#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
typedef struct Curl_easy CURL;
typedef struct Curl_share CURLSH;
#else
typedef void CURL;
typedef void CURLSH;
#endif

/*
* libcurl external API function linkage decorations.
Expand Down Expand Up @@ -253,12 +249,12 @@ typedef int (*curl_xferinfo_callback)(void *clientp,
#endif

#ifndef CURL_MAX_WRITE_SIZE
/* Tests have proven that 20K is a very bad buffer size for uploads on
Windows, while 16K for some odd reason performed a lot better.
We do the ifndef check to allow this value to easier be changed at build
time for those who feel adventurous. The practical minimum is about
400 bytes since libcurl uses a buffer of this size as a scratch area
(unrelated to network send operations). */
/* Tests have proven that 20K is a bad buffer size for uploads on Windows,
while 16K for some odd reason performed a lot better. We do the ifndef
check to allow this value to easier be changed at build time for those
who feel adventurous. The practical minimum is about 400 bytes since
libcurl uses a buffer of this size as a scratch area (unrelated to
network send operations). */
#define CURL_MAX_WRITE_SIZE 16384
#endif

Expand Down Expand Up @@ -555,14 +551,14 @@ typedef enum {
CURLE_FTP_COULDNT_USE_REST, /* 31 - the REST command failed */
CURLE_OBSOLETE32, /* 32 - NOT USED */
CURLE_RANGE_ERROR, /* 33 - RANGE "command" did not work */
CURLE_HTTP_POST_ERROR, /* 34 */
CURLE_OBSOLETE34, /* 34 */
CURLE_SSL_CONNECT_ERROR, /* 35 - wrong when connecting with SSL */
CURLE_BAD_DOWNLOAD_RESUME, /* 36 - could not resume download */
CURLE_FILE_COULDNT_READ_FILE, /* 37 */
CURLE_LDAP_CANNOT_BIND, /* 38 */
CURLE_LDAP_SEARCH_FAILED, /* 39 */
CURLE_OBSOLETE40, /* 40 - NOT USED */
CURLE_FUNCTION_NOT_FOUND, /* 41 - NOT USED starting with 7.53.0 */
CURLE_OBSOLETE41, /* 41 - NOT USED starting with 7.53.0 */
CURLE_ABORTED_BY_CALLBACK, /* 42 */
CURLE_BAD_FUNCTION_ARGUMENT, /* 43 */
CURLE_OBSOLETE44, /* 44 - NOT USED */
Expand Down Expand Up @@ -647,6 +643,12 @@ typedef enum {
#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
the obsolete stuff removed! */

/* removed in 7.53.0 */
#define CURLE_FUNCTION_NOT_FOUND CURLE_OBSOLETE41

/* removed in 7.56.0 */
#define CURLE_HTTP_POST_ERROR CURLE_OBSOLETE34

/* Previously obsolete error code reused in 7.38.0 */
#define CURLE_OBSOLETE16 CURLE_HTTP2

Expand Down Expand Up @@ -942,6 +944,9 @@ typedef enum {
a client certificate for authentication. (Schannel) */
#define CURLSSLOPT_AUTO_CLIENT_CERT (1<<5)

/* If possible, send data using TLS 1.3 early data */
#define CURLSSLOPT_EARLYDATA (1<<6)

/* The default connection attempt delay in milliseconds for happy eyeballs.
CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.3 and happy-eyeballs-timeout-ms.d document
this value, keep them in sync. */
Expand Down Expand Up @@ -2953,7 +2958,8 @@ typedef enum {
CURLINFO_QUEUE_TIME_T = CURLINFO_OFF_T + 65,
CURLINFO_USED_PROXY = CURLINFO_LONG + 66,
CURLINFO_POSTTRANSFER_TIME_T = CURLINFO_OFF_T + 67,
CURLINFO_LASTONE = 67
CURLINFO_EARLYDATA_SENT_T = CURLINFO_OFF_T + 68,
CURLINFO_LASTONE = 68
} CURLINFO;

/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

/* This is the version number of the libcurl package from which this header
file origins: */
#define LIBCURL_VERSION "8.10.1"
#define LIBCURL_VERSION "8.11.1"

/* The numeric version number is also available "in parts" by using these
defines: */
#define LIBCURL_VERSION_MAJOR 8
#define LIBCURL_VERSION_MINOR 10
#define LIBCURL_VERSION_MINOR 11
#define LIBCURL_VERSION_PATCH 1

/* This is the numeric version of the libcurl version number, meant for easier
Expand All @@ -59,7 +59,7 @@
CURL_VERSION_BITS() macro since curl's own configure script greps for it
and needs it to contain the full number.
*/
#define LIBCURL_VERSION_NUM 0x080a01
#define LIBCURL_VERSION_NUM 0x080b01

/*
* This is the date and time when the full source package was created. The
Expand All @@ -70,7 +70,7 @@
*
* "2007-11-23"
*/
#define LIBCURL_TIMESTAMP "2024-09-18"
#define LIBCURL_TIMESTAMP "2024-12-11"

#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
#define CURL_AT_LEAST_VERSION(x,y,z) \
Expand Down
18 changes: 7 additions & 11 deletions ktor-client/ktor-client-curl/desktop/interop/include/curl/multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@
extern "C" {
#endif

#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
typedef struct Curl_multi CURLM;
#else
typedef void CURLM;
#endif

typedef enum {
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
Expand Down Expand Up @@ -248,13 +244,13 @@ CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
* The data the returned pointer points to will not survive calling
* curl_multi_cleanup().
*
* The 'CURLMsg' struct is meant to be very simple and only contain
* very basic information. If more involved information is wanted,
* we will provide the particular "transfer handle" in that struct
* and that should/could/would be used in subsequent
* curl_easy_getinfo() calls (or similar). The point being that we
* must never expose complex structs to applications, as then we will
* undoubtably get backwards compatibility problems in the future.
* The 'CURLMsg' struct is meant to be simple and only contain basic
* information. If more involved information is wanted, we will
* provide the particular "transfer handle" in that struct and that
* should/could/would be used in subsequent curl_easy_getinfo() calls
* (or similar). The point being that we must never expose complex
* structs to applications, as then we will undoubtably get backwards
* compatibility problems in the future.
*
* Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
* of structs. It also writes the number of messages left in the
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified ktor-client/ktor-client-curl/desktop/interop/lib/mingwX64/libz.a
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.server.config

import io.ktor.server.engine.*
import io.ktor.utils.io.*

internal actual val CONFIG_PATH: List<String>
get() = listOfNotNull(
Expand All @@ -18,6 +17,7 @@ internal actual val CONFIG_PATH: List<String>
public actual val configLoaders: List<ConfigLoader>
get() = _configLoaders

@Suppress("ObjectPropertyName")
private val _configLoaders: MutableList<ConfigLoader> = mutableListOf()

public fun addConfigLoader(loader: ConfigLoader) {
Expand Down
5 changes: 2 additions & 3 deletions ktor-server/ktor-server-test-base/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

description = ""
Expand All @@ -10,7 +10,7 @@ kotlin.sourceSets {
commonMain {
dependencies {
api(project(":ktor-server:ktor-server-test-host"))
api(libs.kotlin.test)
api(project(":ktor-shared:ktor-test-base"))
}
}

Expand All @@ -21,7 +21,6 @@ kotlin.sourceSets {
api(project(":ktor-client:ktor-client-apache"))
api(project(":ktor-network:ktor-network-tls:ktor-network-tls-certificates"))
api(project(":ktor-server:ktor-server-plugins:ktor-server-call-logging"))
api(project(":ktor-shared:ktor-test-base"))

if (jetty_alpn_boot_version != null) {
api(libs.jetty.alpn.boot)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.server.test.base
Expand All @@ -16,21 +16,15 @@ expect abstract class BaseTest() {
open fun afterTest()

fun collectUnhandledException(error: Throwable) // TODO: better name?
fun runTest(timeout: Duration = 60.seconds, block: suspend CoroutineScope.() -> Unit): TestResult
fun runTest(
timeout: Duration = 60.seconds,
retries: Int = DEFAULT_RETRIES,
block: suspend CoroutineScope.() -> Unit
): TestResult
}

fun BaseTest.runTest(
retry: Int,
timeout: Duration = this.timeout,
block: suspend CoroutineScope.() -> Unit
): TestResult {
lateinit var lastCause: Throwable
repeat(retry) {
try {
return runTest(timeout, block)
} catch (cause: Throwable) {
lastCause = cause
}
}
throw lastCause
}
/**
* Defaults to `1` on all platforms except for JVM.
* On JVM retries are disabled as we use test-retry Gradle plugin instead.
*/
internal expect val DEFAULT_RETRIES: Int
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2014-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.server.test.base

import io.ktor.util.*
import kotlinx.coroutines.test.TestResult
import kotlin.test.Test
import kotlin.test.fail

class BaseTestTest : BaseTest() {

@Test
fun `runTest - retry test by default on non-JVM platform`(): TestResult {
var retryCount = 0
return runTest {
if (!PlatformUtils.IS_JVM && retryCount++ < 1) fail("This test should be retried")
}
}

@Test
fun `runTest - don't retry test by default on JVM platform`(): TestResult {
var retryCount = 0
return runTest {
if (PlatformUtils.IS_JVM && retryCount++ > 0) fail("This test should not be retried")
}
}

@Test
fun `runTest - more than one retry`(): TestResult {
var retryCount = 0
return runTest(retries = 3) {
if (retryCount++ < 3) fail("This test should be retried")
}
}

@Test
fun `runTest - retry should work with collected exceptions`(): TestResult {
var retryCount = 0
return runTest(retries = 1) {
if (retryCount++ < 1) collectUnhandledException(Exception("This test should be retried"))
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*
* Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2014-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.server.test.base

import io.ktor.test.*
import io.ktor.test.dispatcher.*
import io.ktor.test.junit.*
import io.ktor.test.junit.coroutines.*
Expand Down Expand Up @@ -47,13 +48,20 @@ actual abstract class BaseTest actual constructor() {

actual fun runTest(
timeout: Duration,
retries: Int,
block: suspend CoroutineScope.() -> Unit
): TestResult = runTestWithRealTime(CoroutineName("test-$testName"), timeout) {
beforeTest()
try {
block()
} finally {
afterTest()
): TestResult = retryTest(retries) { retry ->
runTestWithRealTime(CoroutineName("test-$testName"), timeout) {
if (retry > 0) println("[Retry $retry/$retries]")
beforeTest()
try {
block()
} finally {
afterTest()
}
}
}
}

/** On JVM retries are disabled as we use test-retry Gradle plugin instead. */
internal actual const val DEFAULT_RETRIES: Int = 0
Loading

0 comments on commit d55c5df

Please sign in to comment.