[net8.0] [tests] Add a .NET 7 test app. (#17385)

This commit is contained in:
Rolf Bjarne Kvinge 2023-03-07 07:58:54 +01:00 коммит произвёл GitHub
Родитель 425323a1c6
Коммит be031736be
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 107 добавлений и 0 удалений

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

@ -53,9 +53,11 @@ using (TextWriter writer = new StreamWriter (outputPath)) {
if (platform == "macOS") {
writer.WriteLine ($" \"microsoft-net-runtime-mono-tooling\",");
writer.WriteLine ($" \"microsoft-net-runtime-mono-tooling-net6\",");
writer.WriteLine ($" \"microsoft-net-runtime-mono-tooling-net7\",");
} else {
writer.WriteLine ($" \"microsoft-net-runtime-{platformLowerCase}\",");
writer.WriteLine ($" \"microsoft-net-runtime-{platformLowerCase}-net6\",");
writer.WriteLine ($" \"microsoft-net-runtime-{platformLowerCase}-net7\",");
}
writer.WriteLine ($" ]");
writer.WriteLine ($" }},");

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

@ -0,0 +1,17 @@
using System;
using System.Runtime.InteropServices;
using Foundation;
namespace MySimpleApp {
public class Program {
static int Main (string [] args)
{
GC.KeepAlive (typeof (NSObject)); // prevent linking away the platform assembly
Console.WriteLine (Environment.GetEnvironmentVariable ("MAGIC_WORD"));
return args.Length;
}
}
}

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

@ -0,0 +1 @@
include ../shared.mk

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

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-maccatalyst</TargetFramework>
<SupportedOSPlatformVersion>14.0</SupportedOSPlatformVersion>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

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

@ -0,0 +1,2 @@
TOP=../../..
include $(TOP)/tests/common/shared-dotnet-test.mk

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

@ -0,0 +1 @@
include ../shared.mk

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

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-ios</TargetFramework>
<SupportedOSPlatformVersion>11.0</SupportedOSPlatformVersion>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

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

@ -0,0 +1 @@
include ../shared.mk

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

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-macos</TargetFramework>
<SupportedOSPlatformVersion>10.15</SupportedOSPlatformVersion>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

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

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<ApplicationTitle>MySimpleApp</ApplicationTitle>
<ApplicationId>com.xamarin.mysimpleapp</ApplicationId>
<ApplicationVersion>7.0</ApplicationVersion>
</PropertyGroup>
<Import Project="../../common/shared-dotnet.csproj" />
<ItemGroup>
<Compile Include="../*.cs" />
</ItemGroup>
</Project>

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

@ -0,0 +1,4 @@
TOP=../../../..
TESTNAME=Net7_0SimpleApp
TEST_TFM=net7.0
include $(TOP)/tests/common/shared-dotnet.mk

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

@ -0,0 +1 @@
include ../shared.mk

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

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-tvos</TargetFramework>
<SupportedOSPlatformVersion>11.0</SupportedOSPlatformVersion>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

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

@ -1000,6 +1000,36 @@ namespace Xamarin.Tests {
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);
}
[Test]
[TestCase (ApplePlatform.iOS, "iossimulator-x64")]
[TestCase (ApplePlatform.iOS, "ios-arm64")]
[TestCase (ApplePlatform.TVOS, "tvossimulator-arm64")]
[TestCase (ApplePlatform.MacOSX, "osx-arm64")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64")]
public void BuildNet7_0App (ApplePlatform platform, string runtimeIdentifiers)
{
var project = "Net7_0SimpleApp";
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);
var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath, netVersion: "net7.0");
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifiers);
var result = DotNet.AssertBuild (project_path, properties);
AssertThatLinkerExecuted (result);
var infoPlistPath = GetInfoPListPath (platform, appPath);
Assert.That (infoPlistPath, Does.Exist, "Info.plist");
var infoPlist = PDictionary.FromFile (infoPlistPath)!;
Assert.AreEqual ("com.xamarin.mysimpleapp", infoPlist.GetString ("CFBundleIdentifier").Value, "CFBundleIdentifier");
Assert.AreEqual ("MySimpleApp", infoPlist.GetString ("CFBundleDisplayName").Value, "CFBundleDisplayName");
Assert.AreEqual ("7.0", infoPlist.GetString ("CFBundleVersion").Value, "CFBundleVersion");
Assert.AreEqual ("7.0", infoPlist.GetString ("CFBundleShortVersionString").Value, "CFBundleShortVersionString");
var appExecutable = GetNativeExecutable (platform, appPath);
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);
}
[Test]
[TestCase (ApplePlatform.iOS, "iossimulator-x64")]
// [TestCase (ApplePlatform.TVOS, "tvos-arm64")] // Currently doesn't work because we overwrite the required MtouchExtraArgs in tests/nunit.frameworks.target in this test.