Skip to content

Commit

Permalink
Fix TasksCanAddRecursiveDirBuiltInMetadata() (#6337)
Browse files Browse the repository at this point in the history
Co-authored-by: Forgind <Forgind@users.noreply.github.com>
  • Loading branch information
KirillOsenkov and Forgind committed Apr 22, 2021
1 parent 23f5b88 commit b2d404f
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/Build.UnitTests/BackEnd/TaskBuilder_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using ElementLocation = Microsoft.Build.Construction.ElementLocation;
using ILoggingService = Microsoft.Build.BackEnd.Logging.ILoggingService;
using LegacyThreadingData = Microsoft.Build.Execution.LegacyThreadingData;
using Shouldly;
using Xunit;
using Xunit.Abstractions;

Expand Down Expand Up @@ -328,31 +329,28 @@ public void MSBuildLastTaskResult()
/// else could let the item get corrupt (inconsistent values for Filename and FullPath, for example)
/// </summary>
[Fact]
[Trait("Category", "netcore-osx-failing")]
[Trait("Category", "netcore-linux-failing")]
[Trait("Category", "mono-osx-failing")]
public void TasksCanAddRecursiveDirBuiltInMetadata()
{
MockLogger logger = new MockLogger();
MockLogger logger = new MockLogger(this._testOutput);

string projectFileContents = ObjectModelHelpers.CleanupFileContents(@"
<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
string projectFileContents = ObjectModelHelpers.CleanupFileContents($@"
<Project>
<Target Name='t'>
<CreateItem Include='$(programfiles)\reference assemblies\**\*.dll;'>
<CreateItem Include='{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\**\*.dll'>
<Output TaskParameter='Include' ItemName='x' />
</CreateItem>
<Message Text='@(x)'/>
<Message Text='[%(x.RecursiveDir)]'/>
<Message Text='[%(x.RecursiveDir)]'/>
</Target>
</Project>");

Project project = new Project(XmlReader.Create(new StringReader(projectFileContents)));
List<ILogger> loggers = new List<ILogger>();
loggers.Add(logger);
bool result = project.Build("t", loggers);
project.Build("t", new[] { logger }).ShouldBeTrue();

Assert.True(result);
logger.AssertLogDoesntContain("[]");
// Assuming the current directory of the test .dll has at least one subfolder
// such as Roslyn, the log will contain [Roslyn\] (or [Roslyn/] on Unix)
string slashAndBracket = Path.DirectorySeparatorChar.ToString() + "]";
logger.AssertLogContains(slashAndBracket);
logger.AssertLogDoesntContain("MSB4118");
logger.AssertLogDoesntContain("MSB3031");
}
Expand Down

0 comments on commit b2d404f

Please sign in to comment.