public void RecursiveWildcards() { DirectoryInfo source = CreateFiles( "source", "foo.txt", "foo.exe", "foo.exe.config", "foo.dll", "foo.pdb", "foo.xml", "foo.cs", "foo.ini", "bar.dll", "bar.pdb", "bar.xml", "bar.cs", Path.Combine("baz", "baz.dll")); DirectoryInfo destination = new DirectoryInfo(Path.Combine(TestRootPath, "destination")); BuildEngine buildEngine = BuildEngine.Create(); Robocopy copyArtifacts = new Robocopy { BuildEngine = buildEngine, Sources = new ITaskItem[] { new MockTaskItem(source.FullName) { ["DestinationFolder"] = destination.FullName, ["FileMatch"] = "*exe *dll *exe.config", }, }, Sleep = duration => { }, }; copyArtifacts.Execute().ShouldBeTrue(buildEngine.GetConsoleLog()); destination.GetFiles("*", SearchOption.AllDirectories) .Select(i => i.FullName) .ShouldBe( new[] { "bar.dll", "foo.dll", "foo.exe", "foo.exe.config", Path.Combine("baz", "baz.dll"), }.Select(i => Path.Combine(destination.FullName, i)), ignoreOrder: true); }
public void NonRecursiveWildcards() { DirectoryInfo source = CreateFiles( "source", @"foo.txt", @"foo.ini", @"bar.txt", @"bar\bar.pdb", @"bar\bar.txt", @"bar.cs", @"baz\baz.dll", @"baz\baz.txt"); DirectoryInfo destination = new DirectoryInfo(Path.Combine(TestRootPath, "destination")); BuildEngine buildEngine = BuildEngine.Create(); Robocopy copyArtifacts = new Robocopy { BuildEngine = buildEngine, Sources = new ITaskItem[] { new MockTaskItem(source.FullName) { ["DestinationFolder"] = destination.FullName, ["FileMatch"] = "*txt", [nameof(RobocopyMetadata.IsRecursive)] = "false" } }, Sleep = duration => { } }; copyArtifacts.Execute().ShouldBeTrue(buildEngine.GetConsoleLog()); destination.GetFiles("*", SearchOption.AllDirectories) .Select(i => i.FullName) .ShouldBe(new[] { "bar.txt", "foo.txt", }.Select(i => Path.Combine(destination.FullName, i))); }
public void ConsoleLog() { BuildEngine buildEngine = GetBuildEngineWithEvents(i => { i.LogErrorEvent(new BuildErrorEventArgs(null, "A6DAB901460D483FBDF3A0980B14C46F", "48F7F352E2914991827100BCEB69331F", 3, 4, 0, 0, "D988473FF8634A16A0CD8FE94FF20D53", null, null)); i.LogWarningEvent(new BuildWarningEventArgs(null, "AE1B25881A694A70B2EA299C04625596", "07006F38A63E420AAB4124EBE58081BC", 1, 2, 0, 0, "3A3DD4A40DA44BA5BBB123E105EE1F71", null, null)); i.LogMessageEvent(new BuildMessageEventArgs("61BD637C7D704D4B98C25805E3111152", null, null, MessageImportance.High)); i.LogMessageEvent(new BuildMessageEventArgs("B02496FA4D3348A6997DC918EBF7455B", null, null, MessageImportance.Normal)); i.LogMessageEvent(new BuildMessageEventArgs("2C254C4346A347AE94AE5E7FB6C03B0C", null, null, MessageImportance.Low)); }); buildEngine.GetConsoleLog() .ShouldBe( @"48F7F352E2914991827100BCEB69331F(3,4): error A6DAB901460D483FBDF3A0980B14C46F: D988473FF8634A16A0CD8FE94FF20D53 07006F38A63E420AAB4124EBE58081BC(1,2): warning AE1B25881A694A70B2EA299C04625596: 3A3DD4A40DA44BA5BBB123E105EE1F71 61BD637C7D704D4B98C25805E3111152 B02496FA4D3348A6997DC918EBF7455B ", StringCompareShould.IgnoreLineEndings); }