Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infra changes for Microsoft.WinGet.Client and AppInstallerCLIE2ETests #2746

Merged
merged 5 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ wsv
wto
wwinmain
WZDNCRFJ
xcopy
XFile
XPLATSTR
xsi
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,11 @@ ASALocalRun/
# Generated files from WinGetServer.idl
**/WinGetServer/WinGetServer.h
**/WinGetServer/WinGetServer_c.c
**/WinGetServer/WinGetServer_s.c
**/WinGetServer/WinGetServer_s.c

# Crescendo generated module files
src/PowerShell/Microsoft.WinGet.Client/Crescendo/*.psd1
src/PowerShell/Microsoft.WinGet.Client/Crescendo/*.psm1

# Dev PowerShell module path
src/PowerShell/scripts/Module
14 changes: 4 additions & 10 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ jobs:
TargetFolder: '$(artifactsDir)'
condition: succeededOrFailed()

- task: PowerShell@2
displayName: 'Copy PowerShell Module Binaries to Output'
- task: CopyFiles@2
displayName: 'Copy PowerShell Module Files'
inputs:
filePath: 'src\PowerShell\Microsoft.WinGet.Client\Copy-PlatformBinaries.ps1'
arguments: '-Platform $(buildPlatform) -Configuration $(buildConfiguration) -OutDir $(artifactsDir)\PowerShell'
SourceFolder: '$(buildOutDir)\PowerShell'
TargetFolder: '$(artifactsDir)\PowerShell'
condition: always()

- task: PublishPipelineArtifact@1
Expand Down Expand Up @@ -359,12 +359,6 @@ jobs:
Contents: '**\*'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PowerShell@2
displayName: 'Copy PowerShell Module Files to Output'
inputs:
filePath: 'src\PowerShell\Microsoft.WinGet.Client\Copy-ModuleFiles.ps1'
arguments: '-OutDir $(Build.ArtifactStagingDirectory)'

- task: PublishPipelineArtifact@1
displayName: Publish PowerShell Module Artifacts
inputs:
Expand Down
53 changes: 27 additions & 26 deletions src/AppInstallerCLI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
CodeAnalysis.ruleset = CodeAnalysis.ruleset
nuget.config = nuget.config
stylecop.json = stylecop.json
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Management.Deployment", "Microsoft.Management.Deployment\Microsoft.Management.Deployment.vcxproj", "{1CC41A9A-AE66-459D-9210-1E572DD7BE69}"
Expand Down Expand Up @@ -279,6 +280,32 @@ Global
{1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.TestRelease|x64.Build.0 = Release|x64
{1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.TestRelease|x86.ActiveCfg = Release|Win32
{1C6E0108-2860-4B17-9F7E-FA5C6C1F3D3D}.TestRelease|x86.Build.0 = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|Any CPU.ActiveCfg = Debug|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|ARM.ActiveCfg = Debug|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|ARM64.ActiveCfg = Debug|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|x64.ActiveCfg = Debug|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|x64.Build.0 = Debug|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|x86.ActiveCfg = Debug|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|x86.Build.0 = Debug|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|Any CPU.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|Any CPU.Build.0 = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|ARM.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|ARM64.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|x64.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|x86.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|Any CPU.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|ARM.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|ARM64.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|x64.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|x64.Build.0 = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|x86.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|x86.Build.0 = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|Any CPU.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|Any CPU.Build.0 = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|ARM.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|ARM64.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|x64.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|x86.ActiveCfg = Release|Win32
{5EB88068-5FB9-4E69-89B2-72DBC5E068F9}.Debug|Any CPU.ActiveCfg = Debug|Win32
{5EB88068-5FB9-4E69-89B2-72DBC5E068F9}.Debug|ARM.ActiveCfg = Debug|ARM
{5EB88068-5FB9-4E69-89B2-72DBC5E068F9}.Debug|ARM.Build.0 = Debug|ARM
Expand Down Expand Up @@ -313,32 +340,6 @@ Global
{5EB88068-5FB9-4E69-89B2-72DBC5E068F9}.TestRelease|x64.Build.0 = Release|x64
{5EB88068-5FB9-4E69-89B2-72DBC5E068F9}.TestRelease|x86.ActiveCfg = Release|Win32
{5EB88068-5FB9-4E69-89B2-72DBC5E068F9}.TestRelease|x86.Build.0 = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|Any CPU.ActiveCfg = Debug|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|ARM.ActiveCfg = Debug|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|ARM64.ActiveCfg = Debug|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|x64.ActiveCfg = Debug|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|x64.Build.0 = Debug|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|x86.ActiveCfg = Debug|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Debug|x86.Build.0 = Debug|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|Any CPU.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|Any CPU.Build.0 = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|ARM.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|ARM64.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|x64.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Fuzzing|x86.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|Any CPU.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|ARM.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|ARM64.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|x64.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|x64.Build.0 = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|x86.ActiveCfg = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.Release|x86.Build.0 = Release|Win32
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|Any CPU.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|Any CPU.Build.0 = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|ARM.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|ARM64.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|x64.ActiveCfg = Release|x64
{89B1AAB4-2BBC-4B65-9ED7-A01D5CF88230}.TestRelease|x86.ActiveCfg = Release|Win32
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|Any CPU.ActiveCfg = Debug|Win32
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|ARM.ActiveCfg = Debug|ARM
{8BB94BB8-374F-4294-BCA1-C7811514A6B7}.Debug|ARM.Build.0 = Debug|ARM
Expand Down
17 changes: 17 additions & 0 deletions src/AppInstallerCLIE2ETests/AppInstallerCLIE2ETests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@
<IsPackable>false</IsPackable>
<Platforms>x64;x86</Platforms>
<OutputType>Library</OutputType>
<DocumentationFile>$(OutDir)\AppInstallerCLIE2ETests.xml</DocumentationFile>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<PropertyGroup>
<!-- Disable warning for CS1591 because auto generated Microsoft.Management.Deployment -->
<!-- For our code, we still have stylecops acting on it. -->
<NoWarn>1591</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,6 +28,10 @@
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<!-- CsWinRT properties -->
Expand All @@ -33,6 +49,7 @@
<Content Include="..\..\doc\admx\DesktopAppInstaller.admx" Link="TestData\DesktopAppInstaller.admx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<AdditionalFiles Include="..\stylecop.json" Link="stylecop.json" />
</ItemGroup>

<ItemGroup>
Expand Down
52 changes: 41 additions & 11 deletions src/AppInstallerCLIE2ETests/BaseCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// -----------------------------------------------------------------------------
// <copyright file="BaseCommand.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
// -----------------------------------------------------------------------------

namespace AppInstallerCLIE2ETests
{
Expand All @@ -8,27 +11,45 @@ namespace AppInstallerCLIE2ETests
using Newtonsoft.Json.Linq;
using NUnit.Framework;

/// <summary>
/// Base command.
/// </summary>
public class BaseCommand
{
/// <summary>
/// Set up.
/// </summary>
[OneTimeSetUp]
public void BaseSetup()
{
ResetTestSource();
this.ResetTestSource();
}

/// <summary>
/// Tear down.
/// </summary>
[OneTimeTearDown]
public void BaseTeardown()
{
TestCommon.TearDownTestSource();
}

// TODO: If/when cert pinning is implemented on the packaged index source, useGroupPolicyForTestSource should be set to default true
// to enable testing it by default. Until then, leaving this here...
/// <summary>
/// Reset test source.
/// </summary>
/// <param name="useGroupPolicyForTestSource">Use group policy from test source.</param>
public void ResetTestSource(bool useGroupPolicyForTestSource = false)
{
// TODO: If/when cert pinning is implemented on the packaged index source, useGroupPolicyForTestSource should be set to default true
// to enable testing it by default. Until then, leaving this here...
TestCommon.SetupTestSource(useGroupPolicyForTestSource);
}

/// <summary>
/// Configure experimental features.
/// </summary>
/// <param name="featureName">Feature name.</param>
/// <param name="status">Status.</param>
public void ConfigureFeature(string featureName, bool status)
{
string localAppDataPath = Environment.GetEnvironmentVariable(Constants.LocalAppData);
Expand All @@ -39,6 +60,11 @@ public void ConfigureFeature(string featureName, bool status)
File.WriteAllText(Path.Combine(localAppDataPath, TestCommon.SettingsJsonFilePath), settingsJson.ToString());
}

/// <summary>
/// Configure the install behavior.
/// </summary>
/// <param name="settingName">Setting name.</param>
/// <param name="value">Setting value.</param>
public void ConfigureInstallBehavior(string settingName, string value)
{
string localAppDataPath = Environment.GetEnvironmentVariable(Constants.LocalAppData);
Expand All @@ -49,14 +75,18 @@ public void ConfigureInstallBehavior(string settingName, string value)
File.WriteAllText(Path.Combine(localAppDataPath, TestCommon.SettingsJsonFilePath), settingsJson.ToString());
}

/// <summary>
/// Initialize all features.
/// </summary>
/// <param name="status">Initialized feature value.</param>
public void InitializeAllFeatures(bool status)
{
ConfigureFeature("experimentalArg", status);
ConfigureFeature("experimentalCmd", status);
ConfigureFeature("dependencies", status);
ConfigureFeature("directMSI", status);
ConfigureFeature("zipInstall", status);
ConfigureFeature("openLogsArgument", status);
this.ConfigureFeature("experimentalArg", status);
this.ConfigureFeature("experimentalCmd", status);
this.ConfigureFeature("dependencies", status);
this.ConfigureFeature("directMSI", status);
this.ConfigureFeature("zipInstall", status);
this.ConfigureFeature("openLogsArgument", status);
}
}
}
21 changes: 18 additions & 3 deletions src/AppInstallerCLIE2ETests/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// -----------------------------------------------------------------------------
// <copyright file="Constants.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
// -----------------------------------------------------------------------------

namespace AppInstallerCLIE2ETests
{
/// <summary>
/// Constants.
/// </summary>
public class Constants
{
#pragma warning disable SA1600 // ElementsMustBeDocumented
#pragma warning disable SA1310 // Field names should not contain underscore

// Runtime test parameters
public const string PackagedContextParameter = "PackagedContext";
public const string AICLIPathParameter = "AICLIPath";
Expand Down Expand Up @@ -90,7 +99,7 @@ public class Constants

// Package dir
public const string PortableExePackageDirName = $"{PortableExePackageId}_{TestSourceIdentifier}";
public const string PortableExeWithCommandPackageDirName = $"{PortableExeWithCommandPackageId}_{TestSourceIdentifier}";
public const string PortableExeWithCommandPackageDirName = $"{PortableExeWithCommandPackageId}_{TestSourceIdentifier}";

// Registry keys
public const string WinGetPackageIdentifier = "WinGetPackageIdentifier";
Expand All @@ -103,6 +112,9 @@ public class Constants
public const string PortablePackageUserRoot = "portablePackageUserRoot";
public const string PortablePackageMachineRoot = "portablePackageMachineRoot";

/// <summary>
/// Error codes.
/// </summary>
public class ErrorCode
{
public const int S_OK = 0;
Expand Down Expand Up @@ -240,5 +252,8 @@ public class ErrorCode
public const int INSTALLED_STATUS_FILE_FOUND_WITHOUT_HASH_CHECK = unchecked((int)0x0A150206);
public const int INSTALLED_STATUS_FILE_ACCESS_ERROR = unchecked((int)0x8A150207);
}

#pragma warning restore SA1310 // Field names should not contain underscore
#pragma warning restore SA1600 // ElementsMustBeDocumented
}
}
38 changes: 28 additions & 10 deletions src/AppInstallerCLIE2ETests/FeaturesCommand.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,59 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// -----------------------------------------------------------------------------
// <copyright file="FeaturesCommand.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
// -----------------------------------------------------------------------------

namespace AppInstallerCLIE2ETests
{
using NUnit.Framework;

/// <summary>
/// Features command tests.
/// </summary>
public class FeaturesCommand : BaseCommand
{
/// <summary>
/// Set up.
/// </summary>
[SetUp]
public void Setup()
{
InitializeAllFeatures(false);
this.InitializeAllFeatures(false);
}

/// <summary>
/// Tear down.
/// </summary>
[TearDown]
public void TearDown()
{
InitializeAllFeatures(false);
this.InitializeAllFeatures(false);
}

/// <summary>
/// Tests winget features.
/// </summary>
[Test]
public void DisplayFeatures()
{
var result = TestCommon.RunAICLICommand("features", "");
var result = TestCommon.RunAICLICommand("features", string.Empty);
Assert.AreEqual(Constants.ErrorCode.S_OK, result.ExitCode);
Assert.True(result.StdOut.Contains("Direct MSI Installation"));
Assert.False(result.StdOut.Contains("Enabled"));
}

/// <summary>
/// Tests enabled winget features.
/// </summary>
[Test]
public void EnableExperimentalFeatures()
{
ConfigureFeature("experimentalArg", true);
ConfigureFeature("experimentalCmd", true);
ConfigureFeature("directMSI", true);
ConfigureFeature("openLogsArgument", true);
var result = TestCommon.RunAICLICommand("features", "");
this.ConfigureFeature("experimentalArg", true);
this.ConfigureFeature("experimentalCmd", true);
this.ConfigureFeature("directMSI", true);
this.ConfigureFeature("openLogsArgument", true);
var result = TestCommon.RunAICLICommand("features", string.Empty);
Assert.True(result.StdOut.Contains("Enabled"));
}
}
Expand Down
Loading