diff options
Diffstat (limited to '')
| -rw-r--r-- | src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs index a8af2b4d..949746ac 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/HarvestFilesFixture.cs | |||
| @@ -9,7 +9,7 @@ namespace WixToolsetTest.CoreIntegration | |||
| 9 | using System.Linq; | 9 | using System.Linq; |
| 10 | using WixInternal.Core.TestPackage; | 10 | using WixInternal.Core.TestPackage; |
| 11 | using WixInternal.TestSupport; | 11 | using WixInternal.TestSupport; |
| 12 | using WixToolset.Data.WindowsInstaller; | 12 | using WixToolset.Data; |
| 13 | using Xunit; | 13 | using Xunit; |
| 14 | 14 | ||
| 15 | public class HarvestFilesFixture | 15 | public class HarvestFilesFixture |
| @@ -30,12 +30,12 @@ namespace WixToolsetTest.CoreIntegration | |||
| 30 | [Fact] | 30 | [Fact] |
| 31 | public void ZeroFilesHarvestedIsAWarning() | 31 | public void ZeroFilesHarvestedIsAWarning() |
| 32 | { | 32 | { |
| 33 | Build("ZeroFiles.wxs", (_, result) => | 33 | Build("ZeroFiles.wxs", (_, sourceFolder, baseFolder, result) => |
| 34 | { | 34 | { |
| 35 | var messages = result.Messages.Select(m => m.Id); | 35 | var messages = result.Messages.Select(m => FormatMessage(m, sourceFolder, baseFolder)).ToArray(); |
| 36 | Assert.Equal(new[] | 36 | WixAssert.CompareLineByLine(new[] |
| 37 | { | 37 | { |
| 38 | 8600, | 38 | "8600: Files inclusions and exclusions resulted in zero files harvested. Unless that is expected, you should verify your Files paths, inclusions, and exclusions for accuracy.", |
| 39 | }, messages); | 39 | }, messages); |
| 40 | }); | 40 | }); |
| 41 | } | 41 | } |
| @@ -43,15 +43,15 @@ namespace WixToolsetTest.CoreIntegration | |||
| 43 | [Fact] | 43 | [Fact] |
| 44 | public void MissingHarvestDirectoryIsAWarning() | 44 | public void MissingHarvestDirectoryIsAWarning() |
| 45 | { | 45 | { |
| 46 | Build("BadDirectory.wxs", (_, result) => | 46 | Build("BadDirectory.wxs", (_, sourceFolder, baseFolder, result) => |
| 47 | { | 47 | { |
| 48 | var messages = result.Messages.Select(m => m.Id); | 48 | var messages = result.Messages.Select(m => FormatMessage(m, sourceFolder, baseFolder)).ToArray(); |
| 49 | Assert.Equal(new[] | 49 | WixAssert.CompareLineByLine(new[] |
| 50 | { | 50 | { |
| 51 | 8601, | 51 | @"8601: Missing directory for harvesting files: Could not find a part of the path '<sourceFolder>\files2\MissingDirectory'.", |
| 52 | 8600, | 52 | @"8600: Files inclusions and exclusions resulted in zero files harvested. Unless that is expected, you should verify your Files paths, inclusions, and exclusions for accuracy.", |
| 53 | 8601, | 53 | @"8601: Missing directory for harvesting files: Could not find a part of the path '<sourceFolder>\files2\ThisDirectoryIsAlsoMissing'.", |
| 54 | 8600, | 54 | @"8600: Files inclusions and exclusions resulted in zero files harvested. Unless that is expected, you should verify your Files paths, inclusions, and exclusions for accuracy.", |
| 55 | }, messages); | 55 | }, messages); |
| 56 | }); | 56 | }); |
| 57 | } | 57 | } |
| @@ -392,17 +392,21 @@ namespace WixToolsetTest.CoreIntegration | |||
| 392 | 392 | ||
| 393 | private static void AssertFileIdsAndTargetPaths(string msiPath, string[] expected) | 393 | private static void AssertFileIdsAndTargetPaths(string msiPath, string[] expected) |
| 394 | { | 394 | { |
| 395 | var pkg = new WixToolset.Dtf.WindowsInstaller.Package.InstallPackage(msiPath, | 395 | var pkg = new WixToolset.Dtf.WindowsInstaller.Package.InstallPackage(msiPath, WixToolset.Dtf.WindowsInstaller.DatabaseOpenMode.ReadOnly); |
| 396 | WixToolset.Dtf.WindowsInstaller.DatabaseOpenMode.ReadOnly); | 396 | var sortedExpected = expected.OrderBy(s => s).ToArray(); |
| 397 | var sortedExpected = expected.OrderBy(s => s); | 397 | var actual = pkg.Files.OrderBy(kvp => kvp.Key).Select(kvp => $"{kvp.Key}={kvp.Value.TargetPath}").ToArray(); |
| 398 | var actual = pkg.Files.OrderBy(kvp => kvp.Key).Select(kvp => $"{kvp.Key}={kvp.Value.TargetPath}"); | ||
| 399 | 398 | ||
| 400 | Assert.Equal(sortedExpected, actual); | 399 | WixAssert.CompareLineByLine(sortedExpected, actual); |
| 401 | } | 400 | } |
| 402 | 401 | ||
| 403 | private static void Build(string file, Action<string, WixRunnerResult> tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPath = false, params string[] additionalCommandLineArguments) | 402 | private static void Build(string file, Action<string, WixRunnerResult> tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPath = false, params string[] additionalCommandLineArguments) |
| 404 | { | 403 | { |
| 405 | var folder = TestData.Get("TestData", "HarvestFiles"); | 404 | Build(file, (msiPath, sourceFolder, baseFolder, result) => tester(msiPath, result), isMsi, warningsAsErrors, addUnnamedBindPath, additionalCommandLineArguments); |
| 405 | } | ||
| 406 | |||
| 407 | private static void Build(string file, Action<string, string, string, WixRunnerResult> tester, bool isMsi = true, bool warningsAsErrors = true, bool addUnnamedBindPath = false, params string[] additionalCommandLineArguments) | ||
| 408 | { | ||
| 409 | var sourceFolder = TestData.Get("TestData", "HarvestFiles"); | ||
| 406 | 410 | ||
| 407 | using (var fs = new DisposableFileSystem()) | 411 | using (var fs = new DisposableFileSystem()) |
| 408 | { | 412 | { |
| @@ -414,17 +418,17 @@ namespace WixToolsetTest.CoreIntegration | |||
| 414 | var arguments = new List<string>() | 418 | var arguments = new List<string>() |
| 415 | { | 419 | { |
| 416 | "build", | 420 | "build", |
| 417 | Path.Combine(folder, file), | 421 | Path.Combine(sourceFolder, file), |
| 418 | "-intermediateFolder", intermediateFolder, | 422 | "-intermediateFolder", intermediateFolder, |
| 419 | "-bindpath", @$"ToBeHarvested={folder}\files1", | 423 | "-bindpath", @$"ToBeHarvested={sourceFolder}\files1", |
| 420 | "-bindpath", @$"ToBeHarvested={folder}\files2", | 424 | "-bindpath", @$"ToBeHarvested={sourceFolder}\files2", |
| 421 | "-o", msiPath, | 425 | "-o", msiPath, |
| 422 | }; | 426 | }; |
| 423 | 427 | ||
| 424 | if (addUnnamedBindPath) | 428 | if (addUnnamedBindPath) |
| 425 | { | 429 | { |
| 426 | arguments.Add("-bindpath"); | 430 | arguments.Add("-bindpath"); |
| 427 | arguments.Add(Path.Combine(folder, "unnamedbindpath")); | 431 | arguments.Add(Path.Combine(sourceFolder, "unnamedbindpath")); |
| 428 | } | 432 | } |
| 429 | 433 | ||
| 430 | if (additionalCommandLineArguments.Length > 0) | 434 | if (additionalCommandLineArguments.Length > 0) |
| @@ -434,8 +438,13 @@ namespace WixToolsetTest.CoreIntegration | |||
| 434 | 438 | ||
| 435 | var result = WixRunner.Execute(warningsAsErrors, arguments.ToArray()); | 439 | var result = WixRunner.Execute(warningsAsErrors, arguments.ToArray()); |
| 436 | 440 | ||
| 437 | tester(msiPath, result); | 441 | tester(msiPath, sourceFolder, baseFolder, result); |
| 438 | } | 442 | } |
| 439 | } | 443 | } |
| 444 | |||
| 445 | private static string FormatMessage(Message m, string sourceFolder, string baseFolder) | ||
| 446 | { | ||
| 447 | return $"{m.Id}: {m.ToString().Replace(sourceFolder, "<sourceFolder>").Replace(baseFolder, "<baseFolder>")}"; | ||
| 448 | } | ||
| 440 | } | 449 | } |
| 441 | } | 450 | } |
