commit d9a5765367eed5d89d9d9267ead7e6e07cb0ab24
parent 96e931e51831c543f4705e95607d59d8c4b79128
Author: Kaleb Luedtke <jluedtk@jci.com>
Date: Wed, 6 Sep 2023 16:38:17 -0500
Add argument for ignoring warnings (#3572)
Diffstat:
8 files changed, 45 insertions(+), 9 deletions(-)
diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt
@@ -355,6 +355,7 @@ normalizedpackagenameandpublisher
NOTHROW
NOTIMPL
NOTNULL
+nowarn
npos
NTFS
NTSTATUS
diff --git a/src/AppInstallerCLICore/Argument.cpp b/src/AppInstallerCLICore/Argument.cpp
@@ -119,6 +119,8 @@ namespace AppInstaller::CLI
//Validate Command
case Execution::Args::Type::ValidateManifest:
return { type, "manifest"_liv };
+ case Execution::Args::Type::IgnoreWarnings:
+ return { type, "ignore-warnings"_liv, "nowarn"_liv};
// Complete Command
case Execution::Args::Type::Word:
@@ -313,6 +315,8 @@ namespace AppInstaller::CLI
return Argument{ type, Resource::String::SourceTypeArgumentDescription, ArgumentType::Positional };
case Args::Type::ValidateManifest:
return Argument{ type, Resource::String::ValidateManifestArgumentDescription, ArgumentType::Positional, true };
+ case Args::Type::IgnoreWarnings:
+ return Argument{ type, Resource::String::IgnoreWarningsArgumentDescription, ArgumentType::Flag, Argument::Visibility::Help };
case Args::Type::NoVT:
return Argument{ type, Resource::String::NoVTArgumentDescription, ArgumentType::Flag, Argument::Visibility::Hidden };
case Args::Type::RainbowStyle:
diff --git a/src/AppInstallerCLICore/Commands/ValidateCommand.cpp b/src/AppInstallerCLICore/Commands/ValidateCommand.cpp
@@ -16,6 +16,7 @@ namespace AppInstaller::CLI
{
return {
Argument::ForType(Execution::Args::Type::ValidateManifest),
+ Argument::ForType(Execution::Args::Type::IgnoreWarnings),
};
}
@@ -46,7 +47,7 @@ namespace AppInstaller::CLI
{
ManifestValidateOption validateOption;
validateOption.FullValidation = true;
- validateOption.ThrowOnWarning = true;
+ validateOption.ThrowOnWarning = !(context.Args.Contains(Execution::Args::Type::IgnoreWarnings));
auto manifest = YamlParser::CreateFromPath(inputFile, validateOption);
context.Add<Execution::Data::Manifest>(manifest);
diff --git a/src/AppInstallerCLICore/ExecutionArgs.h b/src/AppInstallerCLICore/ExecutionArgs.h
@@ -66,6 +66,7 @@ namespace AppInstaller::CLI::Execution
//Validate Command
ValidateManifest,
+ IgnoreWarnings,
// Complete Command
Word,
diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h
@@ -207,6 +207,7 @@ namespace AppInstaller::CLI::Resource
WINGET_DEFINE_RESOURCE_STRINGID(HelpLinkPreamble);
WINGET_DEFINE_RESOURCE_STRINGID(IdArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(IgnoreLocalArchiveMalwareScanArgumentDescription);
+ WINGET_DEFINE_RESOURCE_STRINGID(IgnoreWarningsArgumentDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ImportCommandLongDescription);
WINGET_DEFINE_RESOURCE_STRINGID(ImportCommandReportDependencies);
WINGET_DEFINE_RESOURCE_STRINGID(ImportCommandShortDescription);
diff --git a/src/AppInstallerCLIE2ETests/TestData/Manifests/TestWarningManifest.yaml b/src/AppInstallerCLIE2ETests/TestData/Manifests/TestWarningManifest.yaml
@@ -1,12 +1,14 @@
-Id: TestWarning.Manifest
-Name: TestWarningManifest
-Version: 1.0.0.0
+PackageIdentifier: TestWarning.Manifest
+PackageName: TestWarningManifest
+PackageVersion: 1.0.0.0
+PackageLocale: en-US
Publisher: AppInstallerTest
License: Test
Installers:
- - Arch: x86
- Url: https://localhost:5001/TestKit/AppInstallerTestExeInstaller/AppInstallerTestExeInstaller.exe
- Sha256: <EXEHASH>
+ - Architecture: x86
+ InstallerUrl: https://localhost:5001/TestKit/AppInstallerTestExeInstaller/AppInstallerTestExeInstaller.exe
+ InstallerSha256: 0000000000000000000000000000000000000000000000000000000000000000
InstallerType: exe
- Switches:
-ManifestVersion: 0.1.0
+ShortDescription: This manifest should have only warnings, no errors
+ManifestType: singleton
+ManifestVersion: 1.6.0
diff --git a/src/AppInstallerCLIE2ETests/ValidateCommand.cs b/src/AppInstallerCLIE2ETests/ValidateCommand.cs
@@ -48,6 +48,29 @@ namespace AppInstallerCLIE2ETests
}
/// <summary>
+ /// Test validate manifest with warnings.
+ /// </summary>
+ [Test]
+ public void ValidateManifestWithWarnings()
+ {
+ var result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestWarningManifest.yaml"));
+ Assert.AreEqual(Constants.ErrorCode.ERROR_MANIFEST_VALIDATION_WARNING, result.ExitCode);
+ Assert.True(result.StdOut.Contains("Manifest validation succeeded with warnings."));
+ }
+
+ /// <summary>
+ /// Test validate manifest with warnings suppressed.
+ /// </summary>
+ [Test]
+ public void ValidateManifestSuppressWarnings()
+ {
+ var result = TestCommon.RunAICLICommand("validate", TestCommon.GetTestDataFile("Manifests\\TestWarningManifest.yaml") + " --ignore-warnings");
+ Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
+ Assert.False(result.StdOut.Contains("Manifest validation succeeded with warnings."));
+ Assert.True(result.StdOut.Contains("Manifest validation succeeded."));
+ }
+
+ /// <summary>
/// Test validate manifest that doesn't exist.
/// </summary>
[Test]
diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
@@ -261,6 +261,9 @@ They can be configured through the settings file 'winget settings'.</value>
<data name="IdArgumentDescription" xml:space="preserve">
<value>Filter results by id</value>
</data>
+ <data name="IgnoreWarningsArgumentDescription" xml:space="preserve">
+ <value>Suppresses warning outputs.</value>
+ </data>
<data name="InstallationDisclaimer1" xml:space="preserve">
<value>This application is licensed to you by its owner.</value>
</data>