Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2014-01-28 15:04:42 +0400
committerAtsushi Eno <atsushieno@gmail.com>2014-02-20 13:22:23 +0400
commitd7702ec671efa56ef91e0be7c4cf64d9aee574d4 (patch)
tree0946be77094841b1804244a23305bf3a502ed314 /mcs/class/Microsoft.Build/Test
parentb3087090a6c76d95525188f625990d0b166e0baa (diff)
do not try to load assembly with empty string specification. Add tests for import/usingTask ordering.
One of the tests fail because we actually fail to pick up imported UsingTasks.
Diffstat (limited to 'mcs/class/Microsoft.Build/Test')
-rw-r--r--mcs/class/Microsoft.Build/Test/Microsoft.Build.Execution/ProjectInstanceTest.cs65
1 files changed, 65 insertions, 0 deletions
diff --git a/mcs/class/Microsoft.Build/Test/Microsoft.Build.Execution/ProjectInstanceTest.cs b/mcs/class/Microsoft.Build/Test/Microsoft.Build.Execution/ProjectInstanceTest.cs
index 01ed253cf47..139a52b1108 100644
--- a/mcs/class/Microsoft.Build/Test/Microsoft.Build.Execution/ProjectInstanceTest.cs
+++ b/mcs/class/Microsoft.Build/Test/Microsoft.Build.Execution/ProjectInstanceTest.cs
@@ -33,6 +33,9 @@ using Microsoft.Build.Construction;
using Microsoft.Build.Execution;
using NUnit.Framework;
using Microsoft.Build.Evaluation;
+using Microsoft.Build.Utilities;
+using Microsoft.Build.Framework;
+using Microsoft.Build.Logging;
namespace MonoTests.Microsoft.Build.Execution
{
@@ -143,6 +146,68 @@ namespace MonoTests.Microsoft.Build.Execution
var proj = new ProjectInstance (root);
Assert.AreEqual ("y", proj.GetPropertyValue ("X"), "#1");
}
+
+ [Test]
+ public void FirstUsingTaskTakesPrecedence1 ()
+ {
+ FirstUsingTaskTakesPrecedenceCommon (false, false);
+ }
+
+ [Test]
+ public void FirstUsingTaskTakesPrecedence2 ()
+ {
+ FirstUsingTaskTakesPrecedenceCommon (true, true);
+ }
+
+ public void FirstUsingTaskTakesPrecedenceCommon (bool importFirst, bool buildShouldSucceed)
+ {
+ string thisAssembly = GetType ().Assembly.GetName ().Name;
+ string filename = "Test/ProjectTargetInstanceTest.FirstUsingTaskTakesPrecedence.Import.proj";
+ string imported_xml = string.Format (@"<Project DefaultTargets='Foo' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+ <UsingTask TaskName='MonoTests.Microsoft.Build.Execution.MyTask' AssemblyFile='{0}.dll' />
+</Project>", thisAssembly);
+ string usingTask = string.Format ("<UsingTask TaskName='MonoTests.Microsoft.Build.Execution.SubNamespace.MyTask' AssemblyFile='{0}.dll' />", thisAssembly);
+ string import = string.Format ("<Import Project='{0}' />", filename);
+ string project_xml = string.Format (@"<Project DefaultTargets='Foo' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+ {0}
+ {1}
+ <Target Name='Foo'>
+ <MyTask />
+ </Target>
+</Project>",
+ importFirst ? import : usingTask, importFirst ? usingTask : import);
+ try {
+ File.WriteAllText (filename, imported_xml);
+ var xml = XmlReader.Create (new StringReader (project_xml));
+ var root = ProjectRootElement.Create (xml);
+ Assert.IsTrue (root.UsingTasks.All (u => !string.IsNullOrEmpty (u.AssemblyFile)), "#1");
+ Assert.IsTrue (root.UsingTasks.All (u => string.IsNullOrEmpty (u.AssemblyName)), "#2");
+ root.FullPath = "ProjectTargetInstanceTest.FirstUsingTaskTakesPrecedence.proj";
+ var proj = new ProjectInstance (root);
+ Assert.AreEqual (buildShouldSucceed, proj.Build (), "#3");
+ } finally {
+ File.Delete (filename);
+ }
+ }
+ }
+
+ namespace SubNamespace
+ {
+ public class MyTask : Task
+ {
+ public override bool Execute ()
+ {
+ return false;
+ }
+ }
+ }
+
+ public class MyTask : Task
+ {
+ public override bool Execute ()
+ {
+ return true;
+ }
}
}