aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-01-02 20:05:54 -0600
committerSean Hall <r.sean.hall@gmail.com>2021-01-03 15:49:32 -0600
commitdf40c2722e4a41e01cf326353e2583ae82ccc9a4 (patch)
tree277e64d517a33a2eeaf4fd94ee457c3d48c2d49a
parentb673734cce44dd28c1d4d1810da3069324466166 (diff)
downloadwix-df40c2722e4a41e01cf326353e2583ae82ccc9a4.tar.gz
wix-df40c2722e4a41e01cf326353e2583ae82ccc9a4.tar.bz2
wix-df40c2722e4a41e01cf326353e2583ae82ccc9a4.zip
Fix TryGetNextNonSwitchArgumentOrError.
-rw-r--r--src/WixToolset.Core/CommandLine/BuildCommand.cs2
-rw-r--r--src/WixToolset.Core/CommandLine/CommandLineParser.cs3
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs44
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs29
4 files changed, 47 insertions, 31 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs
index 072accc3..fed95958 100644
--- a/src/WixToolset.Core/CommandLine/BuildCommand.cs
+++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs
@@ -578,7 +578,7 @@ namespace WixToolset.Core.CommandLine
578 case "bindpath": 578 case "bindpath":
579 { 579 {
580 var value = parser.GetNextArgumentOrError(arg); 580 var value = parser.GetNextArgumentOrError(arg);
581 if (this.TryParseBindPath(value, out var bindPath)) 581 if (value != null && this.TryParseBindPath(value, out var bindPath))
582 { 582 {
583 this.BindPaths.Add(bindPath); 583 this.BindPaths.Add(bindPath);
584 return true; 584 return true;
diff --git a/src/WixToolset.Core/CommandLine/CommandLineParser.cs b/src/WixToolset.Core/CommandLine/CommandLineParser.cs
index 1438d820..e78da47e 100644
--- a/src/WixToolset.Core/CommandLine/CommandLineParser.cs
+++ b/src/WixToolset.Core/CommandLine/CommandLineParser.cs
@@ -138,9 +138,10 @@ namespace WixToolset.Core.CommandLine
138 { 138 {
139 var result = this.TryGetNextSwitchOrArgument(out arg); 139 var result = this.TryGetNextSwitchOrArgument(out arg);
140 140
141 if (!result && !this.IsSwitch(arg)) 141 if (!result || this.IsSwitch(arg))
142 { 142 {
143 this.ErrorArgument = arg ?? CommandLineParser.ExpectedArgument; 143 this.ErrorArgument = arg ?? CommandLineParser.ExpectedArgument;
144 return false;
144 } 145 }
145 146
146 return result; 147 return result;
diff --git a/src/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs
index 02422cf7..874151e4 100644
--- a/src/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs
+++ b/src/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs
@@ -6,11 +6,55 @@ namespace WixToolsetTest.CoreIntegration
6 using System.IO; 6 using System.IO;
7 using WixBuildTools.TestSupport; 7 using WixBuildTools.TestSupport;
8 using WixToolset.Core.TestPackage; 8 using WixToolset.Core.TestPackage;
9 using WixToolset.Data;
9 using Xunit; 10 using Xunit;
10 11
11 public class BadInputFixture 12 public class BadInputFixture
12 { 13 {
13 [Fact] 14 [Fact]
15 public void SwitchIsNotConsideredAnArgument()
16 {
17 var result = WixRunner.Execute(new[]
18 {
19 "build",
20 "-bindpath", "-thisisaswitchnotanarg",
21 });
22
23 Assert.Single(result.Messages, m => m.Id == (int)ErrorMessages.Ids.ExpectedArgument);
24 // TODO: when CantBuildSingleExeBundleWithInvalidArgument is fixed, uncomment:
25 //Assert.Equal((int)ErrorMessages.Ids.ExpectedArgument, result.ExitCode);
26 }
27
28 [Fact(Skip = "Test demonstrates failure")]
29 public void CantBuildSingleExeBundleWithInvalidArgument()
30 {
31 var folder = TestData.Get(@"TestData");
32
33 using (var fs = new DisposableFileSystem())
34 {
35 var baseFolder = fs.GetFolder();
36 var intermediateFolder = Path.Combine(baseFolder, "obj");
37 var exePath = Path.Combine(baseFolder, @"bin\test.exe");
38
39 var result = WixRunner.Execute(new[]
40 {
41 "build",
42 Path.Combine(folder, "SingleExeBundle", "SingleExePackageGroup.wxs"),
43 Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"),
44 "-bindpath", Path.Combine(folder, "SimpleBundle", "data"),
45 "-bindpath", Path.Combine(folder, ".Data"),
46 "-intermediateFolder", intermediateFolder,
47 "-o", exePath,
48 "-nonexistentswitch", "param",
49 });
50
51 Assert.NotEqual(0, result.ExitCode);
52
53 Assert.False(File.Exists(exePath));
54 }
55 }
56
57 [Fact]
14 public void RegistryKeyWithoutAttributesDoesntCrash() 58 public void RegistryKeyWithoutAttributesDoesntCrash()
15 { 59 {
16 var folder = TestData.Get(@"TestData\BadInput"); 60 var folder = TestData.Get(@"TestData\BadInput");
diff --git a/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
index 1e3f1e24..fae2ff4c 100644
--- a/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
+++ b/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
@@ -189,35 +189,6 @@ namespace WixToolsetTest.CoreIntegration
189 } 189 }
190 } 190 }
191 191
192 [Fact(Skip = "Test demonstrates failure")]
193 public void CantBuildSingleExeBundleWithInvalidArgument()
194 {
195 var folder = TestData.Get(@"TestData");
196
197 using (var fs = new DisposableFileSystem())
198 {
199 var baseFolder = fs.GetFolder();
200 var intermediateFolder = Path.Combine(baseFolder, "obj");
201 var exePath = Path.Combine(baseFolder, @"bin\test.exe");
202
203 var result = WixRunner.Execute(new[]
204 {
205 "build",
206 Path.Combine(folder, "SingleExeBundle", "SingleExePackageGroup.wxs"),
207 Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"),
208 "-bindpath", Path.Combine(folder, "SimpleBundle", "data"),
209 "-bindpath", Path.Combine(folder, ".Data"),
210 "-intermediateFolder", intermediateFolder,
211 "-o", exePath,
212 "-nonexistentswitch", "param",
213 });
214
215 Assert.NotEqual(0, result.ExitCode);
216
217 Assert.False(File.Exists(exePath));
218 }
219 }
220
221 [Fact] 192 [Fact]
222 public void CanBuildSingleExeRemotePayloadBundle() 193 public void CanBuildSingleExeRemotePayloadBundle()
223 { 194 {