[tests] Execute tests on older macOS bots with a timeout. (#14593)

This prevents a single test hang from breaking the entire test run.

Also bump timeout to 45 minutes.
This commit is contained in:
Rolf Bjarne Kvinge 2022-04-04 19:16:48 +02:00 коммит произвёл GitHub
Родитель 612c32ca20
Коммит 42d561c623
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 90 добавлений и 26 удалений

Просмотреть файл

@ -66,9 +66,10 @@ run-dotnet-sim: $(TARGETS)
$(DOTNET) build -t:Run size-comparison/MySingleView/dotnet/MySingleView.csproj /p:Configuration=Release --runtime iossimulator-x64 /p:Platform=iPhoneSimulator /bl:$@.binlog
# this target will copy NuGet.config and global.json to the directories that need it for their .NET build to work correctly.
copy-dotnet-config: $(TARGETS)
$(Q) for dir in $(abspath $(TOP))/tests/*/dotnet $(abspath $(TOP))/tests/linker/*/*/dotnet; do \
$(CP) -c NuGet.config global.json "$$dir"; \
rsync -a NuGet.config global.json "$$dir"; \
done
$(Q) $(CP) -c NuGet.config global.json $(TOP)/external/Touch.Unit/Touch.Client/dotnet
$(Q) $(CP) -c NuGet.config global.json $(TOP)/external/MonoTouch.Dialog/MonoTouch.Dialog/dotnet
$(Q) rsync -a NuGet.config global.json $(TOP)/external/Touch.Unit/Touch.Client/dotnet
$(Q) rsync -a NuGet.config global.json $(TOP)/external/MonoTouch.Dialog/MonoTouch.Dialog/dotnet

Просмотреть файл

@ -52,6 +52,7 @@ for app in linker/*/*/dotnet/*/bin/*/*/*/*.app */dotnet/*/bin/*/*/*/*.app; do
done
$CP -p packaged-macos-tests.mk "$DIR/tests"
$CP -p run-with-timeout.sh "$DIR/tests"
$CP -p ../Make.config "$DIR"
$CP -p ../Make.versions "$DIR"
$CP -p test-dependencies.sh "$DIR"

Просмотреть файл

@ -25,6 +25,9 @@ SUPPORTS_MACCATALYST:=$(shell echo '$(MACOS_MAJOR_VERSION).$(MACOS_MINOR_VERSION
CONFIG?=Debug
LAUNCH_ARGUMENTS=--autostart --autoexit
# Time test runs out after 5 minutes (300 seconds)
RUN_WITH_TIMEOUT=./run-with-timeout.sh 300
.stamp-configure-projects-mac: Makefile xharness/xharness.exe
$(Q) $(MAKE) .stamp-xharness-configure
$(Q) touch $@
@ -52,7 +55,7 @@ build-mac-full-dontlink: linker/mac/dont\ link/generated-projects/full/dont\ lin
exec-mac-full-dontlink:
@echo " Executing the 'dont link' test for Xamarin.Mac (Full profile) "
$(Q) "linker/mac/dont link/generated-projects/full/bin/x86/$(CONFIG)-full/dont link.app/Contents/MacOS/dont link"
$(Q) $(RUN_WITH_TIMEOUT) "linker/mac/dont link/generated-projects/full/bin/x86/$(CONFIG)-full/dont link.app/Contents/MacOS/dont link"
# macOS/legacy/system
build-mac-system-dontlink: linker/mac/dont\ link/generated-projects/system/dont\ link-mac-system.csproj .stamp-nuget-restore-mac
@ -60,7 +63,7 @@ build-mac-system-dontlink: linker/mac/dont\ link/generated-projects/system/dont\
exec-mac-system-dontlink:
@echo " Executing the 'dont link' test for Xamarin.Mac (System profile) "
$(Q) "linker/mac/dont link/generated-projects/system/bin/x86/$(CONFIG)-system/dont link.app/Contents/MacOS/dont link"
$(Q) $(RUN_WITH_TIMEOUT) "linker/mac/dont link/generated-projects/system/bin/x86/$(CONFIG)-system/dont link.app/Contents/MacOS/dont link"
#
# introspection
@ -72,7 +75,7 @@ build-mac-modern-introspection: introspection/Mac/introspection-mac.csproj .stam
exec-mac-modern-introspection:
@echo " Executing the 'introspection' test for Xamarin.Mac (Modern profile) "
$(Q) introspection/Mac/bin/x86/$(CONFIG)/introspection.app/Contents/MacOS/introspection
$(Q) $(RUN_WITH_TIMEOUT) introspection/Mac/bin/x86/$(CONFIG)/introspection.app/Contents/MacOS/introspection
#
# xammac tests
@ -84,7 +87,7 @@ build-mac-modern-xammac_tests: xammac_tests/xammac_tests.csproj .stamp-nuget-res
exec-mac-modern-xammac_tests:
@echo " Executing the 'xammac' test for Xamarin.Mac (Modern profile) "
$(Q) xammac_tests/bin/x86/$(CONFIG)/xammac_tests.app/Contents/MacOS/xammac_tests
$(Q) $(RUN_WITH_TIMEOUT) xammac_tests/bin/x86/$(CONFIG)/xammac_tests.app/Contents/MacOS/xammac_tests
#
# link all
@ -96,7 +99,7 @@ build-mac-modern-linkall: linker/mac/link\ all/link\ all-mac.csproj .stamp-nuget
exec-mac-modern-linkall:
@echo " Executing the 'link all' test for Xamarin.Mac (Modern profile) "
$(Q) "./linker/mac/link all/bin/x86/$(CONFIG)/link all.app/Contents/MacOS/link all"
$(Q) $(RUN_WITH_TIMEOUT) "./linker/mac/link all/bin/x86/$(CONFIG)/link all.app/Contents/MacOS/link all"
#
# link sdk
@ -108,51 +111,77 @@ build-mac-modern-linksdk: linker/mac/link\ sdk/link\ sdk-mac.csproj .stamp-nuget
exec-mac-modern-linksdk:
@echo " Executing the 'link sdk' test for Xamarin.Mac (Modern profile) "
$(Q) "./linker/mac/link sdk/bin/x86/$(CONFIG)/link sdk.app/Contents/MacOS/link sdk"
$(Q) $(RUN_WITH_TIMEOUT) "./linker/mac/link sdk/bin/x86/$(CONFIG)/link sdk.app/Contents/MacOS/link sdk"
### .NET dependency projects
# We have library projects that are used in multiple test projects.
# If those test projects are built in parallel, these library projects
# might be built in multiple build processes at once, and that
# may turn into build errors when the simultaneous builds stomp
# on eachother. So here we build those library projects first, serialized,
# so that when the test projects need them, they're already built.
.stamp-copy-dotnet-config:
$(Q) $(MAKE) -C dotnet copy-dotnet-config
$(Q) touch $@
define DotNetDependentProject
.stamp-dotnet-dependency-$(2)-$(1): Makefile .stamp-copy-dotnet-config
$$(Q) $$(MAKE) -C "$(1)/dotnet/$(2)" build
$$(Q) touch $$@
.stamp-dotnet-dependency-$(2):: .stamp-dotnet-dependency-$(2)-$(1)
$$(Q) touch $$@
endef
$(eval $(call DotNetDependentProject,BundledResources,macOS))
$(eval $(call DotNetDependentProject,BundledResources,MacCatalyst))
$(eval $(call DotNetDependentProject,EmbeddedResources,macOS))
$(eval $(call DotNetDependentProject,EmbeddedResources,MacCatalyst))
### .NET normal tests
define DotNetNormalTest
# macOS/.NET/x64
build-mac-dotnet-x64-$(1):
build-mac-dotnet-x64-$(1): .stamp-dotnet-dependency-macOS
$$(Q) $$(MAKE) -C "$(1)/dotnet/macOS" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=osx-x64
exec-mac-dotnet-x64-$(1):
@echo " Executing the '$(1)' test for macOS/.NET (x64) "
$$(Q) "./$(1)/dotnet/macOS/bin/$(CONFIG)/$(DOTNET_TFM)-macos/osx-x64/$(2).app/Contents/MacOS/$(2)"
$$(Q) $(RUN_WITH_TIMEOUT) "./$(1)/dotnet/macOS/bin/$(CONFIG)/$(DOTNET_TFM)-macos/osx-x64/$(2).app/Contents/MacOS/$(2)"
# macOS/.NET/arm64
build-mac-dotnet-arm64-$(1):
build-mac-dotnet-arm64-$(1): .stamp-dotnet-dependency-macOS
$$(Q) $$(MAKE) -C "$(1)/dotnet/macOS" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=osx-arm64
exec-mac-dotnet-arm64-$(1):
ifeq ($(IS_APPLE_SILICON),1)
@echo " Executing the '$(1)' test for macOS/.NET (arm64) "
$$(Q) "./$(1)/dotnet/macOS/bin/$(CONFIG)/$(DOTNET_TFM)-macos/osx-arm64/$(2).app/Contents/MacOS/$(2)"
$$(Q) $(RUN_WITH_TIMEOUT) "./$(1)/dotnet/macOS/bin/$(CONFIG)/$(DOTNET_TFM)-macos/osx-arm64/$(2).app/Contents/MacOS/$(2)"
else
@echo "⚠️ Not executing the '$(1)' test for macOS/.NET (arm64) - not executing on Apple Silicon ⚠️"
endif
# MacCatalyst/.NET/x64
build-maccatalyst-dotnet-x64-$(1):
build-maccatalyst-dotnet-x64-$(1): .stamp-dotnet-dependency-MacCatalyst
$$(Q_BUILD) $$(MAKE) -C "$(1)/dotnet/MacCatalyst" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=maccatalyst-x64
exec-maccatalyst-dotnet-x64-$(1):
ifeq ($(SUPPORTS_MACCATALYST),1)
@echo " Executing the '$(1)' test for Mac Catalyst/.NET (x64) "
$$(Q) "./$(1)/dotnet/MacCatalyst/bin/$(CONFIG)/$(DOTNET_TFM)-maccatalyst/maccatalyst-x64/$(2).app/Contents/MacOS/$(2)" $(LAUNCH_ARGUMENTS)
$$(Q) $(RUN_WITH_TIMEOUT) "./$(1)/dotnet/MacCatalyst/bin/$(CONFIG)/$(DOTNET_TFM)-maccatalyst/maccatalyst-x64/$(2).app/Contents/MacOS/$(2)" $(LAUNCH_ARGUMENTS)
else
@echo "⚠️ Not executing the '$(1)' test for Mac Catalyst/.NET (x64) - macOS version $(MACOS_VERSION) is too old ⚠️"
endif
# MacCatalyst/.NET/arm64
build-maccatalyst-dotnet-arm64-$(1):
build-maccatalyst-dotnet-arm64-$(1):.stamp-dotnet-dependency-MacCatalyst
$$(Q) $$(MAKE) -C "$(1)/dotnet/MacCatalyst" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=maccatalyst-arm64
exec-maccatalyst-dotnet-arm64-$(1):
ifeq ($(IS_APPLE_SILICON),1)
@echo " Executing the '$(1)' test for Mac Catalyst/.NET (arm64) "
$$(Q) "./$(1)/dotnet/MacCatalyst/bin/$(CONFIG)/$(DOTNET_TFM)-maccatalyst/maccatalyst-arm64/$(2).app/Contents/MacOS/$(2)" $(LAUNCH_ARGUMENTS)
$$(Q) $(RUN_WITH_TIMEOUT) "./$(1)/dotnet/MacCatalyst/bin/$(CONFIG)/$(DOTNET_TFM)-maccatalyst/maccatalyst-arm64/$(2).app/Contents/MacOS/$(2)" $(LAUNCH_ARGUMENTS)
else
@echo "⚠️ Not executing the '$(1)' test for Mac Catalyst/.NET (arm64) - not executing on Apple Silicon ⚠️"
endif
@ -183,45 +212,45 @@ $(eval $(call DotNetNormalTest,introspection,introspection))
define DotNetLinkerTest
# macOS/.NET/x64
build-mac-dotnet-x64-$(1):
build-mac-dotnet-x64-$(1): .stamp-dotnet-dependency-macOS
$$(Q_BUILD) $$(MAKE) -C "linker/ios/$(2)/dotnet/macOS" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=osx-x64
exec-mac-dotnet-x64-$(1):
@echo " Executing the '$(2)' test for macOS/.NET (x64) "
$$(Q) "./linker/ios/$(2)/dotnet/macOS/bin/$(CONFIG)/$(DOTNET_TFM)-macos/osx-x64/$(2).app/Contents/MacOS/$(2)"
$$(Q) $(RUN_WITH_TIMEOUT) "./linker/ios/$(2)/dotnet/macOS/bin/$(CONFIG)/$(DOTNET_TFM)-macos/osx-x64/$(2).app/Contents/MacOS/$(2)"
# macOS/.NET/arm64
build-mac-dotnet-arm64-$(1):
build-mac-dotnet-arm64-$(1): .stamp-dotnet-dependency-macOS
$$(Q) $$(MAKE) -C "linker/ios/$(2)/dotnet/macOS" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=osx-arm64
exec-mac-dotnet-arm64-$(1):
ifeq ($(IS_APPLE_SILICON),1)
@echo " Executing the '$(2)' test for macOS/.NET (arm64) "
$$(Q) "./linker/ios/$(2)/dotnet/macOS/bin/$(CONFIG)/$(DOTNET_TFM)-macos/osx-arm64/$(2).app/Contents/MacOS/$(2)"
$$(Q) $(RUN_WITH_TIMEOUT) "./linker/ios/$(2)/dotnet/macOS/bin/$(CONFIG)/$(DOTNET_TFM)-macos/osx-arm64/$(2).app/Contents/MacOS/$(2)"
else
@echo "⚠️ Not executing the '$(2)' test for macOS/.NET (arm64) - not executing on Apple Silicon ⚠️"
endif
# MacCatalyst/.NET/x64
build-maccatalyst-dotnet-x64-$(1):
build-maccatalyst-dotnet-x64-$(1): .stamp-dotnet-dependency-MacCatalyst
$$(Q_BUILD) $$(MAKE) -C "linker/ios/$(2)/dotnet/MacCatalyst" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=maccatalyst-x64
exec-maccatalyst-dotnet-x64-$(1):
ifeq ($(SUPPORTS_MACCATALYST),1)
@echo " Executing the '$(2)' test for Mac Catalyst/.NET (x64) "
$$(Q) "./linker/ios/$(2)/dotnet/MacCatalyst/bin/$(CONFIG)/$(DOTNET_TFM)-maccatalyst/maccatalyst-x64/$(2).app/Contents/MacOS/$(2)" $(LAUNCH_ARGUMENTS)
$$(Q) $(RUN_WITH_TIMEOUT) "./linker/ios/$(2)/dotnet/MacCatalyst/bin/$(CONFIG)/$(DOTNET_TFM)-maccatalyst/maccatalyst-x64/$(2).app/Contents/MacOS/$(2)" $(LAUNCH_ARGUMENTS)
else
@echo "⚠️ Not executing the '$(2)' test for Mac Catalyst/.NET (x64) - macOS version $(MACOS_VERSION) is too old ⚠️"
endif
# MacCatalyst/.NET/arm64
build-maccatalyst-dotnet-arm64-$(1):
build-maccatalyst-dotnet-arm64-$(1): .stamp-dotnet-dependency-MacCatalyst
$$(Q) $$(MAKE) -C "linker/ios/$(2)/dotnet/MacCatalyst" build BUILD_ARGUMENTS=/p:RuntimeIdentifier=maccatalyst-arm64
exec-maccatalyst-dotnet-arm64-$(1):
ifeq ($(IS_APPLE_SILICON),1)
@echo " Executing the '$(2)' test for Mac Catalyst/.NET (arm64) "
$$(Q) "./linker/ios/$(2)/dotnet/MacCatalyst/bin/$(CONFIG)/$(DOTNET_TFM)-maccatalyst/maccatalyst-arm64/$(2).app/Contents/MacOS/$(2)" $(LAUNCH_ARGUMENTS)
$$(Q) $(RUN_WITH_TIMEOUT) "./linker/ios/$(2)/dotnet/MacCatalyst/bin/$(CONFIG)/$(DOTNET_TFM)-maccatalyst/maccatalyst-arm64/$(2).app/Contents/MacOS/$(2)" $(LAUNCH_ARGUMENTS)
else
@echo "⚠️ Not executing the '$(2)' test for Mac Catalyst/.NET (arm64) - not executing on Apple Silicon ⚠️"
endif

33
tests/run-with-timeout.sh Executable file
Просмотреть файл

@ -0,0 +1,33 @@
#!/bin/bash -eu
# This script takes a timeout interval (in seconds) as the first argument.
# The remaining arguments will be executed, and if it takes longer than the timeout,
# the process will be killed.
INTERVAL_SECONDS=1
TIMEOUT=$1
shift
PID=$$
(
((t = TIMEOUT))
while ((t > 0)); do
# Sleep for a bit
sleep $INTERVAL_SECONDS
# Check if the process is still around
if ! kill -0 $PID; then
# The process is gone! Yay!
exit 0
fi
# Process is still around, keep waiting
((t -= INTERVAL_SECONDS))
done
# ⏰ - prepare to die
kill -s SIGKILL $PID
echo "The command '$*' timed out after $TIMEOUT second(s)."
) 2> /dev/null &
exec "$@"

Просмотреть файл

@ -231,7 +231,7 @@ steps:
# yet we do have some flacky ones, this will allow the release to run. The comment will let use know that we failed
exit 0
displayName: 'Run tests'
timeoutInMinutes: 30
timeoutInMinutes: 45
env:
CONTEXT: ${{ parameters.statusContext }}
BUILD_REVISION: $(Build.SourceVersion)