Imported Upstream version 4.4.0.122

Former-commit-id: a99f46acaeba3ab496c7afc02c29b839e30a0d0b
This commit is contained in:
Xamarin Public Jenkins
2016-04-12 13:19:31 -04:00
parent a632333cc7
commit d444f0caa4
118 changed files with 4121 additions and 1632 deletions

View File

@@ -32,6 +32,7 @@ using Microsoft.Build.Framework;
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
using NUnit.Framework;
using System.IO;
using System.Text;
namespace MonoTests.Microsoft.Build.Tasks
@@ -58,22 +59,73 @@ namespace MonoTests.Microsoft.Build.Tasks
"{DAE34193-B5C7-4488-A911-29EE15C84CBE}"
};
CreateAndCheckProject (guids, project_ref_guids, new string[] {
"AssignedProjects : foo0.csproj;foo1.csproj;foo2.csproj;foo3.csproj: SetConfig: Configuration=Release",
CreateAndCheckProject (guids, new bool[] {true, true, true, true, true, true},
project_ref_guids, new string[] {
"AssignedProjects : foo0.csproj;foo1.csproj;foo2.csproj;foo3.csproj;foo4.csproj: SetConfig: Configuration=Release",
"AssignedProjects : foo0.csproj: SetPlatform: Platform=AnyCPU0",
"AssignedProjects : foo1.csproj: SetPlatform: Platform=AnyCPU1",
"AssignedProjects : foo2.csproj: SetPlatform: Platform=AnyCPU2",
"AssignedProjects : foo3.csproj: SetPlatform: Platform=AnyCPU3",
"UnassignedProjects : foo4.csproj"},
"AssignedProjects : foo4.csproj: SetPlatform: Platform=AnyCPU4",
"UnassignedProjects : "},
true,
"A1#");
}
[Test]
public void TestInvalidProjectGuid ()
public void TestNoGuidAndNoAbsolutePathFound()
{
string[] guids = new string[] {
"asd"
};
string[] project_ref_guids = new string[] {
"{DAE34193-B5C7-4488-A911-29EE15C84CB8}",
"invalid guid",
""
};
CreateAndCheckProject (guids, new bool[]{false},
project_ref_guids,
new string[] {
"AssignedProjects : : SetConfig: ",
"AssignedProjects : : SetPlatform: ",
"UnassignedProjects : foo0.csproj;foo1.csproj;foo2.csproj"
},
true, "A1#");
}
[Test]
public void TestInvalidProjectGuidWithAbsolutePath ()
{
string[] guids = new string[] {
null, // no AbsPath
"another invalid guid", // has AbsPath
};
string[] project_ref_guids = new string[] {
"1234zxc", // this won't match because no AbsPath
"xzxoiu", // match with the second project, foo1.csproj
"{23F291D9-78DF-4133-8CF2-78CE104DDE63}",
"badref" // no corresponding project at all
};
CreateAndCheckProject (guids, new bool[]{false, true},
project_ref_guids,
new string[] {
"AssignedProjects : foo1.csproj: SetConfig: Configuration=Release",
"AssignedProjects : foo1.csproj: SetPlatform: Platform=AnyCPU1",
"UnassignedProjects : foo0.csproj;foo2.csproj;foo3.csproj"
},
true, "A1#");
}
[Test]
public void TestNoGuidWithAbsolutePath ()
{
string[] guids = new string[] {
"",
null
};
string[] project_ref_guids = new string[] {
@@ -82,7 +134,14 @@ namespace MonoTests.Microsoft.Build.Tasks
"invalid guid"
};
CreateAndCheckProject (guids, project_ref_guids, null, false, "A1#");
CreateAndCheckProject (guids, new bool[]{true, false},
project_ref_guids,
new string[] {
"AssignedProjects : foo0.csproj: SetConfig: Configuration=Release",
"AssignedProjects : foo0.csproj: SetPlatform: Platform=AnyCPU0",
"UnassignedProjects : foo1.csproj;foo2.csproj"
},
true, "A1#");
}
[Test]
@@ -97,7 +156,8 @@ namespace MonoTests.Microsoft.Build.Tasks
"{23F291D9-78DF-4133-8CF2-78CE104DDE63}"
};
CreateAndCheckProject (guids, project_ref_guids,
CreateAndCheckProject (guids, new bool[]{false, true},
project_ref_guids,
new string [] {
"AssignedProjects : foo1.csproj: SetConfig: Configuration=Release",
"AssignedProjects : foo1.csproj: SetPlatform: Platform=AnyCPU0",
@@ -106,14 +166,14 @@ namespace MonoTests.Microsoft.Build.Tasks
}
void CreateAndCheckProject (string[] guids, string[] project_ref_guids, string[] messages, bool build_result, string prefix)
void CreateAndCheckProject (string[] guids, bool[] set_project_paths, string[] project_ref_guids, string[] messages, bool build_result, string prefix)
{
Engine engine = new Engine (Consts.BinPath);
Project project = engine.CreateNewProject ();
TestMessageLogger testLogger = new TestMessageLogger ();
engine.RegisterLogger (testLogger);
string projectString = CreateProject (guids, project_ref_guids);
string projectString = CreateProject (guids, set_project_paths, project_ref_guids);
project.LoadXml (projectString);
try {
@@ -131,12 +191,12 @@ namespace MonoTests.Microsoft.Build.Tasks
}
}
string CreateProject (string[] guids, string[] project_ref_guids)
string CreateProject (string[] guids, bool[] set_project_paths, string[] project_ref_guids)
{
StringBuilder sb = new StringBuilder ();
sb.Append (@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">");
sb.Append ("\n" + GetUsingTask ("AssignProjectConfiguration"));
sb.AppendFormat (@"<PropertyGroup>{0}</PropertyGroup>", CreateSolutionConfigurationProperty (guids, "Release|AnyCPU"));
sb.AppendFormat (@"<PropertyGroup>{0}</PropertyGroup>", CreateSolutionConfigurationProperty (guids, set_project_paths, "Release|AnyCPU"));
sb.Append (CreateProjectReferencesItemGroup (project_ref_guids));
sb.Append ("\n\t<Target Name=\"1\">\n");
@@ -154,13 +214,19 @@ namespace MonoTests.Microsoft.Build.Tasks
return sb.ToString ();
}
string CreateSolutionConfigurationProperty (string[] guids, string config_str)
string CreateSolutionConfigurationProperty (string[] guids, bool[] set_project_paths, string config_str)
{
string abs_proj_path_prefix = Path.GetFullPath ("foo");
StringBuilder sb = new StringBuilder ();
sb.Append ("\n<CurrentSolutionConfigurationContents>\n");
sb.Append ("\t<foo xmlns=\"\">\n");
for (int i = 0; i < guids.Length; i++) {
sb.AppendFormat ("\t\t<bar Project=\"{0}\">{1}{2}</bar>\n",
sb.Append ("\t\t<bar");
if (guids[i] != null)
sb.AppendFormat (" Project=\"{0}\"", guids[i]);
if (set_project_paths[i])
sb.AppendFormat (" AbsolutePath=\"{0}{1}.csproj\" ", abs_proj_path_prefix, i);
sb.AppendFormat (">{1}{2}</bar>\n",
guids[i], config_str, i);
}
sb.Append ("\t</foo>\n");
@@ -173,8 +239,12 @@ namespace MonoTests.Microsoft.Build.Tasks
{
StringBuilder sb = new StringBuilder ();
sb.Append ("\n<ItemGroup>\n");
for (int i = 0; i < guids.Length; i ++)
sb.AppendFormat ("\t<ProjectReference Include=\"foo{1}.csproj\"><Project>{0}</Project></ProjectReference>\n", guids [i], i);
for (int i = 0; i < guids.Length; i ++) {
sb.AppendFormat ("\t<ProjectReference Include=\"foo{0}.csproj\">", i);
if (guids[i] != null)
sb.AppendFormat ("<Project>{0}</Project>", guids[i]);
sb.Append ("</ProjectReference>\n");
}
sb.Append ("</ItemGroup>\n");
return sb.ToString ();
}

View File

@@ -145,13 +145,6 @@ namespace MonoTests.Microsoft.Build.Tasks {
Assert.AreEqual (0, testLogger.CheckHead ("Text", "HelpKeyword", "Code"), "A1");
}
[Test]
public void TestExecute1 ()
{
Error error = new Error ();
Assert.AreEqual (false, error.Execute (), "A1");
}
}
}

View File

@@ -197,6 +197,19 @@ namespace MonoTests.Microsoft.Build.Tasks
return 0;
}
public int CheckFullLog (string text)
{
for (int i = 0; i < all_messages.Count; i ++) {
BuildEventArgs arg = all_messages [i];
if (text == arg.Message) {
all_messages.RemoveAt (i);
return 0;
}
}
return 1;
}
public void DumpMessages ()
{
foreach (BuildEventArgs arg in all_messages)