Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mtouch/mmp] Build and run mtouch and mmp using dotnet. #8461

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion mk/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ $(eval $(call NativeCompilationTemplate,-debug,-DDEBUG))
$(Q) mkdir -p $@

%.csproj.inc: %.csproj $(TOP)/Make.config $(TOP)/mk/mono.mk $(TOP)/tools/common/create-makefile-fragment.sh
$(Q) $(TOP)/tools/common/create-makefile-fragment.sh $(abspath $<) $(abspath $@)
$(Q) export DOTNET=$(DOTNET); $(TOP)/tools/common/create-makefile-fragment.sh $(abspath $<) $(abspath $@)
17 changes: 5 additions & 12 deletions tests/mmptest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,24 @@ ifneq ($(SKIP_REGRESSION), 1)
endif

# example command to run a single test:
# make run TEST_FIXTURE=-test=Xamarin.MMP.Tests.MMPTests.AOT_SmokeTest
# make run TEST_FIXTURE="--filter Xamarin.MMP.Tests.MMPTests.AOT_SmokeTest"
# or:
# make run XM_TEST_NAME=Xamarin.MMP.Tests.MMPTests.AOT_SmokeTest
# to run multiple tests:
# make run TEST_FIXTURE="-test=Xamarin.MMP.Tests.MMPTests.AOT_32Bit_SmokeTest,Xamarin.MMP.Tests.MMPTests.AOT_SmokeTest"
# make run TEST_FIXTURE="--filter Xamarin.MMP.Tests.MMPTests.AOT_32Bit_SmokeTest --filter Xamarin.MMP.Tests.MMPTests.AOT_SmokeTest"
#

ifeq ($(TEST_FIXTURE),)
ifneq ($(XM_TEST_NAME),)
TEST_FIXTURE=-test=$(XM_TEST_NAME)
TEST_FIXTURE=--filter $(XM_TEST_NAME)
endif
endif

run: build
rm -f .failed-stamp
$(SYSTEM_MONO) --debug $(XIBUILD_EXE_PATH) -t -- $(TOP)/packages/NUnit.ConsoleRunner.3.9.0/tools/nunit3-console.exe $(abspath $(TOP)/tests/mmptest/bin/Debug/mmptest.dll) "--result=$(abspath $(CURDIR)/TestResult.xml);format=nunit2" $(TEST_FIXTURE) --labels=All || touch $(CURDIR)/.failed-stamp
@# Create an html file and tell MonkeyWrench to upload it (if we're running there)
@[[ -z "$$BUILD_REPOSITORY" ]] || \
( xsltproc $(TOP)/tests/HtmlTransform.xslt TestResult.xml > index.html && \
echo "@MonkeyWrench: AddFile: $$PWD/index.html")
@[[ ! -e .failed-stamp ]]
$(Q) $(DOTNET) test *.csproj --results-directory:. "--logger:console;verbosity=detailed" "--logger:trx;LogFileName=$(CURDIR)/TestResult.trx" "--logger:html;LogFileName=$(CURDIR)/TestResult.html" $(TEST_FIXTURE)

build:
$(Q_XBUILD) $(SYSTEM_XIBUILD) -t -- /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/nuget/NuGet.exe restore ../tests-mac.sln
$(SYSTEM_XIBUILD) -- mmptest.csproj $(XBUILD_VERBOSITY)
$(Q) $(DOTNET) build *.csproj $(XBUILD_VERBOSITY)

