Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/common/test-variations.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
<Project>
<ItemGroup>
<TestVariations Include="interpreter" Description="Run with the interpreter ('UseInterpreter=true')" />
<TestVariations Include="bundle-original-resources" Description="Bundle original resources ('BundleOriginalResources=true')" />
<TestVariations Include="do-not-bundle-original-resources" Description="Do not original resources ('BundleOriginalResources=false')" />
</ItemGroup>

<PropertyGroup Condition="'$(TestVariation)' == 'interpreter'">
<UseInterpreter>true</UseInterpreter>
</PropertyGroup>

<PropertyGroup Condition="'$(TestVariation)' == 'bundle-original-resources'">
<BundleOriginalResources>true</BundleOriginalResources>
</PropertyGroup>

<PropertyGroup Condition="'$(TestVariation)' == 'do-not-bundle-original-resources'">
<BundleOriginalResources>false</BundleOriginalResources>
</PropertyGroup>

<Target Name="ValidateTestVariation" Condition="'$(TestVariation)' != ''" BeforeTargets="Build">
<ItemGroup>
<_FilteredTestVariations Include="@(TestVariations)" Condition="'%(Identity)' == '$(TestVariation)'" />
Expand Down
2 changes: 1 addition & 1 deletion tests/dotnet/UnitTests/TestBaseClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ protected Execution Execute (string executable, out StringBuilder output, out st
}

output = new StringBuilder ();
return Execution.RunWithStringBuildersAsync (executable, Array.Empty<string> (), environment: env, standardOutput: output, standardError: output, timeout: TimeSpan.FromSeconds (15)).Result;
return Execution.RunWithStringBuildersAsync (executable, Array.Empty<string> (), environment: env, standardOutput: output, standardError: output, timeout: TimeSpan.FromSeconds (30)).Result;
}

public static StringBuilder AssertExecute (string executable, params string [] arguments)
Expand Down
4 changes: 4 additions & 0 deletions tests/xharness/Harness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ string GetVariable (string variable, string @default = null)
public string DOTNET_DIR { get; set; }
public string DOTNET_TFM { get; set; }

public Version DotNetVersion {
get => Version.Parse (DOTNET_TFM.Replace ("net", ""));
}

// Run

public string XcodeRoot { get; private set; }
Expand Down
1 change: 1 addition & 0 deletions tests/xharness/IHarness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public interface IHarness {
string JENKINS_RESULTS_DIRECTORY { get; }
string DOTNET_DIR { get; set; }
string DOTNET_TFM { get; }
Version DotNetVersion { get; }
string XcodeRoot { get; }
string LogDirectory { get; }
double Timeout { get; }
Expand Down
22 changes: 21 additions & 1 deletion tests/xharness/Jenkins/TestVariationsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ IEnumerable<TestData> GetTestData (RunTestTask test)
break;
}

switch (test.TestName) {
case "link all":
if (test.ProjectConfiguration == "Debug") {
// in .NET 9 we add a variation to test original resource bundling (which is opt in in .NET 9),
// and in .NET 10 we change the variation to test *not* bundling original resources (because it becomes opt out in .NET 10,
// so we don't test it by default).
if (jenkins.Harness.DotNetVersion.Major <= 9) {
yield return new TestData { Variation = "Debug (bundle original resources)", TestVariation = "bundle-original-resources", Debug = true };
} else {
yield return new TestData { Variation = "Debug (don't bundle original resources)", TestVariation = "do-not-bundle-original-resources", Debug = true };
}
}
break;
}

switch (test.ProjectPlatform) {
case "iPhone":
if (test.ProjectConfiguration.Contains ("Debug"))
Expand Down Expand Up @@ -219,8 +234,13 @@ public IEnumerable<T> CreateTestVariations<T> (IEnumerable<T> tests, Func<MSBuil
clone.Xml.SetProperty ("_IsPublishing", "true", last: false); // quack like "dotnet publish", otherwise PublishAot=true has no effect.
clone.Xml.SetProperty ("IlcTreatWarningsAsErrors", "false", last: false); // We're enabling warnaserror by default, but we're not warning-free for ILC (especially for NUnit), so disable warnaserror for ILC - https://github.com/xamarin/xamarin-macios/issues/19911
}
if (!string.IsNullOrEmpty (test_variation))
if (!string.IsNullOrEmpty (test_variation)) {
clone.Xml.SetProperty ("TestVariation", test_variation);
foreach (var pr in clone.ProjectReferences) {
pr.Xml.SetProperty ("TestVariation", test_variation);
pr.Xml.Save (pr.Path);
}
}
clone.Xml.Save (clone.Path);
});

Expand Down
2 changes: 1 addition & 1 deletion tests/xharness/TestProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class TestProject {
public TimeSpan Timeout = TimeSpan.FromMinutes (10);
public bool? Ignore;

public IEnumerable<TestProject>? ProjectReferences;
public IEnumerable<TestProject> ProjectReferences = Array.Empty<TestProject> ();

public TestProject (TestLabel label, string path, bool isExecutableProject = true)
{
Expand Down
38 changes: 19 additions & 19 deletions tools/linker/RemoveUserResourcesSubStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,12 @@
using Xamarin.Bundler;
using Xamarin.Utils;

#nullable enable

namespace Xamarin.Linker {

public class RemoveUserResourcesSubStep : ExceptionalSubStep {

const string iOS_Content = "__monotouch_content_";
const string iOS_Page = "__monotouch_page_";
const string Mac_Content = "__xammac_content_";
const string Mac_Page = "__xammac_page_";

string Content;
string Page;
string [] prefixes = Array.Empty<string> ();

public override SubStepTargets Targets {
get { return SubStepTargets.Assembly; }
Expand All @@ -41,12 +36,18 @@ public override void Initialize (LinkContext context)
case ApplePlatform.TVOS:
case ApplePlatform.WatchOS:
case ApplePlatform.MacCatalyst:
Content = iOS_Content;
Page = iOS_Page;
prefixes = new string [] {
"__monotouch_content_",
"__monotouch_page_",
"__monotouch_item_",
};
break;
case ApplePlatform.MacOSX:
Content = Mac_Content;
Page = Mac_Page;
prefixes = new string [] {
"__xammac_content_",
"__xammac_page_",
"__xammac_item_",
};
break;
default:
Report (ErrorHelper.CreateError (71, Errors.MX0071, LinkContext.App.Platform, LinkContext.App.ProductName));
Expand All @@ -63,7 +64,7 @@ protected override void Process (AssemblyDefinition assembly)
if (!module.HasResources)
return;

HashSet<string> libraries = null;
HashSet<string>? libraries = null;
if (assembly.HasCustomAttributes) {
foreach (var ca in assembly.CustomAttributes) {
if (!ca.AttributeType.Is ("ObjCRuntime", "LinkWithAttribute"))
Expand Down Expand Up @@ -104,16 +105,15 @@ bool IsMonoTouchResource (string resourceName)
if (Simulator)
return false;

if (resourceName.StartsWith (Content, StringComparison.OrdinalIgnoreCase))
return true;

if (resourceName.StartsWith (Page, StringComparison.OrdinalIgnoreCase))
return true;
foreach (var prefix in prefixes) {
if (resourceName.StartsWith (prefix, StringComparison.OrdinalIgnoreCase))
return true;
}

return false;
}

static bool IsNativeLibrary (string resourceName, HashSet<string> libraries)
static bool IsNativeLibrary (string resourceName, HashSet<string>? libraries)
{
if (libraries is null)
return false;
Expand Down
Loading