aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRon Martin <cpuwzd@comcast.net>2021-04-22 18:46:03 -0400
committerBob Arnson <bob@firegiant.com>2021-04-23 17:14:38 -0400
commitb0840f6ad872f7085fd8d62285dc889763a65968 (patch)
treee44bda9a381c22d8dc159a10bfb3bd7023884caf /src
parentb3a60d6117c6ea69044e93c896b4456e9b1a03f0 (diff)
downloadwix-b0840f6ad872f7085fd8d62285dc889763a65968.tar.gz
wix-b0840f6ad872f7085fd8d62285dc889763a65968.tar.bz2
wix-b0840f6ad872f7085fd8d62285dc889763a65968.zip
Detect Inability to write to output file
Fixes wixtoolset/issues#6425
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.Converters/WixConverter.cs20
-rw-r--r--src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs24
2 files changed, 35 insertions, 9 deletions
diff --git a/src/WixToolset.Converters/WixConverter.cs b/src/WixToolset.Converters/WixConverter.cs
index 80784807..6080eeb9 100644
--- a/src/WixToolset.Converters/WixConverter.cs
+++ b/src/WixToolset.Converters/WixConverter.cs
@@ -1848,8 +1848,8 @@ namespace WixToolset.Converters
1848 { 1848 {
1849 // Ignore the error if explicitly ignored or outside the range of the current operation. 1849 // Ignore the error if explicitly ignored or outside the range of the current operation.
1850 if (this.IgnoreErrors.Contains(converterTestType) || 1850 if (this.IgnoreErrors.Contains(converterTestType) ||
1851 (this.Operation == ConvertOperation.Convert && converterTestType < ConverterTestType.DeclarationPresent) || 1851 (this.Operation == ConvertOperation.Convert && converterTestType < ConverterTestType.EndIgnoreInConvert) ||
1852 (this.Operation == ConvertOperation.Format && converterTestType > ConverterTestType.DeclarationPresent)) 1852 (this.Operation == ConvertOperation.Format && converterTestType > ConverterTestType.BeginIgnoreInFormat))
1853 { 1853 {
1854 return false; 1854 return false;
1855 } 1855 }
@@ -2033,11 +2033,6 @@ namespace WixToolset.Converters
2033 XmlException, 2033 XmlException,
2034 2034
2035 /// <summary> 2035 /// <summary>
2036 /// Displayed when a file cannot be accessed; typically when trying to save back a fixed file.
2037 /// </summary>
2038 UnauthorizedAccessException,
2039
2040 /// <summary>
2041 /// Displayed when the whitespace preceding a node is wrong. 2036 /// Displayed when the whitespace preceding a node is wrong.
2042 /// </summary> 2037 /// </summary>
2043 WhitespacePrecedingNodeWrong, 2038 WhitespacePrecedingNodeWrong,
@@ -2047,14 +2042,21 @@ namespace WixToolset.Converters
2047 /// </summary> 2042 /// </summary>
2048 WhitespacePrecedingEndElementWrong, 2043 WhitespacePrecedingEndElementWrong,
2049 2044
2050 // Before this point, ignore errors on convert operation 2045 /// Before this point, ignore errors on convert operation
2046 EndIgnoreInConvert,
2051 2047
2052 /// <summary> 2048 /// <summary>
2053 /// Displayed when the XML declaration is present in the source file. 2049 /// Displayed when the XML declaration is present in the source file.
2054 /// </summary> 2050 /// </summary>
2055 DeclarationPresent, 2051 DeclarationPresent,
2056 2052
2057 // After this point, ignore errors on format operation 2053 /// <summary>
2054 /// Displayed when a file cannot be accessed; typically when trying to save back a fixed file.
2055 /// </summary>
2056 UnauthorizedAccessException,
2057
2058 /// After this point, ignore errors on format operation
2059 BeginIgnoreInFormat,
2058 2060
2059 /// <summary> 2061 /// <summary>
2060 /// Displayed when the xmlns attribute is missing from the document element. 2062 /// Displayed when the xmlns attribute is missing from the document element.
diff --git a/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs b/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs
index cabc89ee..acd7991e 100644
--- a/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs
+++ b/src/test/WixToolsetTest.Converters/ConverterIntegrationFixture.cs
@@ -8,6 +8,7 @@ namespace WixToolsetTest.Converters
8 using WixBuildTools.TestSupport; 8 using WixBuildTools.TestSupport;
9 using WixToolset.Converters; 9 using WixToolset.Converters;
10 using WixToolset.Core; 10 using WixToolset.Core;
11 using WixToolset.Core.ExtensibilityServices;
11 using WixToolset.Core.TestPackage; 12 using WixToolset.Core.TestPackage;
12 using WixToolsetTest.Converters.Mocks; 13 using WixToolsetTest.Converters.Mocks;
13 using Xunit; 14 using Xunit;
@@ -69,6 +70,29 @@ namespace WixToolsetTest.Converters
69 } 70 }
70 71
71 [Fact] 72 [Fact]
73 public void CanDetectReadOnlyOutputFile()
74 {
75 const string beforeFileName = "SingleFile.wxs";
76 var folder = TestData.Get(@"TestData\SingleFile");
77
78 using (var fs = new DisposableFileSystem())
79 {
80 var baseFolder = fs.GetFolder(true);
81 var targetFile = Path.Combine(baseFolder, beforeFileName);
82 File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName));
83
84 var info = new FileInfo(targetFile);
85 info.IsReadOnly = true;
86
87 var messaging = new MockMessaging();
88 var converter = new WixConverter(messaging, 4);
89 var errors = converter.ConvertFile(targetFile, true);
90
91 Assert.Equal(10, errors);
92 }
93 }
94
95 [Fact]
72 public void RetainsPreprocessorInstructions() 96 public void RetainsPreprocessorInstructions()
73 { 97 {
74 const string beforeFileName = "Preprocessor.wxs"; 98 const string beforeFileName = "Preprocessor.wxs";