clean-local::
@rm -rf ./obj
Expand Down
75 changes: 11 additions & 64 deletions tests/mmptest/mmptest.csproj
Original file line number Diff line number Diff line change
@@ -1,57 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\..\packages\NUnit.3.11.0\build\NUnit.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Xamarin.MMP.Tests</RootNamespace>
<AssemblyName>mmptest</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>__UNIFIED__;DEBUG;XAMCORE_2_0;MONOMAC;MMP_TEST;__MACOS__</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>0</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DefineConstants>__UNIFIED__;XAMCORE_2_0;MONOMAC;MMP_TEST;__MACOS__</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>0</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.3.11.0\lib\net40\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="mmp">
<HintPath>..\..\_mac-build\Library\Frameworks\Xamarin.Mac.framework\Versions\git\lib\mmp\mmp.exe</HintPath>
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.10.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<ProjectReference Include="..\..\tools\mmp\mmp.csproj" />
<Reference Include="Mono.Cecil">
<HintPath>..\..\builds\mono-ios-sdk-destdir\ios-bcl\monotouch_tools\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb">
<HintPath>..\..\_mac-build\Library\Frameworks\Xamarin.Mac.framework\Versions\git\lib\mmp\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil">
<HintPath>..\..\_mac-build\Library\Frameworks\Xamarin.Mac.framework\Versions\git\lib\mmp\Mono.Cecil.dll</HintPath>
<HintPath>..\..\builds\mono-ios-sdk-destdir\ios-bcl\monotouch_tools\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
<Folder Include="unit\" />
</ItemGroup>
<ItemGroup>
<Compile Include="src\MMPTest.cs" />
<Compile Include="src\NativeReferencesTests.cs" />
<Compile Include="..\common\mac\ProjectTestHelpers.cs">
<Link>ProjectTestHelpers.cs</Link>
</Compile>
Expand All @@ -64,20 +35,12 @@
<Compile Include="..\..\src\ObjCRuntime\RuntimeException.cs">
<Link>RuntimeException.cs</Link>
</Compile>
<Compile Include="src\ExtensionTests.cs" />
<Compile Include="src\RemotingConfigurationTests.cs" />
<Compile Include="src\AOTTests.cs" />
<Compile Include="..\..\tests\mmp-aot-tests\aot.cs">
<Link>unit\aot.cs</Link>
</Compile>
<Compile Include="src\FrameworkLinksTests.cs" />
<Compile Include="src\TargetFrameworkDetectionTests.cs" />
<Compile Include="src\LinkerTests.cs" />
<Compile Include="src\Extensions.cs" />
<Compile Include="..\mtouch\Cache.cs">
<Link>Cache.cs</Link>
</Compile>
<Compile Include="src\NetStandardTests.cs" />
<Compile Include="..\common\ProductTests.cs">
<Link>ProductTests.cs</Link>
</Compile>
Expand All @@ -93,30 +56,15 @@
<Compile Include="..\common\Profile.cs">
<Link>Profile.cs</Link>
</Compile>
<Compile Include="src\MmpTool.cs" />
<Compile Include="..\common\BundlerTool.cs">
<Link>BundlerTool.cs</Link>
</Compile>
<Compile Include="src\CodeStrippingTests.cs" />
<Compile Include="..\..\tools\common\StringUtils.cs">
<Link>StringUtils.cs</Link>
</Compile>
<Compile Include="src\WarningTests.cs" />
<Compile Include="src\Unified45.cs" />
<Compile Include="src\System.ServiceModel\Net45.cs" />
<Compile Include="src\BindingProjectTests.cs" />
<Compile Include="src\SmokeTests.cs" />
<Compile Include="src\RegistrarTests.cs" />
<Compile Include="src\AssemblyReferencesTests.cs" />
<Compile Include="src\PackageReferenceTests.cs" />
<Compile Include="src\BindingProjectNoEmbeddingTests.cs" />
<Compile Include="..\..\tools\common\SdkVersions.cs">
<Link>SdkVersions.cs</Link>
</Compile>
<Compile Include="src\TargetFrameworkMutateTests.cs" />
<Compile Include="..\..\tools\common\MachO.cs">
<Link>MachO.cs</Link>
</Compile>
<Compile Include="..\..\tools\mtouch\Errors.Designer.cs">
<Link>Errors.Designer.cs</Link>
</Compile>
Expand All @@ -136,6 +84,5 @@
<Link>remoting.config</Link>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="CustomBuildActions.targets" />
</Project>
26 changes: 20 additions & 6 deletions tests/tests-mac.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "link sdk-mac", "linker\mac\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bindings-test-mac", "bindings-test\bindings-test-mac.csproj", "{20BEA313-7E2D-4209-93C0-E4D99C72695A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mmp", "..\tools\mmp\mmp.csproj", "{45F62609-8E80-4674-AB7A-8DAB24319602}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,14 +35,14 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Debug|Any CPU.ActiveCfg = Debug|x86
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Debug|Any CPU.Build.0 = Debug|x86
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Release|Any CPU.ActiveCfg = Release|x86
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Release|Any CPU.Build.0 = Release|x86
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Release|Any CPU.Build.0 = Release|Any CPU
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Default|Any CPU.ActiveCfg = Debug|x86
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Default|Any CPU.Build.0 = Debug|x86
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.AppStore|Any CPU.ActiveCfg = Debug|x86
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.AppStore|Any CPU.Build.0 = Debug|x86
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Debug|x86.ActiveCfg = Debug|x86
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Debug|x86.Build.0 = Debug|x86
{6E5405EC-1F68-4CD8-AD4B-E4CCFBE47977}.Release|x86.ActiveCfg = Release|x86
Expand Down Expand Up @@ -165,5 +167,17 @@ Global
{20BEA313-7E2D-4209-93C0-E4D99C72695A}.Debug|x86.Build.0 = Debug|Any CPU
{20BEA313-7E2D-4209-93C0-E4D99C72695A}.Release|x86.ActiveCfg = Release|Any CPU
{20BEA313-7E2D-4209-93C0-E4D99C72695A}.Release|x86.Build.0 = Release|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.Release|Any CPU.Build.0 = Release|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.Default|Any CPU.ActiveCfg = Debug|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.Default|Any CPU.Build.0 = Debug|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.Debug|x86.ActiveCfg = Debug|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.Debug|x86.Build.0 = Debug|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.Release|x86.ActiveCfg = Release|Any CPU
{45F62609-8E80-4674-AB7A-8DAB24319602}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
11 changes: 6 additions & 5 deletions tests/xharness/Harness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,17 @@ int AutoConfigureMac (bool generate_projects)
MacTestProjects.Add (new MacTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "introspection", "Mac", "introspection-mac.csproj")), targetFrameworkFlavor: MacFlavors.Modern) { Name = "introspection" });

