Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,193 @@
//
// Build.cs: Various build tests.
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2005 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.Xml;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine.Various {
[TestFixture]
public class Build {
[Test]
public void TestBuild1 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='1' DependsOnTargets='2'>
</Target>
<Target Name='2' DependsOnTargets='1'>
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.IsFalse (project.Build ("1"), "A1");
}
[Test]
public void TestBuild2 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='1' DependsOnTargets='2'>
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.IsFalse (project.Build ("1"));
}
[Test]
public void TestBuild3 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='A'>
<Error Text='text' />
<OnError ExecuteTargets='B' />
</Target>
<Target Name='B'>
<CreateProperty Value='B'>
<Output TaskParameter='Value' PropertyName='B'/>
</CreateProperty>
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.IsFalse (project.Build ("A"), "A1");
Assert.IsNotNull (project.EvaluatedProperties ["B"], "A2");
}
[Test]
public void TestBuild4 ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='A'>
<Error ContinueOnError='true' Text='text' />
<CreateProperty Value='A'>
<Output TaskParameter='Value' PropertyName='A'/>
</CreateProperty>
<OnError ExecuteTargets='B' />
</Target>
<Target Name='B'>
<CreateProperty Value='B'>
<Output TaskParameter='Value' PropertyName='B'/>
</CreateProperty>
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.IsTrue (project.Build ("A"), "A1");
Assert.IsNotNull (project.EvaluatedProperties ["A"], "A2");
Assert.IsNull (project.EvaluatedProperties ["B"], "A3");
}
[Test]
public void TestBuildContinueOnError ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='A'>
<Error ContinueOnError='true' Text='text' />
<CreateProperty Value='A'>
<Output TaskParameter='Value' PropertyName='A'/>
</CreateProperty>
<Error ContinueOnError='true' Text='text' />
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.IsTrue (project.Build ("A"), "A1");
Assert.IsNotNull (project.EvaluatedProperties["A"], "A2");
}
[Test]
public void TestBuildContinueOnErrorFalse ()
{
Engine engine;
Project project;
string documentString = @"
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='A'>
<Error ContinueOnError='false' Text='text' />
<CreateProperty Value='A'>
<Output TaskParameter='Value' PropertyName='A'/>
</CreateProperty>
</Target>
</Project>
";
engine = new Engine (Consts.BinPath);
project = engine.CreateNewProject ();
project.LoadXml (documentString);
Assert.IsFalse (project.Build ("A"), "A1");
Assert.IsNull (project.EvaluatedProperties["A"], "A2");
}
}
}

View File

