@joebigelow / wix-1 / commits / d97c0d16

Update PackageVerifier to calculate installed path of file.

Fixes 6676

Sean Hall committed Mar 30, 2022 at 17:07 UTC d97c0d1685ef4c3840776327e76ce25d4dbdbeb1
2 files changed +41 -14
src/test/burn/WixTestTools/PackageVerifier.cs
+33 -10
@@ -19,19 +19,42 @@ namespace WixTestTools
19
20 public string GetInstalledFilePath(string filename)
21 {
22 - return this.TestContext.GetTestInstallFolder(this.IsX64, Path.Combine(this.GetInstallFolderName(), filename));
23 - }
22 + var fileRow = this.WiData.Tables["File"].Rows.Single(r => r.FieldAsString(2).Contains(filename));
23 + var componentRow = this.WiData.Tables["Component"].Rows.Single(r => r.FieldAsString(0) == fileRow.FieldAsString(1));
24 + var directoryId = componentRow.FieldAsString(2);
25 + var path = filename;
26
25 - public string GetInstallFolderName()
26 - {
27 - var row = this.WiData.Tables["Directory"].Rows.Single(r => r.FieldAsString(0) == "INSTALLFOLDER");
28 - var value = row.FieldAsString(2);
29 - var longNameIndex = value.IndexOf('|') + 1;
30 - if (longNameIndex > 0)
27 + while (directoryId != null)
28 {
32 - return value.Substring(longNameIndex);
29 + string directoryName;
30 +
31 + if (directoryId == "ProgramFiles6432Folder")
32 + {
33 + var baseDirectory = this.IsX64 ? Environment.SpecialFolder.ProgramFiles : Environment.SpecialFolder.ProgramFilesX86;
34 + directoryName = Environment.GetFolderPath(baseDirectory);
35 +
36 + directoryId = null;
37 + }
38 + else if (directoryId == "LocalAppDataFolder")
39 + {
40 + directoryName = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
41 +
42 + directoryId = null;
43 + }
44 + else
45 + {
46 + var directoryRow = this.WiData.Tables["Directory"].Rows.Single(r => r.FieldAsString(0) == directoryId);
47 + var value = directoryRow.FieldAsString(2);
48 + var longNameIndex = value.IndexOf('|') + 1;
49 + directoryName = longNameIndex > 0 ? value.Substring(longNameIndex) : value;
50 +
51 + directoryId = directoryRow.FieldAsString(1);
52 + }
53 +
54 + path = Path.Combine(directoryName, path);
55 }
34 - return value;
56 +
57 + return path;
58 }
59
60 public string GetProperty(string name)
src/test/burn/WixToolsetTest.BurnE2E/BasicFunctionalityTests.cs
+8 -4
@@ -41,10 +41,14 @@ namespace WixToolsetTest.BurnE2E
41 this.CanInstallAndUninstallSimpleBundle("PackageA_x64", "BundleA_x64");
42 }
43
44 - [Fact(Skip = "Need to update assertions for per-user-ness.")]
44 +#if DEBUG
45 + [Fact(Skip = "0xc0000005 during shutdown from tiptsf.dll")]
46 +#else
47 + [Fact]
48 +#endif
49 public void CanInstallAndUninstallSimplePerUserBundle_x64_wixstdba()
50 {
47 - this.CanInstallAndUninstallSimpleBundle("PackageApu_x64", "BundleApu_x64");
51 + this.CanInstallAndUninstallSimpleBundle("PackageApu_x64", "BundleApu_x64", "PackagePerUser.wxs");
52 }
53
54 [Fact]
@@ -65,13 +69,13 @@ namespace WixToolsetTest.BurnE2E
69 this.CanInstallAndUninstallSimpleBundle("PackageA_x64", "BundleD_x64");
70 }
71
68 - private void CanInstallAndUninstallSimpleBundle(string packageName, string bundleName)
72 + private void CanInstallAndUninstallSimpleBundle(string packageName, string bundleName, string fileName = "Package.wxs")
73 {
74 var package = this.CreatePackageInstaller(packageName);
75
76 var bundle = this.CreateBundleInstaller(bundleName);
77
74 - var packageSourceCodeInstalled = package.GetInstalledFilePath("Package.wxs");
78 + var packageSourceCodeInstalled = package.GetInstalledFilePath(fileName);
79
80 // Source file should *not* be installed
81 Assert.False(File.Exists(packageSourceCodeInstalled), $"{packageName} payload should not be there on test start: {packageSourceCodeInstalled}");