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

Fix TasksCanAddRecursiveDirBuiltInMetadata() #6337

Merged
merged 4 commits into from
Apr 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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