@@ -0,0 +1,133 @@
2010-03-04 Ankit Jain <jankit@novell.com>
* Build.cs (TestBuildContinueOnError*): New.
2010-02-19 Ankit Jain <jankit@novell.com>
* Items.cs (TestItemsWithWildcards): Check for RecursiveDir metadata also.
2009-12-22 Ankit Jain <jankit@novell.com>
* Items.cs (TestItemsWithWildcards): Add Exclude also, update
test accordingly.
2009-10-08 Ankit Jain <jankit@novell.com>
* Items.cs (TestItemsWithWildcards): New.
2009-10-08 Ankit Jain <jankit@novell.com>
* Items.cs (TestItems5): Fix to work correctly on windows
and unix.
(TestReservedMetadata): New.
2009-09-10 Ankit Jain <jankit@novell.com>
* Items.cs (TestItems2a):
(TestInheritedMetadataFromItemRefs):
(TestInheritedMetadataFromItemRefs2):
(TestMetadataFromItemReferences): New.
2009-09-08 Ankit Jain <jankit@novell.com>
* Items.cs (TestItems5):
(TestItems6): Remove 'NotWorking' attribute.
2009-08-29 Ankit Jain <jankit@novell.com>
* Items.cs: Add tests for property/item evaluation.
2009-06-12 Ankit Jain <jankit@novell.com>
* Items.cs (TestItemsInTarget3a): Add another case for valid whitespace
around an item ref.
2009-05-29 Ankit Jain <jankit@novell.com>
* Conditions.cs (TestHasTrailingSlash1): New.
(TestUnknownFunction): New.
2009-05-15 Marek Sieradzki <marek.sieradzki@gmail.com>
* Items.cs
* Conditions.cs: Don't check exception messages.
2009-02-23 Ankit Jain <jankit@novell.com>
* Items.cs (TestItemsInTarget8): New.
(TestItemsInTarget9): New.
2009-02-20 Ankit Jain <jankit@novell.com>
* Conditions.cs (TestCondition11): New. Test unquoted item/property
references in conditions.
2009-01-01 Ankit Jain <jankit@novell.com>
* Items.cs: Add tests for expression parsing, mainly for concat'ing
expressions. Remove "NotWorking" for some tests that are working now.
2008-11-21 Ankit Jain <jankit@novell.com>
* Items.cs (TestItemsInTarget1): Remove 'NotWorking' attribute.
2008-11-11 Jonathan Chambers <joncham@gmail.com>
* Items.cs: Use Path.DirectorySeparatorChar instead of
hardcoded '/' to fix test on Windows.
2007-01-23 Marek Sieradzki <marek.sieradzki@gmail.com>
* EvaluationOrder.cs: Removed NotWorking from test that started to
work.
2007-01-19 Marek Sieradzki <marek.sieradzki@gmail.com>
* Condition.cs: More tests.
2007-01-12 Marek Sieradzki <marek.sieradzki@gmail.com>
* Build.cs: More tests.
2006-12-19 Marek Sieradzki <marek.sieradzki@gmail.com>
* Build.cs: Added.
* Condition.cs, ProjectElement.cs: More tests.
2006-12-18 Marek Sieradzki <marek.sieradzki@gmail.com>
* Items.cs: More tests.
2006-12-16 Marek Sieradzki <marek.sieradzki@gmail.com>
* Items.cs: Split not working test from others and add a test for
reference to item that doesn't exist.
2006-12-16 Marek Sieradzki <marek.sieradzki@gmail.com>
* Items.cs, Conditions.cs, EvaluationOrder.cs: More tests.
2006-12-11 Marek Sieradzki <marek.sieradzki@gmail.com>
* EvaluationOrder.cs: Enabled more tests.
2006-12-07 Marek Sieradzki <marek.sieradzki@gmail.com>
* EvaluationOrder.cs, Conditions.cs: More tests.
2006-12-05 Marek Sieradzki <marek.sieradzki@gmail.com>
* Conditions.cs: Enabled some more tests.
2006-12-04 Marek Sieradzki <marek.sieradzki@gmail.com>
* EvaluationOrder.cs, Condition.cs: Added.
2006-12-04 Marek Sieradzki <marek.sieradzki@gmail.com>
* Items.cs: Split big test into 4.
2006-10-06 Marek Sieradzki <marek.sieradzki@gmail.com>
* Items.cs: Added [Ignore]

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
//
// DefaultTasks: Test if tasks that are included by default are usable.
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Xml;
using Microsoft.Build.BuildEngine;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine.Various {
[TestFixture]
public class DefaultTasks {
[Test]
public void TestDefaultTasks ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Target Name='Main'>
<Message Text='Message' />
</Target>
</Project>
";
proj.LoadXml (documentString);
proj.Build ("Main");
}
}
}

View File

