From aa33b92c7a2e6b699a11532056485143b0edf4a3 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Thu, 27 Sep 2018 20:10:30 -0400 Subject: Report preprocessor exceptions as errors. Fixes wixtoolset/issues#5881. --- .../PreprocessorFixture.cs | 26 ++++++++++++++++++++++ .../TestData/BadIf/Package.en-us.wxl | 11 +++++++++ .../TestData/BadIf/Package.wxs | 26 ++++++++++++++++++++++ .../TestData/BadIf/PackageComponents.wxs | 12 ++++++++++ .../TestData/BadIf/data/test.txt | 1 + .../WixToolsetTest.CoreIntegration.csproj | 4 ++++ 6 files changed, 80 insertions(+) create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/data/test.txt (limited to 'src/test') diff --git a/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs index 9c60c902..ebc713ed 100644 --- a/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs @@ -63,6 +63,32 @@ namespace WixToolsetTest.CoreIntegration Assert.Equal(0, result); } } + + [Fact] + public void NonterminatedPreprocessorInstructionShowsSourceLineNumber() + { + var folder = TestData.Get(@"TestData\BadIf"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "Package.wxs"), + Path.Combine(folder, "PackageComponents.wxs"), + "-loc", Path.Combine(folder, "Package.en-us.wxl"), + "-bindpath", Path.Combine(folder, "data"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(baseFolder, @"bin\test.msi") + }, out var messages); + + Assert.Equal(147, result); + Assert.StartsWith("Found a ", messages.Single().ToString()); + } + } } } diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.wxs new file mode 100644 index 00000000..73577ce5 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/Package.wxs @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/PackageComponents.wxs new file mode 100644 index 00000000..2a75e3d7 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/PackageComponents.wxs @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/data/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/data/test.txt new file mode 100644 index 00000000..cd0db0e1 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BadIf/data/test.txt @@ -0,0 +1 @@ +This is test.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj index 7c4578d9..38b7dc81 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj +++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj @@ -28,6 +28,10 @@ + + + + -- cgit v1.2.3-55-g6feb