var hard_coded_test_suites = new [] {
new { Directory = "mmptest", ProjectFile = "mmptest", Name = "mmptest", IsNUnit = true, Configurations = (string[]) null, Platform = "x86", Flavors = MacFlavors.Console, },
new { Directory = "msbuild-mac", ProjectFile = "msbuild-mac", Name = "MSBuild tests", IsNUnit = true, Configurations = (string[]) null, Platform = "x86", Flavors = MacFlavors.Console, },
new { Directory = "xammac_tests", ProjectFile = "xammac_tests", Name = "xammac tests", IsNUnit = false, Configurations = new string [] { "Debug", "Release" }, Platform = "AnyCPU", Flavors = MacFlavors.Modern, },
new { Directory = "linker/mac/link all", ProjectFile = "link all-mac", Name = "link all", IsNUnit = false, Configurations = new string [] { "Debug", "Release" }, Platform = "x86", Flavors = MacFlavors.Modern, },
new { Directory = "linker/mac/link sdk", ProjectFile = "link sdk-mac", Name = "link sdk", IsNUnit = false, Configurations = new string [] { "Debug", "Release" }, Platform = "x86", Flavors = MacFlavors.Modern, },
new { Directory = "mmptest", ProjectFile = "mmptest", Name = "mmptest", IsNUnit = true, Configurations = (string[]) null, Platform = "x86", Flavors = MacFlavors.Console, IsDotNetProject = true, },
new { Directory = "msbuild-mac", ProjectFile = "msbuild-mac", Name = "MSBuild tests", IsNUnit = true, Configurations = (string[]) null, Platform = "x86", Flavors = MacFlavors.Console, IsDotNetProject = false, },
new { Directory = "xammac_tests", ProjectFile = "xammac_tests", Name = "xammac tests", IsNUnit = false, Configurations = new string [] { "Debug", "Release" }, Platform = "AnyCPU", Flavors = MacFlavors.Modern, IsDotNetProject = false, },
new { Directory = "linker/mac/link all", ProjectFile = "link all-mac", Name = "link all", IsNUnit = false, Configurations = new string [] { "Debug", "Release" }, Platform = "x86", Flavors = MacFlavors.Modern, IsDotNetProject = false, },
new { Directory = "linker/mac/link sdk", ProjectFile = "link sdk-mac", Name = "link sdk", IsNUnit = false, Configurations = new string [] { "Debug", "Release" }, Platform = "x86", Flavors = MacFlavors.Modern, IsDotNetProject = false, },
};
foreach (var p in hard_coded_test_suites) {
MacTestProjects.Add (new MacTestProject (Path.GetFullPath (Path.Combine (RootDirectory, p.Directory, p.ProjectFile + ".csproj")), targetFrameworkFlavor: p.Flavors) {
Name = p.Name,
IsNUnitProject = p.IsNUnit,
IsDotNetProject = p.IsDotNetProject,
SolutionPath = Path.GetFullPath (Path.Combine (RootDirectory, "tests-mac.sln")),
Configurations = p.Configurations,
Platform = p.Platform,
Expand Down
19 changes: 17 additions & 2 deletions tests/xharness/Jenkins/Jenkins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,12 @@ Task PopulateTasksAsync ()
throw new NotImplementedException (project.TargetFrameworkFlavors.ToString ());
}
foreach (var config in configurations) {
MSBuildTask build = new MSBuildTask (jenkins: this, testProject: project, processManager: processManager);
BuildProjectTask build;
if (project.IsDotNetProject) {
build = new DotNetBuildTask (jenkins: this, testProject: project, processManager: processManager);
} else {
build = new MSBuildTask (jenkins: this, testProject: project, processManager: processManager);
}
build.Platform = platform;
build.CloneTestProject (project);
build.SolutionPath = project.SolutionPath;
Expand All @@ -1062,7 +1067,17 @@ Task PopulateTasksAsync ()
RunTestTask exec;
IEnumerable<RunTestTask> execs;
var ignored_main = ignored;
if (project.IsNUnitProject) {
if (project.IsDotNetProject) {
exec = new DotNetTestTask (this, (DotNetBuildTask) build, processManager) {
TestProject = build.TestProject,
Platform = build.Platform,
TestName = project.Name,
Ignored = ignored_main,
Timeout = TimeSpan.FromMinutes (120),
Mode = "macOS",
};
execs = new [] { exec };
} else if (project.IsNUnitProject) {
var dll = Path.Combine (Path.GetDirectoryName (build.TestProject.Path), project.Xml.GetOutputAssemblyPath (build.ProjectPlatform, build.ProjectConfiguration).Replace ('\\', '/'));
exec = new NUnitExecuteTask (this, build, processManager) {
Ignored = ignored_main,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class TestProject
public string Name;
public bool IsExecutableProject;
public bool IsNUnitProject;
public bool IsDotNetProject;
public string [] Configurations;
public Func<Task> Dependency;
public string FailureMessage;
Expand Down Expand Up @@ -88,7 +89,18 @@ public async Task CreateCopyAsync (ITestTask test = null)
doc.SetNode ("DocumentationFile", "bin\\$(Configuration)\\nunitlite.xml");
}
doc.ResolveAllPaths (original_path);

if (doc.IsDotNetProject ()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to move this to dotnet/xharness, created an issue not to forget: dotnet/xharness#128

// All *.cs files below the csproj are included by default, which means that we have to include them manually in the cloned csproj, because it's in a completely different directory.
var proj_dir = System.IO.Path.GetDirectoryName (original_path);
var cs_files = Directory.GetFiles (proj_dir, "*.cs", SearchOption.AllDirectories);
foreach (var cs in cs_files) {
var relative = cs.Substring (proj_dir.Length + 1);
if (relative.StartsWith ("bin", StringComparison.OrdinalIgnoreCase) || relative.StartsWith ("obj", StringComparison.Ordinal))
continue;
doc.AddCompileInclude (cs, cs.Replace ('/', '\\'), true);
}
}

var projectReferences = new List<TestProject> ();
foreach (var pr in doc.GetProjectReferences ()) {
var tp = new TestProject (pr.Replace ('\\', '/'));
Expand Down