diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index dcac300ca7c527..25d0a50788ff9c 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "microsoft.dotnet.xharness.cli": { - "version": "1.0.0-prerelease.20214.1", + "version": "1.0.0-prerelease.20227.9", "commands": [ "xharness" ] diff --git a/eng/testing/MobileRunnerTemplate.sh b/eng/testing/MobileRunnerTemplate.sh index 241b3f74a93cd5..11b5675fab77fb 100644 --- a/eng/testing/MobileRunnerTemplate.sh +++ b/eng/testing/MobileRunnerTemplate.sh @@ -2,9 +2,30 @@ EXECUTION_DIR=$(dirname $0) TEST_NAME=$1 -SIMULATOR_NAME="iPhone 11" - -# TODO: to be replaced with xharness cli tool +TARGET_ARCH=$2 +TARGET= +SCHEME_SDK= + +if [ "$TARGET_ARCH" == "arm" ]; then + TARGET=ios-device + SCHEME_SDK=Release-iphoneos +elif [ "$TARGET_ARCH" == "arm64" ]; then + TARGET=ios-device + SCHEME_SDK=Release-iphoneos +elif [ "$TARGET_ARCH" == "x64" ]; then + TARGET=ios-simulator-64 + SCHEME_SDK=Release-iphonesimulator +elif [ "$TARGET_ARCH" == "x86" ]; then + TARGET=ios-simulator-32 + SCHEME_SDK=Release-iphonesimulator +else + echo "Unknown architecture: $TARGET_ARCH" + exit 1 +fi + +# "Release" in SCHEME_SDK is what xcode produces (see "bool Optimized" property in AppleAppBuilderTask) + +APP_BUNDLE=$EXECUTION_DIR/Bundle/$TEST_NAME/$SCHEME_SDK/$TEST_NAME.app # it doesn't support parallel execution yet, so, here is a hand-made semaphore: LOCKDIR=/tmp/runonsim.lock @@ -18,20 +39,10 @@ while true; do fi done -# Release here is what xcode produces (see "bool Optimized" property in AppleAppBuilderTask) -AppBundlePath=$EXECUTION_DIR/Bundle/$TEST_NAME/Release-iphonesimulator/$TEST_NAME.app - -# kill a simulator if it exists -xcrun simctl shutdown "$SIMULATOR_NAME" || true - -# boot it again -xcrun simctl boot "$SIMULATOR_NAME" - -# open UI (this step is not neccessary) -open -a Simulator +XHARNESS_OUT="$EXECUTION_DIR/Bundle/xharness-output" -# install the *.app bundle -xcrun simctl install "$SIMULATOR_NAME" "$SIMULATOR_NAME" +dotnet xharness ios test --app="$APP_BUNDLE" \ + --targets=$TARGET \ + --output-directory=$XHARNESS_OUT -# launch the app, redirect logs to console and quite once tests are completed -xcrun simctl launch --console booted net.dot.$TEST_NAME testlib:$TEST_NAME.dll --auto-exit +echo "Xharness artifacts: $XHARNESS_OUT" diff --git a/eng/testing/tests.targets b/eng/testing/tests.targets index 4524a8bd246f80..7c2512ae464726 100644 --- a/eng/testing/tests.targets +++ b/eng/testing/tests.targets @@ -98,7 +98,7 @@ "$(RunScriptOutputPath)" --runtime-path "$(TestHostRootPath.TrimEnd('\/'))" $(RunTestsCommand) --rsp-file "$(TestRspFile)" - "$(RunScriptOutputPath)" $(AssemblyName) + "$(RunScriptOutputPath)" $(AssemblyName) $(TargetArchitecture) @@ -141,6 +141,8 @@ + @@ -148,20 +150,6 @@ - - - - - - - - - - = 3); - if ([arg hasPrefix:@"--setenv="]) { - // TODO: setenv - } else if ([arg isEqualToString:@"--auto-exit"]) { - auto_exit = TRUE; - } managed_argv[argi] = [arg UTF8String]; } @@ -273,6 +266,5 @@ // Print this so apps parsing logs can detect when we exited os_log_info (OS_LOG_DEFAULT, "Exit code: %d.", res); - if (auto_exit) - exit (res); + exit (res); } diff --git a/src/mono/msbuild/AppleAppBuilder/Xcode.cs b/src/mono/msbuild/AppleAppBuilder/Xcode.cs index f925c036c37f67..305e5d45762565 100644 --- a/src/mono/msbuild/AppleAppBuilder/Xcode.cs +++ b/src/mono/msbuild/AppleAppBuilder/Xcode.cs @@ -76,7 +76,7 @@ public static string GenerateXCode( string plist = Utils.GetEmbeddedResource("Info.plist.template") .Replace("%BundleIdentifier%", projectName); - File.WriteAllText(Path.Combine(binDir, "Info.plist.in"), plist); + File.WriteAllText(Path.Combine(binDir, "Info.plist"), plist); File.WriteAllText(Path.Combine(binDir, "CMakeLists.txt"), cmakeLists); var cmakeArgs = new StringBuilder(); diff --git a/src/mono/msbuild/AppleTestRunner/AppleTestRunner.cs b/src/mono/msbuild/AppleTestRunner/AppleTestRunner.cs index 6094059123eda6..dc1f045a819396 100644 --- a/src/mono/msbuild/AppleTestRunner/AppleTestRunner.cs +++ b/src/mono/msbuild/AppleTestRunner/AppleTestRunner.cs @@ -126,9 +126,9 @@ protected override void TerminateWithSuccess() protected override TestRunnerType TestRunner => TestRunnerType.Xunit; - protected override string? IgnoreFilesDirectory => Environment.CurrentDirectory; + protected override string? IgnoreFilesDirectory => null; - public string BundleIdentifier => "net.dot.test-runner"; + public string BundleIdentifier => "net.dot." + s_MainTestName; public string? UniqueIdentifier { get; }