diff options
| author | Bob Arnson <bob@firegiant.com> | 2020-08-24 17:25:00 -0400 |
|---|---|---|
| committer | Bob Arnson <bob@firegiant.com> | 2020-08-24 18:57:49 -0400 |
| commit | c237bb3bb00d36c50271a70baac68f49890e35e1 (patch) | |
| tree | 25f90ddb7b74180fc3ef299c899585f24e88809f /src/test/WixToolsetTest.CoreIntegration | |
| parent | 2c040e2d5b401af3607cf6e482cffeaa511d167a (diff) | |
| download | wix-c237bb3bb00d36c50271a70baac68f49890e35e1.tar.gz wix-c237bb3bb00d36c50271a70baac68f49890e35e1.tar.bz2 wix-c237bb3bb00d36c50271a70baac68f49890e35e1.zip | |
Update decompiler to use XDocument rather than generated classes.
- Use CompareXml for diffing.
- Change CustomAction/@ScriptFile to @ScriptSourceFile.
Diffstat (limited to 'src/test/WixToolsetTest.CoreIntegration')
3 files changed, 22 insertions, 141 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs b/src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs index 0a45c914..4a5cf544 100644 --- a/src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | namespace WixToolsetTest.CoreIntegration | 3 | namespace WixToolsetTest.CoreIntegration |
| 4 | { | 4 | { |
| 5 | using System.IO; | 5 | using System.IO; |
| 6 | using System.Xml.Linq; | ||
| 6 | using WixBuildTools.TestSupport; | 7 | using WixBuildTools.TestSupport; |
| 7 | using WixToolset.Core.TestPackage; | 8 | using WixToolset.Core.TestPackage; |
| 8 | using Xunit; | 9 | using Xunit; |
| @@ -224,20 +225,8 @@ namespace WixToolsetTest.CoreIntegration | |||
| 224 | 225 | ||
| 225 | result.AssertSuccess(); | 226 | result.AssertSuccess(); |
| 226 | 227 | ||
| 227 | CompareLineByLine(expectedFile, decompiledWxsPath); | 228 | WixAssert.CompareXml(expectedFile, decompiledWxsPath); |
| 228 | } | 229 | } |
| 229 | } | 230 | } |
| 230 | |||
| 231 | private static void CompareLineByLine(string expectedFile, string actualFile) | ||
| 232 | { | ||
| 233 | var expectedLines = File.ReadAllLines(expectedFile); | ||
| 234 | var actualLines = File.ReadAllLines(actualFile); | ||
| 235 | for (var i = 0; i < expectedLines.Length; ++i) | ||
| 236 | { | ||
| 237 | Assert.True(actualLines.Length > i, $"{i}: Expected file longer than actual file"); | ||
| 238 | Assert.Equal($"{i}: {expectedLines[i]}", $"{i}: {actualLines[i]}"); | ||
| 239 | } | ||
| 240 | Assert.True(expectedLines.Length == actualLines.Length, "Actual file longer than expected file"); | ||
| 241 | } | ||
| 242 | } | 231 | } |
| 243 | } | 232 | } |
diff --git a/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs b/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs index 9893a525..15082f2b 100644 --- a/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs | |||
| @@ -6,14 +6,14 @@ namespace WixToolsetTest.CoreIntegration | |||
| 6 | using System.Xml.Linq; | 6 | using System.Xml.Linq; |
| 7 | using WixBuildTools.TestSupport; | 7 | using WixBuildTools.TestSupport; |
| 8 | using WixToolset.Core.TestPackage; | 8 | using WixToolset.Core.TestPackage; |
| 9 | using WixToolset.Extensibility.Services; | ||
| 9 | using Xunit; | 10 | using Xunit; |
| 10 | 11 | ||
| 11 | public class DecompileFixture | 12 | public class DecompileFixture |
| 12 | { | 13 | { |
| 13 | [Fact] | 14 | private static void DecompileAndCompare(string sourceFolder, string msiName, string expectedWxsName) |
| 14 | public void CanDecompileSingleFileCompressed() | ||
| 15 | { | 15 | { |
| 16 | var folder = TestData.Get(@"TestData\DecompileSingleFileCompressed"); | 16 | var folder = TestData.Get(sourceFolder); |
| 17 | 17 | ||
| 18 | using (var fs = new DisposableFileSystem()) | 18 | using (var fs = new DisposableFileSystem()) |
| 19 | { | 19 | { |
| @@ -23,75 +23,33 @@ namespace WixToolsetTest.CoreIntegration | |||
| 23 | var result = WixRunner.Execute(new[] | 23 | var result = WixRunner.Execute(new[] |
| 24 | { | 24 | { |
| 25 | "decompile", | 25 | "decompile", |
| 26 | Path.Combine(folder, "example.msi"), | 26 | Path.Combine(folder, msiName), |
| 27 | "-intermediateFolder", intermediateFolder, | 27 | "-intermediateFolder", intermediateFolder, |
| 28 | "-o", outputPath | 28 | "-o", outputPath |
| 29 | }); | 29 | }); |
| 30 | 30 | ||
| 31 | result.AssertSuccess(); | 31 | result.AssertSuccess(); |
| 32 | 32 | ||
| 33 | var actual = File.ReadAllText(outputPath); | 33 | WixAssert.CompareXml(Path.Combine(folder, expectedWxsName), outputPath); |
| 34 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 35 | var expected = XDocument.Load(Path.Combine(folder, "Expected.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 36 | |||
| 37 | Assert.Equal(expected, actualFormatted); | ||
| 38 | } | 34 | } |
| 39 | } | 35 | } |
| 40 | 36 | ||
| 41 | [Fact] | 37 | [Fact] |
| 42 | public void CanDecompile64BitSingleFileCompressed() | 38 | public void CanDecompileSingleFileCompressed() |
| 43 | { | 39 | { |
| 44 | var folder = TestData.Get(@"TestData\DecompileSingleFileCompressed64"); | 40 | DecompileAndCompare(@"TestData\DecompileSingleFileCompressed", "example.msi", "Expected.wxs"); |
| 45 | 41 | } | |
| 46 | using (var fs = new DisposableFileSystem()) | ||
| 47 | { | ||
| 48 | var intermediateFolder = fs.GetFolder(); | ||
| 49 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); | ||
| 50 | |||
| 51 | var result = WixRunner.Execute(new[] | ||
| 52 | { | ||
| 53 | "decompile", | ||
| 54 | Path.Combine(folder, "example.msi"), | ||
| 55 | "-intermediateFolder", intermediateFolder, | ||
| 56 | "-o", outputPath | ||
| 57 | }); | ||
| 58 | |||
| 59 | result.AssertSuccess(); | ||
| 60 | |||
| 61 | var actual = File.ReadAllText(outputPath); | ||
| 62 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 63 | var expected = XDocument.Load(Path.Combine(folder, "Expected.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 64 | 42 | ||
| 65 | Assert.Equal(expected, actualFormatted); | 43 | [Fact] |
| 66 | } | 44 | public void CanDecompile64BitSingleFileCompressed() |
| 45 | { | ||
| 46 | DecompileAndCompare(@"TestData\DecompileSingleFileCompressed64", "example.msi", "Expected.wxs"); | ||
| 67 | } | 47 | } |
| 68 | 48 | ||
| 69 | [Fact] | 49 | [Fact] |
| 70 | public void CanDecompileNestedDirSearchUnderRegSearch() | 50 | public void CanDecompileNestedDirSearchUnderRegSearch() |
| 71 | { | 51 | { |
| 72 | var folder = TestData.Get(@"TestData\AppSearch"); | 52 | DecompileAndCompare(@"TestData\AppSearch", "NestedDirSearchUnderRegSearch.msi", "DecompiledNestedDirSearchUnderRegSearch.wxs"); |
| 73 | |||
| 74 | using (var fs = new DisposableFileSystem()) | ||
| 75 | { | ||
| 76 | var intermediateFolder = fs.GetFolder(); | ||
| 77 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); | ||
| 78 | |||
| 79 | var result = WixRunner.Execute(new[] | ||
| 80 | { | ||
| 81 | "decompile", | ||
| 82 | Path.Combine(folder, "NestedDirSearchUnderRegSearch.msi"), | ||
| 83 | "-intermediateFolder", intermediateFolder, | ||
| 84 | "-o", outputPath | ||
| 85 | }); | ||
| 86 | |||
| 87 | result.AssertSuccess(); | ||
| 88 | |||
| 89 | var actual = File.ReadAllText(outputPath); | ||
| 90 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 91 | var expected = XDocument.Load(Path.Combine(folder, "DecompiledNestedDirSearchUnderRegSearch.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 92 | |||
| 93 | Assert.Equal(expected, actualFormatted); | ||
| 94 | } | ||
| 95 | } | 53 | } |
| 96 | 54 | ||
| 97 | [Fact] | 55 | [Fact] |
| @@ -100,85 +58,19 @@ namespace WixToolsetTest.CoreIntegration | |||
| 100 | // The input MSI was not created using standard methods, it is an example of a real world database that needs to be decompiled. | 58 | // The input MSI was not created using standard methods, it is an example of a real world database that needs to be decompiled. |
| 101 | // The Class/@Feature_ column has length of 32, the File/@Attributes has length of 2, | 59 | // The Class/@Feature_ column has length of 32, the File/@Attributes has length of 2, |
| 102 | // and numerous foreign key relationships are missing. | 60 | // and numerous foreign key relationships are missing. |
| 103 | var folder = TestData.Get(@"TestData\Class"); | 61 | DecompileAndCompare(@"TestData\Class", "OldClassTableDef.msi", "DecompiledOldClassTableDef.wxs"); |
| 104 | |||
| 105 | using (var fs = new DisposableFileSystem()) | ||
| 106 | { | ||
| 107 | var intermediateFolder = fs.GetFolder(); | ||
| 108 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); | ||
| 109 | |||
| 110 | var result = WixRunner.Execute(new[] | ||
| 111 | { | ||
| 112 | "decompile", | ||
| 113 | Path.Combine(folder, "OldClassTableDef.msi"), | ||
| 114 | "-intermediateFolder", intermediateFolder, | ||
| 115 | "-o", outputPath | ||
| 116 | }); | ||
| 117 | |||
| 118 | result.AssertSuccess(); | ||
| 119 | |||
| 120 | var actual = File.ReadAllText(outputPath); | ||
| 121 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 122 | var expected = XDocument.Load(Path.Combine(folder, "DecompiledOldClassTableDef.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 123 | |||
| 124 | Assert.Equal(expected, actualFormatted); | ||
| 125 | } | ||
| 126 | } | 62 | } |
| 127 | 63 | ||
| 128 | [Fact] | 64 | [Fact] |
| 129 | public void CanDecompileSequenceTables() | 65 | public void CanDecompileSequenceTables() |
| 130 | { | 66 | { |
| 131 | var folder = TestData.Get(@"TestData\SequenceTables"); | 67 | DecompileAndCompare(@"TestData\SequenceTables", "SequenceTables.msi", "DecompiledSequenceTables.wxs"); |
| 132 | |||
| 133 | using (var fs = new DisposableFileSystem()) | ||
| 134 | { | ||
| 135 | var intermediateFolder = fs.GetFolder(); | ||
| 136 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); | ||
| 137 | |||
| 138 | var result = WixRunner.Execute(new[] | ||
| 139 | { | ||
| 140 | "decompile", | ||
| 141 | Path.Combine(folder, "SequenceTables.msi"), | ||
| 142 | "-intermediateFolder", intermediateFolder, | ||
| 143 | "-o", outputPath | ||
| 144 | }); | ||
| 145 | |||
| 146 | result.AssertSuccess(); | ||
| 147 | |||
| 148 | var actual = File.ReadAllText(outputPath); | ||
| 149 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 150 | var expected = XDocument.Load(Path.Combine(folder, "DecompiledSequenceTables.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 151 | |||
| 152 | Assert.Equal(expected, actualFormatted); | ||
| 153 | } | ||
| 154 | } | 68 | } |
| 155 | 69 | ||
| 156 | [Fact] | 70 | [Fact] |
| 157 | public void CanDecompileShortcuts() | 71 | public void CanDecompileShortcuts() |
| 158 | { | 72 | { |
| 159 | var folder = TestData.Get(@"TestData\Shortcut"); | 73 | DecompileAndCompare(@"TestData\Shortcut", "shortcuts.msi", "DecompiledShortcuts.wxs"); |
| 160 | |||
| 161 | using (var fs = new DisposableFileSystem()) | ||
| 162 | { | ||
| 163 | var intermediateFolder = fs.GetFolder(); | ||
| 164 | var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); | ||
| 165 | |||
| 166 | var result = WixRunner.Execute(new[] | ||
| 167 | { | ||
| 168 | "decompile", | ||
| 169 | Path.Combine(folder, "shortcuts.msi"), | ||
| 170 | "-intermediateFolder", intermediateFolder, | ||
| 171 | "-o", outputPath | ||
| 172 | }); | ||
| 173 | |||
| 174 | result.AssertSuccess(); | ||
| 175 | |||
| 176 | var actual = File.ReadAllText(outputPath); | ||
| 177 | var actualFormatted = XDocument.Parse(actual, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 178 | var expected = XDocument.Load(Path.Combine(folder, "DecompiledShortcuts.wxs"), LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo).ToString(); | ||
| 179 | |||
| 180 | Assert.Equal(expected, actualFormatted); | ||
| 181 | } | ||
| 182 | } | 74 | } |
| 183 | } | 75 | } |
| 184 | } | 76 | } |
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/CustomTable/CustomTable-Expected.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/CustomTable/CustomTable-Expected.wxs index c55f4ed0..22036ae5 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/CustomTable/CustomTable-Expected.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/CustomTable/CustomTable-Expected.wxs | |||
| @@ -6,12 +6,12 @@ | |||
| 6 | <Column Id="Column1" PrimaryKey="yes" Type="string" Width="0" Category="text" Description="The first custom column." /> | 6 | <Column Id="Column1" PrimaryKey="yes" Type="string" Width="0" Category="text" Description="The first custom column." /> |
| 7 | <Column Id="Component_" Type="string" Width="72" KeyTable="Component" KeyColumn="1" Description="The custom table's Component reference" /> | 7 | <Column Id="Component_" Type="string" Width="72" KeyTable="Component" KeyColumn="1" Description="The custom table's Component reference" /> |
| 8 | <Row> | 8 | <Row> |
| 9 | <Data Column="Column1">Row1</Data> | 9 | <Data Column="Column1" Value="Row1" /> |
| 10 | <Data Column="Component_">test.txt</Data> | 10 | <Data Column="Component_" Value="test.txt" /> |
| 11 | </Row> | 11 | </Row> |
| 12 | <Row> | 12 | <Row> |
| 13 | <Data Column="Column1">Row2</Data> | 13 | <Data Column="Column1" Value="Row2" /> |
| 14 | <Data Column="Component_">test.txt</Data> | 14 | <Data Column="Component_" Value="test.txt" /> |
| 15 | </Row> | 15 | </Row> |
| 16 | </CustomTable> | 16 | </CustomTable> |
| 17 | <Directory Id="TARGETDIR" Name="SourceDir"> | 17 | <Directory Id="TARGETDIR" Name="SourceDir"> |
