From b673734cce44dd28c1d4d1810da3069324466166 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 2 Jan 2021 19:00:16 -0600 Subject: Implement command line for SuppressAllWarnings and WarningsAsError. Make WixRunner.Execute default to setting WarningsAsError to make sure tests are not accidentally causing warnings. --- .../LinkerFixture.cs | 1 + .../WixToolsetTest.CoreIntegration/MsiFixture.cs | 1 + .../MsiQueryFixture.cs | 1 + .../MsiTransactionFixture.cs | 2 + .../PayloadFixture.cs | 2 +- .../PreprocessorFixture.cs | 2 +- .../WarningFixture.cs | 63 ++++++++++++++++++++++ 7 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 src/test/WixToolsetTest.CoreIntegration/WarningFixture.cs (limited to 'src/test') diff --git a/src/test/WixToolsetTest.CoreIntegration/LinkerFixture.cs b/src/test/WixToolsetTest.CoreIntegration/LinkerFixture.cs index 5e08ca58..d85eb3bf 100644 --- a/src/test/WixToolsetTest.CoreIntegration/LinkerFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/LinkerFixture.cs @@ -55,6 +55,7 @@ namespace WixToolsetTest.CoreIntegration var result = WixRunner.Execute(new[] { "build", + "-sw1008", // this is expected for this test Path.Combine(folder, "Package.wxs"), Path.Combine(folder, "PackageComponents.wxs"), "-loc", Path.Combine(folder, "Package.en-us.wxl"), diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs index 740d58c7..e26e197f 100644 --- a/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/MsiFixture.cs @@ -162,6 +162,7 @@ namespace WixToolsetTest.CoreIntegration var result = WixRunner.Execute(new[] { "build", + "-sw1079", // TODO: why does this test need to create a second cab which is empty? Path.Combine(folder, "Package.wxs"), Path.Combine(folder, "PackageComponents.wxs"), "-loc", Path.Combine(folder, "Package.en-us.wxl"), diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs index 11b1703c..b71b62cb 100644 --- a/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs @@ -357,6 +357,7 @@ namespace WixToolsetTest.CoreIntegration var result = WixRunner.Execute(new[] { "build", + "-sw1031", // this is expected for this test Path.Combine(folder, "DefaultDir", "DefaultDir.wxs"), Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), "-bindpath", Path.Combine(folder, "SingleFile", "data"), diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiTransactionFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiTransactionFixture.cs index 5a29eb9e..7ec0ea93 100644 --- a/src/test/WixToolsetTest.CoreIntegration/MsiTransactionFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/MsiTransactionFixture.cs @@ -26,6 +26,7 @@ namespace WixToolsetTest.CoreIntegration var result = WixRunner.Execute(new[] { "build", + "-sw1151", // this is expected for this test Path.Combine(folder, "MsiTransaction", "X64AfterX86Bundle.wxs"), Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), @@ -55,6 +56,7 @@ namespace WixToolsetTest.CoreIntegration var result = WixRunner.Execute(new[] { "build", + "-sw1151", // this is expected for this test Path.Combine(folder, "MsiTransaction", "X86AfterX64Bundle.wxs"), Path.Combine(folder, "BundleWithPackageGroupRef", "Bundle.wxs"), "-bindpath", Path.Combine(folder, "SimpleBundle", "data"), diff --git a/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs index 4a9344b9..4fc57c76 100644 --- a/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/PayloadFixture.cs @@ -61,7 +61,7 @@ namespace WixToolsetTest.CoreIntegration var intermediateFolder = Path.Combine(baseFolder, "obj"); var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); - var result = WixRunner.Execute(new[] + var result = WixRunner.Execute(warningsAsErrors: false, new[] { "build", Path.Combine(folder, "CanonicalizeName.wxs"), diff --git a/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs index e18990d3..a6504cb9 100644 --- a/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/PreprocessorFixture.cs @@ -49,7 +49,7 @@ namespace WixToolsetTest.CoreIntegration var baseFolder = fs.GetFolder(); var intermediateFolder = Path.Combine(baseFolder, "obj"); - var result = WixRunner.Execute(new[] + var result = WixRunner.Execute(warningsAsErrors: false, new[] { "build", Path.Combine(folder, "Package.wxs"), diff --git a/src/test/WixToolsetTest.CoreIntegration/WarningFixture.cs b/src/test/WixToolsetTest.CoreIntegration/WarningFixture.cs new file mode 100644 index 00000000..c5b6c261 --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/WarningFixture.cs @@ -0,0 +1,63 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.CoreIntegration +{ + using System.IO; + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.Data; + using Xunit; + + public class WarningFixture + { + [Fact] + public void SuppressedWarningsWithWarningAsErrorsAreNotErrors() + { + var folder = TestData.Get(@"TestData\Payload"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); + + var result = WixRunner.Execute(warningsAsErrors: true, new[] + { + "build", + "-sw1152", + Path.Combine(folder, "CanonicalizeName.wxs"), + "-intermediateFolder", intermediateFolder, + "-o", wixlibPath, + }); + + result.AssertSuccess(); + } + } + + [Fact] + public void WarningsAsErrorsTreatsWarningsAsErrors() + { + var folder = TestData.Get(@"TestData\Payload"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var wixlibPath = Path.Combine(intermediateFolder, @"test.wixlib"); + + var result = WixRunner.Execute(warningsAsErrors: true, new[] + { + "build", + Path.Combine(folder, "CanonicalizeName.wxs"), + "-intermediateFolder", intermediateFolder, + "-o", wixlibPath, + }); + + Assert.Equal((int)WarningMessages.Ids.PathCanonicalized, result.ExitCode); + + var message = Assert.Single(result.Messages); + Assert.Equal(MessageLevel.Warning, message.Level); // TODO: is this right? + } + } + } +} -- cgit v1.2.3-55-g6feb