From f591c75ad727d161a6f048f14612b592cdb48e4f Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Tue, 28 Jun 2022 19:45:26 +0900 Subject: [PATCH] Disable incompatible tests on macOS AArch64 This commit also updates related test support classes. See gh-31539 --- .../boot/testsupport/junit/DisabledOnOs.java | 2 +- .../testsupport/junit/DisabledOnOsCondition.java | 15 ++++++++++----- .../embedded/jetty/SslServerCustomizerTests.java | 8 ++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOs.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOs.java index d691eac3a8..0b0dd15b69 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOs.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOs.java @@ -40,7 +40,7 @@ public @interface DisabledOnOs { * See {@link org.junit.jupiter.api.condition.DisabledOnOs#value()}. * @return os */ - OS os(); + OS[] os(); /** * Architecture of the operating system. diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOsCondition.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOsCondition.java index 3b644b2006..3968c0ba6a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOsCondition.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/DisabledOnOsCondition.java @@ -18,6 +18,7 @@ package org.springframework.boot.testsupport.junit; import java.util.Optional; +import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.extension.ConditionEvaluationResult; import org.junit.jupiter.api.extension.ExecutionCondition; import org.junit.jupiter.api.extension.ExtensionContext; @@ -42,11 +43,15 @@ class DisabledOnOsCondition implements ExecutionCondition { private ConditionEvaluationResult evaluate(DisabledOnOs annotation) { String architecture = System.getProperty("os.arch"); String os = System.getProperty("os.name"); - if (annotation.os().isCurrentOs() && annotation.architecture().equals(architecture)) { - String reason = annotation.disabledReason().isEmpty() - ? String.format("Disabled on OS = %s, architecture = %s", os, architecture) - : annotation.disabledReason(); - return ConditionEvaluationResult.disabled(reason); + if (annotation.architecture().equals(architecture)) { + for (OS targetOs : annotation.os()) { + if (targetOs.isCurrentOs()) { + String reason = annotation.disabledReason().isEmpty() + ? String.format("Disabled on OS = %s, architecture = %s", os, architecture) + : annotation.disabledReason(); + return ConditionEvaluationResult.disabled(reason); + } + } } return ConditionEvaluationResult .enabled(String.format("Enabled on OS = %s, architecture = %s", os, architecture)); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/SslServerCustomizerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/SslServerCustomizerTests.java index 556384575a..5cc9815eb4 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/SslServerCustomizerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/SslServerCustomizerTests.java @@ -57,8 +57,8 @@ class SslServerCustomizerTests { @Test @SuppressWarnings("rawtypes") - @DisabledOnOs(os = OS.LINUX, architecture = "aarch64", - disabledReason = "conscrypt doesn't support Linux aarch64, see https://github.com/google/conscrypt/issues/1051") + @DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64", + disabledReason = "conscrypt doesn't support Linux/macOS aarch64, see https://github.com/google/conscrypt/issues/1051") void whenHttp2IsEnabledServerConnectorsHasSslAlpnH2AndHttpConnectionFactories() { Http2 http2 = new Http2(); http2.setEnabled(true); @@ -71,8 +71,8 @@ class SslServerCustomizerTests { } @Test - @DisabledOnOs(os = OS.LINUX, architecture = "aarch64", - disabledReason = "conscrypt doesn't support Linux aarch64, see https://github.com/google/conscrypt/issues/1051") + @DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64", + disabledReason = "conscrypt doesn't support Linux/macOS aarch64, see https://github.com/google/conscrypt/issues/1051") void alpnConnectionFactoryHasNullDefaultProtocolToAllowNegotiationToHttp11() { Http2 http2 = new Http2(); http2.setEnabled(true);