@@ -0,0 +1,423 @@
//
// EvaluationOrder.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Xml;
using Microsoft.Build.BuildEngine;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine.Various {
[TestFixture]
public class EvaluationOrder {
string GetItems (Project proj, string name)
{
BuildItemGroup big = proj.GetEvaluatedItemsByName (name);
string str = String.Empty;
if (big == null)
return str;
foreach (BuildItem bi in big) {
if (str == String.Empty)
str = bi.FinalItemSpec;
else
str += ";" + bi.FinalItemSpec;
}
return str;
}
[Test]
public void TestOrder0 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<Item Include='A' />
</ItemGroup>
<PropertyGroup>
<A>A</A>
<Property>@(Item)$(A)$(B)</Property>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("@(Item)A", proj.EvaluatedProperties ["Property"].FinalValue, "A1");
Assert.AreEqual ("@(Item)$(A)$(B)", proj.EvaluatedProperties ["Property"].Value, "A2");
Assert.AreEqual ("A", GetItems (proj, "Item"), "A3");
}
[Test]
public void TestOrder1 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<Item Include='A' />
</ItemGroup>
<PropertyGroup>
<Property>@(Item)</Property>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("@(Item)", proj.EvaluatedProperties ["Property"].FinalValue, "A1");
Assert.AreEqual ("@(Item)", proj.EvaluatedProperties ["Property"].Value, "A2");
Assert.AreEqual ("A", GetItems (proj, "Item"), "A3");
}
[Test]
public void TestOrder2 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Property>@(Item)</Property>
</PropertyGroup>
<ItemGroup>
<Item Include='A' />
</ItemGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("@(Item)", proj.EvaluatedProperties ["Property"].FinalValue, "A1");
Assert.AreEqual ("@(Item)", proj.EvaluatedProperties ["Property"].Value, "A2");
Assert.AreEqual ("A", GetItems (proj, "Item"), "A3");
}
[Test]
public void TestOrder3 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Property>A</Property>
</PropertyGroup>
<ItemGroup>
<Item Include='$(Property)' />
</ItemGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("A", proj.EvaluatedProperties ["Property"].FinalValue, "A1");
Assert.AreEqual ("A", proj.EvaluatedProperties ["Property"].Value, "A2");
Assert.AreEqual ("A", GetItems (proj, "Item"), "A3");
}
[Test]
public void TestOrder4 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<Item Include='$(Property)' />
</ItemGroup>
<PropertyGroup>
<Property>A</Property>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("A", proj.EvaluatedProperties ["Property"].FinalValue, "A1");
Assert.AreEqual ("A", proj.EvaluatedProperties ["Property"].Value, "A2");
Assert.AreEqual ("A", GetItems (proj, "Item"), "A3");
}
[Test]
public void TestOrder5 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<Item Include='$(Property)' />
</ItemGroup>
<PropertyGroup>
<Property>A</Property>
<Property2>@(Item)</Property2>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("A", proj.EvaluatedProperties ["Property"].FinalValue, "A1");
Assert.AreEqual ("A", proj.EvaluatedProperties ["Property"].Value, "A2");
Assert.AreEqual ("A", GetItems (proj, "Item"), "A3");
Assert.AreEqual ("@(Item)", proj.EvaluatedProperties ["Property2"].FinalValue, "A4");
Assert.AreEqual ("@(Item)", proj.EvaluatedProperties ["Property2"].Value, "A5");
}
[Test]
[Category ("NotWorking")]
public void TestOrder6 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<Item Include='A' />
<Item2 Include='$(Property)' />
</ItemGroup>
<PropertyGroup>
<Property>@(Item)</Property>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("@(Item)", proj.EvaluatedProperties ["Property"].FinalValue, "A1");
Assert.AreEqual ("@(Item)", proj.EvaluatedProperties ["Property"].Value, "A2");
Assert.AreEqual ("A", GetItems (proj, "Item"), "A3");
Assert.AreEqual ("A", GetItems (proj, "Item2"), "A4");
}
[Test]
[Category ("NotDotNet")]
public void TestImportOrder1 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Property>Test/resources/Import.csproj</Property>
</PropertyGroup>
<Import Project='$(Property)'/>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("Value", proj.EvaluatedProperties ["ImportedProperty"].FinalValue, "A1");
Assert.AreEqual ("Value", proj.EvaluatedProperties ["ImportedProperty"].Value, "A2");
}
[Test]
[Category ("NotDotNet")]
[ExpectedException (typeof (InvalidProjectFileException))]
public void TestImportOrder2 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='$(Property)'/>
<PropertyGroup>
<Property>Test/resources/Import.csproj</Property>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("Value", proj.EvaluatedProperties ["ImportedProperty"].FinalValue, "A1");
Assert.AreEqual ("Value", proj.EvaluatedProperties ["ImportedProperty"].Value, "A2");
}
[Test]
// NOTE: It will try to import "@(Item)" instead of Test/...
[ExpectedException (typeof (InvalidProjectFileException))]
public void TestImportOrder3 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<ItemGroup>
<Item Include='Test/resources/Import.csproj' />
</ItemGroup>
<Import Project='@(Item)'/>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("Value", proj.EvaluatedProperties ["ImportedProperty"].FinalValue, "A1");
Assert.AreEqual ("Value", proj.EvaluatedProperties ["ImportedProperty"].Value, "A2");
}
[Test]
// NOTE: It will try to import "@(Item)" instead of Test/...
[ExpectedException (typeof (InvalidProjectFileException))]
public void TestImportOrder4 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='@(Item)'/>
<ItemGroup>
<Item Include='Test/resources/Import.csproj' />
</ItemGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("Value", proj.EvaluatedProperties ["ImportedProperty"].FinalValue, "A1");
Assert.AreEqual ("Value", proj.EvaluatedProperties ["ImportedProperty"].Value, "A2");
}
[Test]
[Category ("NotDotNet")]
public void TestImportOrder5 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<ImportedProperty>AnotherValue</ImportedProperty>
</PropertyGroup>
<Import Project='Test/resources/Import.csproj'/>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("Value", proj.EvaluatedProperties ["ImportedProperty"].FinalValue, "A1");
Assert.AreEqual ("Value", proj.EvaluatedProperties ["ImportedProperty"].Value, "A2");
}
[Test]
[Category ("NotDotNet")]
public void TestImportOrder6 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/Import.csproj'/>
<PropertyGroup>
<ImportedProperty>AnotherValue</ImportedProperty>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("AnotherValue", proj.EvaluatedProperties ["ImportedProperty"].FinalValue, "A1");
Assert.AreEqual ("AnotherValue", proj.EvaluatedProperties ["ImportedProperty"].Value, "A2");
}
[Test]
[Category ("NotDotNet")]
public void TestImportOrder7 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<Import Project='Test/resources/Import.csproj'/>
<PropertyGroup>
<ImportedProperty>Another$(ImportedProperty)</ImportedProperty>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("AnotherValue", proj.EvaluatedProperties ["ImportedProperty"].FinalValue, "A1");
Assert.AreEqual ("Another$(ImportedProperty)", proj.EvaluatedProperties ["ImportedProperty"].Value, "A2");
}
[Test]
public void TestUsingTaskOrder1 ()
{
Engine engine = new Engine (Consts.BinPath);
Project proj = engine.CreateNewProject ();
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Property>Test\resources\TestTasks.dll</Property>
</PropertyGroup>
<UsingTask AssemblyFile='$(Property)' TaskName='TrueTestTask' />
</Project>
";
proj.LoadXml (documentString);
UsingTask [] ut = new UsingTask [1];
proj.UsingTasks.CopyTo (ut, 0);
Assert.AreEqual ("$(Property)", ut [0].AssemblyFile, "A1");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,86 @@
//
// ProjectElement.cs
//
// Author:
// Marek Sieradzki (marek.sieradzki@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Xml;
using Microsoft.Build.BuildEngine;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine.Various {
[TestFixture]
public class ProjectElement {
// Clones a project by reloading from original.Xml
private Project CloneProject (Project original)
{
Project clone;
clone = original.ParentEngine.CreateNewProject ();
clone.LoadXml (original.Xml);
return clone;
}
[Test]
public void TestDefaultTargetsAttribute ()
{
Engine engine;
Project proj;
Project cproj;
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" DefaultTargets=""Build;Compile"">
</Project>
";
engine = new Engine (Consts.BinPath);
proj = engine.CreateNewProject ();
Assert.AreEqual (String.Empty, proj.FullFileName, "A1");
proj.LoadXml (documentString);
Assert.AreEqual (String.Empty, proj.FullFileName, "A2");
proj.DefaultTargets = "Build";
Assert.AreEqual ("Build", proj.DefaultTargets, "A3");
cproj = CloneProject (proj);
Assert.AreEqual (proj.DefaultTargets, cproj.DefaultTargets, "A4");
}
[Test]
[ExpectedException (typeof (InvalidProjectFileException))]
public void TestRootElement ()
{
Engine engine;
Project proj;
string documentString = @"
<something>
</something>
";
engine = new Engine (Consts.BinPath);
proj = engine.CreateNewProject ();
proj.LoadXml (documentString);
}
}
}

View File

@@ -0,0 +1,195 @@
//
// Properties.cs
//
// Authors:
// Marek Sieradzki (marek.sieradzki@gmail.com)
// Marek Safar (marek.safar@gmail.com)
//
// (C) 2006 Marek Sieradzki
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Xml;
using Microsoft.Build.BuildEngine;
using NUnit.Framework;
namespace MonoTests.Microsoft.Build.BuildEngine.Various {
[TestFixture]
public class Properties {
Project proj;
[SetUp]
public void Setup ()
{
Engine engine = new Engine (Consts.BinPath);
proj = engine.CreateNewProject ();
}
[Test]
public void PropertyReference ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Config>debug</Config>
<ExpProp>$(Config)-$(Config)</ExpProp>
<ExpProp2> $(Config) $(Config) </ExpProp2>
<InvProp1>$(Config-$(Config)</InvProp1>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual (1, proj.PropertyGroups.Count, "A1");
Assert.AreEqual ("debug", proj.GetEvaluatedProperty ("Config"), "A2");
Assert.AreEqual ("debug-debug", proj.GetEvaluatedProperty ("ExpProp"), "A3");
Assert.AreEqual (" debug debug ", proj.GetEvaluatedProperty ("ExpProp2"), "A4");
Assert.AreEqual ("$(Config-$(Config)", proj.GetEvaluatedProperty ("InvProp1"), "A5");
}
[Test]
[Category ("NotDotNet")]
public void PropertyReference2 ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<UsingTask TaskName='StringTestTask' AssemblyFile='Test\resources\TestTasks.dll' />
<PropertyGroup>
<A>A</A>
<B>B</B>
</PropertyGroup>
<Target Name='Main' >
<StringTestTask Array='$(A)$(B)'>
<Output TaskParameter='Array' ItemName='Out' />
</StringTestTask>
</Target>
</Project>
";
proj.LoadXml (documentString);
proj.Build ("Main");
Assert.AreEqual (1, proj.GetEvaluatedItemsByName ("Out").Count, "A1");
Assert.AreEqual ("AB", proj.GetEvaluatedItemsByName ("Out") [0].Include, "A2");
}
[Test]
public void StringInstanceProperties ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Config>debug</Config>
<NullValue>null</NullValue>
<TargetValue> </TargetValue>
<Prop1>$(Config.Substring(0,3)) </Prop1>
<Prop2>$(Config.Length )</Prop2>
<Prop3>$(Config.StartsWith ('DE', System.StringComparison.OrdinalIgnoreCase))</Prop3>
<Prop4>$(NullValue.StartsWith ('Te', StringComparison.OrdinalIgnoreCase))</Prop4>
<Prop5>$(TargetValue.Trim('\\'))</Prop5>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("deb ", proj.GetEvaluatedProperty ("Prop1"), "#1");
Assert.AreEqual ("5", proj.GetEvaluatedProperty ("Prop2"), "#2");
Assert.AreEqual ("True", proj.GetEvaluatedProperty ("Prop3"), "#3");
Assert.AreEqual ("False", proj.GetEvaluatedProperty ("Prop4"), "#4");
Assert.AreEqual ("", proj.GetEvaluatedProperty ("Prop5"), "#5");
}
[Test]
public void AllowedFrameworkMembers ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Prop1>$([System.Byte]::MaxValue)</Prop1>
<Prop2>$([System.math]::Abs (-4.2) )</Prop2>
<Prop3>$([System.DateTime]::Today )</Prop3>
<Prop4>$([System.Char]::GetNumericValue('3'))</Prop4>
<Prop5>$([System.String]::Compare (Null, nUll))</Prop5>
<Prop6>$([System.Environment]::GetLogicalDrives ( ))</Prop6>
<Prop7>$([System.String]::Concat (`,`, `n`, `,`))</Prop7>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("255", proj.GetEvaluatedProperty ("Prop1"), "#1");
Assert.AreEqual ("4.2", proj.GetEvaluatedProperty ("Prop2"), "#2");
Assert.AreEqual (DateTime.Today.ToString (), proj.GetEvaluatedProperty ("Prop3"), "#3");
Assert.AreEqual ("3", proj.GetEvaluatedProperty ("Prop4"), "#4");
Assert.AreEqual ("0", proj.GetEvaluatedProperty ("Prop5"), "#5");
Assert.AreEqual (string.Join (";", Environment.GetLogicalDrives ()), proj.GetEvaluatedProperty ("Prop6"), "#6");
Assert.AreEqual (",n,", proj.GetEvaluatedProperty ("Prop7"), "#7");
}
[Test]
public void InstanceMethodOnStaticProperty ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Prop1>$([System.DateTime]::Now.ToString(""yyyy.MM.dd""))</Prop1>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual (DateTime.Now.ToString ("yyyy.MM.dd"), proj.GetEvaluatedProperty ("Prop1"), "#1");
}
[Test]
public void InstanceMemberOnStaticProperty ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<Prop1>$([System.DateTime]::Now.Year)</Prop1>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual (DateTime.Now.Year.ToString (), proj.GetEvaluatedProperty ("Prop1"), "#1");
}
[Test]
public void MSBuildPropertyFunctions ()
{
string documentString = @"
<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
<PropertyGroup>
<NumberOne>0.6</NumberOne>
<NumberTwo>6</NumberTwo>
<Prop1>$([MSBuild]::Add($(NumberOne), $(NumberTwo)))</Prop1>
</PropertyGroup>
</Project>
";
proj.LoadXml (documentString);
Assert.AreEqual ("6.6", proj.GetEvaluatedProperty ("Prop1"), "#1");
}
}
}