From d447b8e28f8d7dc99fbef75ae2bd6fe6f56f311b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 22 Dec 2020 01:28:25 +0100 Subject: [PATCH] Fix wrong XHARNESS_CLI_COMMAND in wasm README and simplify scripts (#46294) * Fix wrong XHARNESS_CLI_COMMAND in wasm README The variable is actually `XHARNESS_CLI_PATH`. Also added it to the AppleRunnerTemplate.sh script since it was missing there. * Add note about usage for Android/AppleRunnerTemplate.sh scripts Also simplify the iOS/Android scripts a bit. --- eng/testing/AndroidRunnerTemplate.sh | 26 ++++++------ eng/testing/AppleRunnerTemplate.sh | 70 ++++++++++++++------------------- eng/testing/tests.mobile.targets | 13 +----- eng/testing/tests.targets | 2 +- eng/testing/xunit/xunit.console.targets | 7 +++- src/mono/wasm/README.md | 4 +- 6 files changed, 56 insertions(+), 66 deletions(-) diff --git a/eng/testing/AndroidRunnerTemplate.sh b/eng/testing/AndroidRunnerTemplate.sh index db06f4d..3e60d7a 100644 --- a/eng/testing/AndroidRunnerTemplate.sh +++ b/eng/testing/AndroidRunnerTemplate.sh @@ -1,6 +1,13 @@ #!/usr/bin/env bash +# NOTE: this script is only used locally, on CI we use the Helix SDK from arcade + EXECUTION_DIR=$(dirname $0) +ASSEMBLY_NAME=$1 +TARGET_ARCH=$2 +TARGET_OS=$3 +TEST_NAME=$4 +XHARNESS_OUT="$EXECUTION_DIR/xharness-output" cd $EXECUTION_DIR @@ -16,22 +23,19 @@ while true; do fi done -if [ -z "$HELIX_WORKITEM_UPLOAD_ROOT" ]; then - XHARNESS_OUT="$EXECUTION_DIR/xharness-output" -else - XHARNESS_OUT="$HELIX_WORKITEM_UPLOAD_ROOT/xharness-output" -fi - if [ ! -z "$XHARNESS_CLI_PATH" ]; then - # When running in CI, we only have the .NET runtime available - # We need to call the XHarness CLI DLL directly via dotnet exec - HARNESS_RUNNER="dotnet exec $XHARNESS_CLI_PATH" + # Allow overriding the path to the XHarness CLI DLL, + # we need to call it directly via dotnet exec + HARNESS_RUNNER="dotnet exec $XHARNESS_CLI_PATH" else HARNESS_RUNNER="dotnet xharness" fi -# RunCommands defined in tests.mobile.targets -[[RunCommands]] +$HARNESS_RUNNER android test \ + --instrumentation="net.dot.MonoRunner" \ + --package-name="net.dot.$ASSEMBLY_NAME" \ + --app="$EXECUTION_DIR/bin/$TEST_NAME.apk" \ + --output-directory="$XHARNESS_OUT" _exitCode=$? diff --git a/eng/testing/AppleRunnerTemplate.sh b/eng/testing/AppleRunnerTemplate.sh index 7ea80e1..331e964 100644 --- a/eng/testing/AppleRunnerTemplate.sh +++ b/eng/testing/AppleRunnerTemplate.sh @@ -1,43 +1,33 @@ #!/usr/bin/env bash -EXECUTION_DIR=$(dirname $0) -[[RunCommands]] +# NOTE: this script is only used locally, on CI we use the Helix SDK from arcade -TARGET_DEVICE=ios-device -TARGET_SIMULATOR=ios-simulator-64 -TARGET_SDK=iphoneos -TARGET_SIMULATOR_SDK=iphonesimulator +EXECUTION_DIR=$(dirname $0) +ASSEMBLY_NAME=$1 +TARGET_ARCH=$2 +TARGET_OS=$3 +TEST_NAME=$4 +XHARNESS_OUT="$EXECUTION_DIR/xharness-output" +XCODE_PATH=$(xcode-select -p)/../.. -if [ "$TARGET_OS" == "tvOS" ]; then - TARGET_DEVICE=tvos-device - TARGET_SIMULATOR=tvos-simulator - TARGET_SDK=appletvos - TARGET_SIMULATOR_SDK=appletvsimulator -fi +if [[ "$TARGET_OS" == "iOS" && "$TARGET_ARCH" == "x86" ]]; then TARGET=ios-simulator-32; fi +if [[ "$TARGET_OS" == "iOS" && "$TARGET_ARCH" == "x64" ]]; then TARGET=ios-simulator-64; fi +if [[ "$TARGET_OS" == "iOS" && "$TARGET_ARCH" == "arm" ]]; then TARGET=ios-device; fi +if [[ "$TARGET_OS" == "iOS" && "$TARGET_ARCH" == "arm64" ]]; then TARGET=ios-device; fi +if [[ "$TARGET_OS" == "tvOS" && "$TARGET_ARCH" == "x64" ]]; then TARGET=tvos-simulator; fi +if [[ "$TARGET_OS" == "tvOS" && "$TARGET_ARCH" == "arm64" ]]; then TARGET=tvos-device; fi # "Release" in SCHEME_SDK is what xcode produces (see "bool Optimized" property in AppleAppBuilderTask) -if [ "$TARGET_ARCH" == "arm" ]; then - TARGET=$TARGET_DEVICE - SCHEME_SDK="Release-$TARGET_SDK" -elif [ "$TARGET_ARCH" == "arm64" ]; then - TARGET=$TARGET_DEVICE - SCHEME_SDK="Release-$TARGET_SDK" -elif [ "$TARGET_ARCH" == "x64" ]; then - TARGET=$TARGET_SIMULATOR - SCHEME_SDK="Release-$TARGET_SIMULATOR_SDK" -elif [ "$TARGET_ARCH" == "x86" ] && [ "$TARGET_OS" == "iOS" ]; then - TARGET=ios-simulator-32 - SCHEME_SDK="Release-$TARGET_SIMULATOR_SDK" -else - echo "Unknown OS & architecture: $TARGET_OS $TARGET_ARCH" - exit 1 -fi +if [[ "$TARGET" == "ios-simulator-"* ]]; then SCHEME_SDK=Release-iphonesimulator; fi +if [[ "$TARGET" == "tvos-simulator" ]]; then SCHEME_SDK=Release-appletvsimulator; fi +if [[ "$TARGET" == "ios-device" ]]; then SCHEME_SDK=Release-iphoneos; fi +if [[ "$TARGET" == "tvos-device" ]]; then SCHEME_SDK=Release-appletvos; fi -APP_BUNDLE=$EXECUTION_DIR/$TEST_NAME/$SCHEME_SDK/$TEST_NAME.app +cd $EXECUTION_DIR # it doesn't support parallel execution yet, so, here is a hand-made semaphore: -LOCKDIR=/tmp/runonsim.lock +LOCKDIR=/tmp/appletests.lock while true; do if mkdir "$LOCKDIR" then @@ -48,19 +38,19 @@ while true; do fi done -XCODE_PATH="`xcode-select -p`/../.." - -if [ -z "$HELIX_WORKITEM_UPLOAD_ROOT" ]; then - export XHARNESS_OUT="$EXECUTION_DIR/xharness-output" +if [ ! -z "$XHARNESS_CLI_PATH" ]; then + # Allow overriding the path to the XHarness CLI DLL, + # we need to call it directly via dotnet exec + HARNESS_RUNNER="dotnet exec $XHARNESS_CLI_PATH" else - export XHARNESS_OUT="$HELIX_WORKITEM_UPLOAD_ROOT/xharness-output" + HARNESS_RUNNER="dotnet xharness" fi -dotnet xharness ios test \ - --targets="$TARGET" \ - --app="$APP_BUNDLE" \ - --xcode="$XCODE_PATH" \ - --output-directory=$XHARNESS_OUT +$HARNESS_RUNNER ios test \ + --app="$EXECUTION_DIR/$TEST_NAME/$SCHEME_SDK/$TEST_NAME.app" \ + --targets="$TARGET" \ + --xcode="$XCODE_PATH" \ + --output-directory="$XHARNESS_OUT" _exitCode=$? diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index 05e0a24..a1734bd 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -13,15 +13,6 @@ $HARNESS_RUNNER wasm $XHARNESS_COMMAND --app=. --engine=$(JSEngine) $(JSEngineArgs) --js-file=runtime.js --output-directory=$XHARNESS_OUT -- $(RunTestsJSArguments) --run WasmTestRunner.dll $(AssemblyName).dll - - $HARNESS_RUNNER android test --instrumentation="net.dot.MonoRunner" --package-name="net.dot.$(AssemblyName)" --app=$EXECUTION_DIR/bin/$(TestProjectName).apk --output-directory=$XHARNESS_OUT -v -- - - - - - - - - + - + true diff --git a/eng/testing/tests.targets b/eng/testing/tests.targets index 90d5981..d85145e1 100644 --- a/eng/testing/tests.targets +++ b/eng/testing/tests.targets @@ -96,7 +96,7 @@ $(RunTestsCommand) --runtime-path "$(TestHostRootPath.TrimEnd('\/'))" $(RunTestsCommand) --rsp-file "$(TestRspFile)" - "$(RunScriptOutputPath)" $(AssemblyName) $(TargetArchitecture) + "$(RunScriptOutputPath)" $(AssemblyName) $(TargetArchitecture) $(TargetOS) $(TestProjectName) "$(RunScriptOutputPath)" $(JSEngine) $(AssemblyName).dll $(_withoutCategories.Replace(';', ' -notrait category=')) diff --git a/eng/testing/xunit/xunit.console.targets b/eng/testing/xunit/xunit.console.targets index 5b71327..a2a6d88 100644 --- a/eng/testing/xunit/xunit.console.targets +++ b/eng/testing/xunit/xunit.console.targets @@ -2,6 +2,7 @@ true testResults.xml + true @@ -18,7 +19,7 @@ $(RunScriptCommand) -verbose - + $(RunScriptCommand) -method $(XUnitMethodName) $(RunScriptCommand) -class $(XUnitClassName) @@ -31,6 +32,10 @@ $(RunScriptCommand) $(XUnitOptions) + + $(_withoutCategories.Replace(';', '%0dcategory=')) + +