diff options
| author | Rob Mensching <rob@firegiant.com> | 2019-05-23 15:35:48 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2019-05-23 16:07:04 -0700 |
| commit | 5812c6c4b9d40e9ae2b5234a778ecf5aeb8423ff (patch) | |
| tree | ea6fae3959e205b5c261ae7d7fc1f83b981d5e63 /src/test | |
| parent | b645ddc2c1386c1199ca1e7790201d7a5ab6627b (diff) | |
| download | wix-5812c6c4b9d40e9ae2b5234a778ecf5aeb8423ff.tar.gz wix-5812c6c4b9d40e9ae2b5234a778ecf5aeb8423ff.tar.bz2 wix-5812c6c4b9d40e9ae2b5234a778ecf5aeb8423ff.zip | |
Integrate latest Data changes for FileTuple and AssemblyTuple
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/WixToolsetTest.Converters.Tupleizer/ConvertTuplesFixture.cs | 94 |
1 files changed, 70 insertions, 24 deletions
diff --git a/src/test/WixToolsetTest.Converters.Tupleizer/ConvertTuplesFixture.cs b/src/test/WixToolsetTest.Converters.Tupleizer/ConvertTuplesFixture.cs index 9b1fa4cf..14ebd70a 100644 --- a/src/test/WixToolsetTest.Converters.Tupleizer/ConvertTuplesFixture.cs +++ b/src/test/WixToolsetTest.Converters.Tupleizer/ConvertTuplesFixture.cs | |||
| @@ -56,8 +56,11 @@ namespace WixToolsetTest.Converters.Tupleizer | |||
| 56 | .ToArray(); | 56 | .ToArray(); |
| 57 | 57 | ||
| 58 | var tuples = intermediate.Sections.SelectMany(s => s.Tuples); | 58 | var tuples = intermediate.Sections.SelectMany(s => s.Tuples); |
| 59 | |||
| 60 | var assemblyTuplesByFileId = tuples.OfType<AssemblyTuple>().ToDictionary(a => a.Id.Id); | ||
| 61 | |||
| 59 | var wix4Dump = tuples | 62 | var wix4Dump = tuples |
| 60 | .SelectMany(tuple => TupleToStrings(tuple)) | 63 | .SelectMany(tuple => TupleToStrings(tuple, assemblyTuplesByFileId)) |
| 61 | .OrderBy(s => s) | 64 | .OrderBy(s => s) |
| 62 | .ToArray(); | 65 | .ToArray(); |
| 63 | 66 | ||
| @@ -67,8 +70,11 @@ namespace WixToolsetTest.Converters.Tupleizer | |||
| 67 | var wix3TextDump = String.Join(Environment.NewLine, wix3Dump); | 70 | var wix3TextDump = String.Join(Environment.NewLine, wix3Dump); |
| 68 | var wix4TextDump = String.Join(Environment.NewLine, wix4Dump); | 71 | var wix4TextDump = String.Join(Environment.NewLine, wix4Dump); |
| 69 | 72 | ||
| 70 | File.WriteAllText(Path.Combine(Path.GetTempPath(), "~3.txt"), wix3TextDump); | 73 | var path3 = Path.Combine(Path.GetTempPath(), "~3.txt"); |
| 71 | File.WriteAllText(Path.Combine(Path.GetTempPath(), "~4.txt"), wix4TextDump); | 74 | var path4 = Path.Combine(Path.GetTempPath(), "~4.txt"); |
| 75 | |||
| 76 | File.WriteAllText(path3, wix3TextDump); | ||
| 77 | File.WriteAllText(path4, wix4TextDump); | ||
| 72 | 78 | ||
| 73 | Assert.Equal(wix3TextDump, wix4TextDump); | 79 | Assert.Equal(wix3TextDump, wix4TextDump); |
| 74 | #endif | 80 | #endif |
| @@ -143,13 +149,19 @@ namespace WixToolsetTest.Converters.Tupleizer | |||
| 143 | break; | 149 | break; |
| 144 | case "WixFile": | 150 | case "WixFile": |
| 145 | { | 151 | { |
| 146 | var fieldValues = row.Fields.Take(10).Select(SafeConvertField).ToArray(); | 152 | var fieldValues = row.Fields.Select(SafeConvertField).ToArray(); |
| 147 | if (fieldValues[8] == null) | 153 | if (fieldValues[8] == null) |
| 148 | { | 154 | { |
| 149 | // "Somebody" sometimes writes out a null field even when the column definition says | 155 | // "Somebody" sometimes writes out a null field even when the column definition says |
| 150 | // it's non-nullable. Not naming names or anything. (SWID tags.) | 156 | // it's non-nullable. Not naming names or anything. (SWID tags.) |
| 151 | fieldValues[8] = "0"; | 157 | fieldValues[8] = "0"; |
| 152 | } | 158 | } |
| 159 | if (fieldValues[10] == null) | ||
| 160 | { | ||
| 161 | // WixFile rows that come from merge modules will not have the attributes column set | ||
| 162 | // so initilaize with 0. | ||
| 163 | fieldValues[10] = "0"; | ||
| 164 | } | ||
| 153 | fields = String.Join(",", fieldValues); | 165 | fields = String.Join(",", fieldValues); |
| 154 | break; | 166 | break; |
| 155 | } | 167 | } |
| @@ -166,8 +178,11 @@ namespace WixToolsetTest.Converters.Tupleizer | |||
| 166 | } | 178 | } |
| 167 | } | 179 | } |
| 168 | 180 | ||
| 169 | private static IEnumerable<string> TupleToStrings(IntermediateTuple tuple) | 181 | private static IEnumerable<string> TupleToStrings(IntermediateTuple tuple, Dictionary<string, AssemblyTuple> assemblyTuplesByFileId) |
| 170 | { | 182 | { |
| 183 | var name = tuple.Definition.Type == TupleDefinitionType.SummaryInformation ? "_SummaryInformation" : tuple.Definition.Name; | ||
| 184 | var id = tuple.Id?.Id ?? String.Empty; | ||
| 185 | |||
| 171 | string fields; | 186 | string fields; |
| 172 | switch (tuple.Definition.Name) | 187 | switch (tuple.Definition.Name) |
| 173 | { | 188 | { |
| @@ -280,20 +295,53 @@ namespace WixToolsetTest.Converters.Tupleizer | |||
| 280 | yield return $"SelfReg:{fileTuple.Id.Id},{fileTuple.SelfRegCost}"; | 295 | yield return $"SelfReg:{fileTuple.Id.Id},{fileTuple.SelfRegCost}"; |
| 281 | } | 296 | } |
| 282 | 297 | ||
| 298 | int? assemblyAttributes = null; | ||
| 299 | if (assemblyTuplesByFileId.TryGetValue(fileTuple.Id.Id, out var assemblyTuple)) | ||
| 300 | { | ||
| 301 | if (assemblyTuple.Type == AssemblyType.DotNetAssembly) | ||
| 302 | { | ||
| 303 | assemblyAttributes = 0; | ||
| 304 | } | ||
| 305 | else if (assemblyTuple.Type == AssemblyType.Win32Assembly) | ||
| 306 | { | ||
| 307 | assemblyAttributes = 1; | ||
| 308 | } | ||
| 309 | } | ||
| 310 | |||
| 311 | yield return "WixFile:" + String.Join(",", | ||
| 312 | fileTuple.Id.Id, | ||
| 313 | assemblyAttributes, | ||
| 314 | assemblyTuple?.ManifestFileRef, | ||
| 315 | assemblyTuple?.ApplicationFileRef, | ||
| 316 | fileTuple.DirectoryRef, | ||
| 317 | fileTuple.DiskId, | ||
| 318 | fileTuple.Source.Path, | ||
| 319 | null, // assembly processor arch | ||
| 320 | fileTuple.PatchGroup, | ||
| 321 | (fileTuple.Attributes & FileTupleAttributes.GeneratedShortFileName) != 0 ? 1 : 0, | ||
| 322 | (int)fileTuple.PatchAttributes, | ||
| 323 | fileTuple.RetainLengths, | ||
| 324 | fileTuple.IgnoreOffsets, | ||
| 325 | fileTuple.IgnoreLengths, | ||
| 326 | fileTuple.RetainOffsets | ||
| 327 | ); | ||
| 328 | |||
| 329 | var fileAttributes = 0; | ||
| 330 | fileAttributes |= (fileTuple.Attributes & FileTupleAttributes.ReadOnly) != 0 ? WindowsInstallerConstants.MsidbFileAttributesReadOnly : 0; | ||
| 331 | fileAttributes |= (fileTuple.Attributes & FileTupleAttributes.Hidden) != 0 ? WindowsInstallerConstants.MsidbFileAttributesHidden : 0; | ||
| 332 | fileAttributes |= (fileTuple.Attributes & FileTupleAttributes.System) != 0 ? WindowsInstallerConstants.MsidbFileAttributesSystem : 0; | ||
| 333 | fileAttributes |= (fileTuple.Attributes & FileTupleAttributes.Vital) != 0 ? WindowsInstallerConstants.MsidbFileAttributesVital : 0; | ||
| 334 | fileAttributes |= (fileTuple.Attributes & FileTupleAttributes.Checksum) != 0 ? WindowsInstallerConstants.MsidbFileAttributesChecksum : 0; | ||
| 335 | fileAttributes |= (fileTuple.Attributes & FileTupleAttributes.Compressed) != 0 ? WindowsInstallerConstants.MsidbFileAttributesCompressed : 0; | ||
| 336 | fileAttributes |= (fileTuple.Attributes & FileTupleAttributes.Uncompressed) != 0 ? WindowsInstallerConstants.MsidbFileAttributesNoncompressed : 0; | ||
| 337 | |||
| 283 | fields = String.Join(",", | 338 | fields = String.Join(",", |
| 284 | fileTuple.ComponentRef, | 339 | fileTuple.ComponentRef, |
| 285 | fileTuple.Name, | 340 | fileTuple.Name, |
| 286 | fileTuple.FileSize.ToString(), | 341 | fileTuple.FileSize.ToString(), |
| 287 | fileTuple.Version, | 342 | fileTuple.Version, |
| 288 | fileTuple.Language, | 343 | fileTuple.Language, |
| 289 | ((fileTuple.ReadOnly ? WindowsInstallerConstants.MsidbFileAttributesReadOnly : 0) | 344 | fileAttributes); |
| 290 | | (fileTuple.Hidden ? WindowsInstallerConstants.MsidbFileAttributesHidden : 0) | ||
| 291 | | (fileTuple.System ? WindowsInstallerConstants.MsidbFileAttributesSystem : 0) | ||
| 292 | | (fileTuple.Vital ? WindowsInstallerConstants.MsidbFileAttributesVital : 0) | ||
| 293 | | (fileTuple.Checksum ? WindowsInstallerConstants.MsidbFileAttributesChecksum : 0) | ||
| 294 | | ((fileTuple.Compressed.HasValue && fileTuple.Compressed.Value) ? WindowsInstallerConstants.MsidbFileAttributesCompressed : 0) | ||
| 295 | | ((fileTuple.Compressed.HasValue && !fileTuple.Compressed.Value) ? WindowsInstallerConstants.MsidbFileAttributesNoncompressed : 0)) | ||
| 296 | .ToString()); | ||
| 297 | break; | 345 | break; |
| 298 | } | 346 | } |
| 299 | 347 | ||
| @@ -301,6 +349,15 @@ namespace WixToolsetTest.Converters.Tupleizer | |||
| 301 | fields = String.Join(",", tuple.Fields.Skip(1).Select(SafeConvertField)); | 349 | fields = String.Join(",", tuple.Fields.Skip(1).Select(SafeConvertField)); |
| 302 | break; | 350 | break; |
| 303 | 351 | ||
| 352 | case "Assembly": | ||
| 353 | { | ||
| 354 | var assemblyTuple = (AssemblyTuple)tuple; | ||
| 355 | |||
| 356 | id = null; | ||
| 357 | name = "MsiAssembly"; | ||
| 358 | fields = String.Join(",", assemblyTuple.ComponentRef, assemblyTuple.FeatureRef, assemblyTuple.ManifestFileRef, assemblyTuple.ApplicationFileRef, assemblyTuple.Type == AssemblyType.Win32Assembly ? 1 : 0); | ||
| 359 | break; | ||
| 360 | } | ||
| 304 | case "Registry": | 361 | case "Registry": |
| 305 | { | 362 | { |
| 306 | var registryTuple = (RegistryTuple)tuple; | 363 | var registryTuple = (RegistryTuple)tuple; |
| @@ -468,15 +525,6 @@ namespace WixToolsetTest.Converters.Tupleizer | |||
| 468 | break; | 525 | break; |
| 469 | } | 526 | } |
| 470 | 527 | ||
| 471 | case "WixFile": | ||
| 472 | { | ||
| 473 | var wixFileTuple = (WixFileTuple)tuple; | ||
| 474 | fields = String.Concat( | ||
| 475 | wixFileTuple.AssemblyType == FileAssemblyType.DotNetAssembly ? "0" : wixFileTuple.AssemblyType == FileAssemblyType.Win32Assembly ? "1" : String.Empty, ",", | ||
| 476 | String.Join(",", tuple.Fields.Skip(1).Take(8).Select(field => (string)field))); | ||
| 477 | break; | ||
| 478 | } | ||
| 479 | |||
| 480 | case "WixProperty": | 528 | case "WixProperty": |
| 481 | { | 529 | { |
| 482 | var wixPropertyTuple = (WixPropertyTuple)tuple; | 530 | var wixPropertyTuple = (WixPropertyTuple)tuple; |
| @@ -496,8 +544,6 @@ namespace WixToolsetTest.Converters.Tupleizer | |||
| 496 | break; | 544 | break; |
| 497 | } | 545 | } |
| 498 | 546 | ||
| 499 | var name = tuple.Definition.Type == TupleDefinitionType.SummaryInformation ? "_SummaryInformation" : tuple.Definition.Name; | ||
| 500 | var id = tuple.Id?.Id ?? String.Empty; | ||
| 501 | fields = String.IsNullOrEmpty(id) ? fields : String.IsNullOrEmpty(fields) ? id : $"{id},{fields}"; | 547 | fields = String.IsNullOrEmpty(id) ? fields : String.IsNullOrEmpty(fields) ? id : $"{id},{fields}"; |
| 502 | yield return $"{name}:{fields}"; | 548 | yield return $"{name}:{fields}"; |
| 503 | } | 549 | } |
