Disable incompatible tests on macOS AArch64

This commit also updates related test support classes.

See gh-31539
This commit is contained in:
Johnny Lim 2022-06-28 19:45:26 +09:00 committed by Stephane Nicoll
parent 8c4708982b
commit f591c75ad7
3 changed files with 15 additions and 10 deletions

View File

@ -40,7 +40,7 @@ public @interface DisabledOnOs {
* See {@link org.junit.jupiter.api.condition.DisabledOnOs#value()}. * See {@link org.junit.jupiter.api.condition.DisabledOnOs#value()}.
* @return os * @return os
*/ */
OS os(); OS[] os();
/** /**
* Architecture of the operating system. * Architecture of the operating system.

View File

@ -18,6 +18,7 @@ package org.springframework.boot.testsupport.junit;
import java.util.Optional; import java.util.Optional;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.extension.ConditionEvaluationResult; import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExecutionCondition; import org.junit.jupiter.api.extension.ExecutionCondition;
import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.ExtensionContext;
@ -42,11 +43,15 @@ class DisabledOnOsCondition implements ExecutionCondition {
private ConditionEvaluationResult evaluate(DisabledOnOs annotation) { private ConditionEvaluationResult evaluate(DisabledOnOs annotation) {
String architecture = System.getProperty("os.arch"); String architecture = System.getProperty("os.arch");
String os = System.getProperty("os.name"); String os = System.getProperty("os.name");
if (annotation.os().isCurrentOs() && annotation.architecture().equals(architecture)) { if (annotation.architecture().equals(architecture)) {
String reason = annotation.disabledReason().isEmpty() for (OS targetOs : annotation.os()) {
? String.format("Disabled on OS = %s, architecture = %s", os, architecture) if (targetOs.isCurrentOs()) {
: annotation.disabledReason(); String reason = annotation.disabledReason().isEmpty()
return ConditionEvaluationResult.disabled(reason); ? String.format("Disabled on OS = %s, architecture = %s", os, architecture)
: annotation.disabledReason();
return ConditionEvaluationResult.disabled(reason);
}
}
} }
return ConditionEvaluationResult return ConditionEvaluationResult
.enabled(String.format("Enabled on OS = %s, architecture = %s", os, architecture)); .enabled(String.format("Enabled on OS = %s, architecture = %s", os, architecture));

View File

@ -57,8 +57,8 @@ class SslServerCustomizerTests {
@Test @Test
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@DisabledOnOs(os = OS.LINUX, architecture = "aarch64", @DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64",
disabledReason = "conscrypt doesn't support Linux aarch64, see https://github.com/google/conscrypt/issues/1051") disabledReason = "conscrypt doesn't support Linux/macOS aarch64, see https://github.com/google/conscrypt/issues/1051")
void whenHttp2IsEnabledServerConnectorsHasSslAlpnH2AndHttpConnectionFactories() { void whenHttp2IsEnabledServerConnectorsHasSslAlpnH2AndHttpConnectionFactories() {
Http2 http2 = new Http2(); Http2 http2 = new Http2();
http2.setEnabled(true); http2.setEnabled(true);
@ -71,8 +71,8 @@ class SslServerCustomizerTests {
} }
@Test @Test
@DisabledOnOs(os = OS.LINUX, architecture = "aarch64", @DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64",
disabledReason = "conscrypt doesn't support Linux aarch64, see https://github.com/google/conscrypt/issues/1051") disabledReason = "conscrypt doesn't support Linux/macOS aarch64, see https://github.com/google/conscrypt/issues/1051")
void alpnConnectionFactoryHasNullDefaultProtocolToAllowNegotiationToHttp11() { void alpnConnectionFactoryHasNullDefaultProtocolToAllowNegotiationToHttp11() {
Http2 http2 = new Http2(); Http2 http2 = new Http2();
http2.setEnabled(true); http2.setEnabled(true);