From 4d896b683e3d490e03f8cd10276b32e1f461699e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 1 Jul 2022 10:29:44 -0500 Subject: Some test improvements. --- .../BadInputFixture.cs | 40 +++++++++++++++++-- .../BurnRemotePayloadSubcommandFixture.cs | 31 +++++++++------ .../ExePackageFixture.cs | 15 ++++---- .../FeatureFixture.cs | 5 ++- .../MsiPackageFixture.cs | 5 +-- .../MsuPackageFixture.cs | 45 +++++++++++++++++++--- .../BundleWithInvalidLocValues.wxs | 3 +- .../BundleWithReservedVariableNames.wxs | 7 ++++ 8 files changed, 114 insertions(+), 37 deletions(-) create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithReservedVariableNames.wxs (limited to 'src') diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs index 815c5ccd..4d308fa5 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs @@ -163,17 +163,15 @@ namespace WixToolsetTest.CoreIntegration { var baseFolder = fs.GetFolder(); var intermediateFolder = Path.Combine(baseFolder, "obj"); + var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); var result = WixRunner.Execute(new[] { "build", Path.Combine(folder, "BundleWithInvalid", "BundleWithInvalidLocVariableNames.wxs"), "-loc", Path.Combine(folder, "BundleWithInvalid", "BundleWithInvalidLocValues.wxl"), - "-bindpath", Path.Combine(folder, ".Data"), - "-bindpath", Path.Combine(folder, "DecompileSingleFileCompressed"), - "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), "-intermediateFolder", intermediateFolder, - "-o", Path.Combine(baseFolder, @"bin\test.exe") + "-o", wixlibPath, }); var messages = result.Messages.Select(m => m.ToString()).ToList(); @@ -190,6 +188,39 @@ namespace WixToolsetTest.CoreIntegration } } + [Fact] + public void CannotBuildBundleWithReservedVariableNames() + { + var folder = TestData.Get(@"TestData"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "BundleWithInvalid", "BundleWithReservedVariableNames.wxs"), + "-intermediateFolder", intermediateFolder, + "-o", wixlibPath, + }); + + var messages = result.Messages.Select(m => m.ToString()).ToList(); + messages.Sort(); + + WixAssert.CompareLineByLine(new[] + { + "The SetVariable/@Variable attribute's value, 'WixBundleInstalled', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFilesFolder', 'CompatibilityMode', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleCommandLineAction', 'WixBundleForcedRestartPackage', 'WixBundleElevated', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleTag', or 'WixBundleVersion'.", + "The Variable/@Name attribute's value begins with the reserved prefix 'Wix'. Some prefixes are reserved by the Windows Installer and WiX toolset for well-known values. Change your attribute's value to not begin with the same prefix.", + "The Variable/@Name attribute's value, 'AppDataFolder', is one of the illegal options: 'AdminToolsFolder', 'AppDataFolder', 'CommonAppDataFolder', 'CommonFiles64Folder', 'CommonFilesFolder', 'CompatibilityMode', 'Date', 'DesktopFolder', 'FavoritesFolder', 'FontsFolder', 'InstallerName', 'InstallerVersion', 'LocalAppDataFolder', 'LogonUser', 'MyPicturesFolder', 'NativeMachine', 'NTProductType', 'NTSuiteBackOffice', 'NTSuiteDataCenter', 'NTSuiteEnterprise', 'NTSuitePersonal', 'NTSuiteSmallBusiness', 'NTSuiteSmallBusinessRestricted', 'NTSuiteWebServer', 'PersonalFolder', 'Privileged', 'ProgramFiles64Folder', 'ProgramFiles6432Folder', 'ProgramFilesFolder', 'ProgramMenuFolder', 'RebootPending', 'SendToFolder', 'ServicePackLevel', 'StartMenuFolder', 'StartupFolder', 'System64Folder', 'SystemFolder', 'TempFolder', 'TemplateFolder', 'TerminalServer', 'UserLanguageID', 'UserUILanguageID', 'VersionMsi', 'VersionNT', 'VersionNT64', 'WindowsFolder', 'WindowsVolume', 'WixBundleAction', 'WixBundleCommandLineAction', 'WixBundleForcedRestartPackage', 'WixBundleElevated', 'WixBundleInstalled', 'WixBundleProviderKey', 'WixBundleTag', or 'WixBundleVersion'.", + }, messages.ToArray()); + + Assert.Equal(348, result.ExitCode); + } + } + [Fact] public void GuardsAgainstVariousBundleValuesFromLoc() { @@ -217,6 +248,7 @@ namespace WixToolsetTest.CoreIntegration WixAssert.CompareLineByLine(new[] { + "*Search/@Condition contains the built-in Variable 'WixBundleAction', which is not available when it is evaluated. (Unavailable Variables are: 'WixBundleAction'.). Rewrite the condition to avoid Variables that are never valid during its evaluation.", "Bundle/@Condition contains the built-in Variable 'WixBundleInstalled', which is not available when it is evaluated. (Unavailable Variables are: 'RebootPending', 'WixBundleAction', or 'WixBundleInstalled'.). Rewrite the condition to avoid Variables that are never valid during its evaluation.", "ExePackage/@DetectCondition contains the built-in Variable 'WixBundleAction', which is not available when it is evaluated. (Unavailable Variables are: 'WixBundleAction'.). Rewrite the condition to avoid Variables that are never valid during its evaluation.", "The CommandLine/@Condition attribute's value '=' is not a valid bundle condition.", diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BurnRemotePayloadSubcommandFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BurnRemotePayloadSubcommandFixture.cs index dbc4d591..7dae1ee9 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/BurnRemotePayloadSubcommandFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/BurnRemotePayloadSubcommandFixture.cs @@ -59,13 +59,11 @@ namespace WixToolsetTest.CoreIntegration { "Payload", new List { "Size", "Hash" } }, }; WixAssert.StringEqual( - "" + "" + "" + "" + "" + - "" + - "", xml.GetFragmentTestXml(ignoreAttributesByElementName)); + "", xml.GetTestXml(ignoreAttributesByElementName)); // ExternalWithoutDownloadUrl var externalWithoutDownloadUrlOutFile = Path.Combine(outputFolder, "externalWithoutDownloadUrl_out.xml"); @@ -83,7 +81,6 @@ namespace WixToolsetTest.CoreIntegration xml = File.ReadAllText(externalWithoutDownloadUrlOutFile); WixAssert.StringEqual( - "" + "" + "" + "" + @@ -92,8 +89,7 @@ namespace WixToolsetTest.CoreIntegration "" + "" + "" + - "" + - "", xml.GetFragmentTestXml(ignoreAttributesByElementName)); + "", xml.GetTestXml(ignoreAttributesByElementName)); // External var externalOutFile = Path.Combine(outputFolder, "external_out.xml"); @@ -111,7 +107,6 @@ namespace WixToolsetTest.CoreIntegration xml = File.ReadAllText(externalOutFile); WixAssert.StringEqual( - "" + "" + "" + "" + @@ -121,8 +116,7 @@ namespace WixToolsetTest.CoreIntegration "" + "" + "" + - "" + - "", xml.GetFragmentTestXml(ignoreAttributesByElementName)); + "", xml.GetTestXml(ignoreAttributesByElementName)); // All var allOutFile = Path.Combine(outputFolder, "all_out.xml"); @@ -140,7 +134,6 @@ namespace WixToolsetTest.CoreIntegration xml = File.ReadAllText(allOutFile); WixAssert.StringEqual( - "" + "" + "" + "" + @@ -151,8 +144,7 @@ namespace WixToolsetTest.CoreIntegration "" + "" + "" + - "" + - "", xml.GetFragmentTestXml(ignoreAttributesByElementName)); + "", xml.GetTestXml(ignoreAttributesByElementName)); } } @@ -266,6 +258,8 @@ namespace WixToolsetTest.CoreIntegration var remotePayloadSourceFile = Path.Combine(outputFolder, "remotePayload.wxs"); var intermediateFolder = Path.Combine(outputFolder, "obj"); var bundleFile = Path.Combine(intermediateFolder, "out.exe"); + var baFolderPath = Path.Combine(outputFolder, "ba"); + var extractFolderPath = Path.Combine(outputFolder, "extract"); var result = WixRunner.Execute(new[] { @@ -313,6 +307,17 @@ namespace WixToolsetTest.CoreIntegration }); result.AssertSuccess(); + + var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); + extractResult.AssertSuccess(); + + var msuPackages = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Chain/burn:MsuPackage"); + WixAssert.CompareLineByLine(new string[] + { + "" + + "" + + "", + }, msuPackages); } } @@ -328,6 +333,8 @@ namespace WixToolsetTest.CoreIntegration var remotePayloadSourceFile = Path.Combine(outputFolder, "remotePayload.wxs"); var intermediateFolder = Path.Combine(outputFolder, "obj"); var bundleFile = Path.Combine(intermediateFolder, "out.exe"); + var baFolderPath = Path.Combine(outputFolder, "ba"); + var extractFolderPath = Path.Combine(outputFolder, "extract"); var result = WixRunner.Execute(new[] { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/ExePackageFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/ExePackageFixture.cs index 0dba95e1..647a5386 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/ExePackageFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/ExePackageFixture.cs @@ -44,14 +44,10 @@ namespace WixToolsetTest.CoreIntegration var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); extractResult.AssertSuccess(); - var ignoreAttributes = new Dictionary> - { - { "ExePackage", new List { "CacheId", "Size" } }, - }; - var exePackages = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Chain/burn:ExePackage", ignoreAttributes); + var exePackages = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Chain/burn:ExePackage"); WixAssert.CompareLineByLine(new string[] { - "" + + "" + "" + "", }, exePackages); @@ -465,9 +461,12 @@ namespace WixToolsetTest.CoreIntegration "-o", Path.Combine(baseFolder, "bin", "test.exe") }); + WixAssert.CompareLineByLine(new[] + { + "The ExePackage/@CacheId attribute was not found; it is required when attribute CertificatePublicKey is specified.", + }, result.Messages.Select(m => m.ToString()).ToArray()); + Assert.Equal(10, result.ExitCode); - var message = result.Messages.Single(); - Assert.Equal("The ExePackage/@CacheId attribute was not found; it is required when attribute CertificatePublicKey is specified.", message.ToString()); } } } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs index 51c83618..8beb4d8d 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/FeatureFixture.cs @@ -71,7 +71,10 @@ namespace WixToolsetTest.CoreIntegration { 7503 }, errors.Select(e => e.Id).ToArray()); - Assert.Equal("Maximum depth of the Feature tree allowed in an MSI was exceeded. An MSI does not support a Feature tree with depth greater than 16. The Feature 'Depth17' is at depth 17.", errors.Single().ToString()); + WixAssert.CompareLineByLine(new[] + { + "Maximum depth of the Feature tree allowed in an MSI was exceeded. An MSI does not support a Feature tree with depth greater than 16. The Feature 'Depth17' is at depth 17.", + }, result.Messages.Select(m => m.ToString()).ToArray()); } } } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/MsiPackageFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/MsiPackageFixture.cs index ce963df6..011dbca5 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/MsiPackageFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/MsiPackageFixture.cs @@ -41,10 +41,7 @@ namespace WixToolsetTest.CoreIntegration var extractResult = BundleExtractor.ExtractBAContainer(null, exePath, baFolderPath, extractFolderPath); extractResult.AssertSuccess(); - var msiProperties = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Chain/burn:MsiPackage/burn:MsiProperty") - .Cast() - .Select(e => e.GetTestXml()) - .ToArray(); + var msiProperties = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Chain/burn:MsiPackage/burn:MsiProperty"); WixAssert.CompareLineByLine(new[] { "" diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/MsuPackageFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/MsuPackageFixture.cs index 0ebaf868..28cb0eb5 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/MsuPackageFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/MsuPackageFixture.cs @@ -20,6 +20,10 @@ namespace WixToolsetTest.CoreIntegration { var baseFolder = fs.GetFolder(); var intermediateFolder = Path.Combine(baseFolder, "obj"); + var binFolder = Path.Combine(baseFolder, "bin"); + var bundlePath = Path.Combine(binFolder, "test.exe"); + var baFolderPath = Path.Combine(baseFolder, "ba"); + var extractFolderPath = Path.Combine(baseFolder, "extract"); var result = WixRunner.Execute(new[] { @@ -28,11 +32,22 @@ namespace WixToolsetTest.CoreIntegration "-bindpath", Path.Combine(folder, "data"), "-bindpath", dotDatafolder, "-intermediateFolder", intermediateFolder, - "-o", Path.Combine(baseFolder, "bin", "test.exe") + "-o", bundlePath, }); result.AssertSuccess(); - Assert.True(File.Exists(Path.Combine(baseFolder, "bin", "test.exe"))); + Assert.True(File.Exists(bundlePath)); + + var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); + extractResult.AssertSuccess(); + + var msuPackages = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Chain/burn:MsuPackage"); + WixAssert.CompareLineByLine(new string[] + { + "" + + "" + + "", + }, msuPackages); } } @@ -46,6 +61,10 @@ namespace WixToolsetTest.CoreIntegration { var baseFolder = fs.GetFolder(); var intermediateFolder = Path.Combine(baseFolder, "obj"); + var binFolder = Path.Combine(baseFolder, "bin"); + var bundlePath = Path.Combine(binFolder, "test.exe"); + var baFolderPath = Path.Combine(baseFolder, "ba"); + var extractFolderPath = Path.Combine(baseFolder, "extract"); var result = WixRunner.Execute(new[] { @@ -54,11 +73,22 @@ namespace WixToolsetTest.CoreIntegration "-bindpath", Path.Combine(folder, "data"), "-bindpath", dotDatafolder, "-intermediateFolder", intermediateFolder, - "-o", Path.Combine(baseFolder, "bin", "test.exe") + "-o", bundlePath, }); result.AssertSuccess(); - Assert.True(File.Exists(Path.Combine(baseFolder, "bin", "test.exe"))); + Assert.True(File.Exists(bundlePath)); + + var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); + extractResult.AssertSuccess(); + + var msuPackages = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Chain/burn:MsuPackage"); + WixAssert.CompareLineByLine(new string[] + { + "" + + "" + + "", + }, msuPackages); } } @@ -83,9 +113,12 @@ namespace WixToolsetTest.CoreIntegration "-o", Path.Combine(baseFolder, "bin", "test.exe") }); + WixAssert.CompareLineByLine(new[] + { + "The MsuPackage/@CacheId attribute was not found; it is required when attribute CertificatePublicKey is specified.", + }, result.Messages.Select(m => m.ToString()).ToArray()); + Assert.Equal(10, result.ExitCode); - var message = result.Messages.Single(); - Assert.Equal("The MsuPackage/@CacheId attribute was not found; it is required when attribute CertificatePublicKey is specified.", message.ToString()); } } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidLocValues.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidLocValues.wxs index 00263f49..74f66bbb 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidLocValues.wxs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithInvalidLocValues.wxs @@ -12,7 +12,6 @@ - + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithReservedVariableNames.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithReservedVariableNames.wxs new file mode 100644 index 00000000..af0e6625 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithInvalid/BundleWithReservedVariableNames.wxs @@ -0,0 +1,7 @@ + + + + + + + -- cgit v1.2.3-55-g6feb