Skip to content

Commit 41fdf50

Browse files
committed
Copy testbed in pipeline; initialize signal handler in server process; use explicit test package parameter in tests
1 parent 1882f6c commit 41fdf50

File tree

7 files changed

+21
-5
lines changed

7 files changed

+21
-5
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ jobs:
213213
Contents: |
214214
AppInstallerCLIE2ETests\**
215215
AppInstallerCLITests\**
216+
ComInprocTestbed\**
216217
Microsoft.Management.Configuration\**
217218
Microsoft.Management.Configuration.UnitTests\**
218219
Microsoft.Management.Configuration.OutOfProc\**

src/AppInstallerCLICore/Public/ShutdownMonitoring.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace AppInstaller::ShutdownMonitoring
7171
using ShutdownCompleteCallback = void (*)();
7272

7373
// Initializes the monitoring system and sets up a callback to be invoked when shutdown is completed.
74-
static void Initialize(ShutdownCompleteCallback callback);
74+
static void Initialize(ShutdownCompleteCallback callback, bool createTerminationSignalHandler = true);
7575

7676
// "Interface" for a single component to synchronize with.
7777
struct ComponentSystem

src/AppInstallerCLICore/ShutdownMonitoring.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,16 @@ namespace AppInstaller::ShutdownMonitoring
286286
}
287287
}
288288

289-
void ServerShutdownSynchronization::Initialize(ShutdownCompleteCallback callback)
289+
void ServerShutdownSynchronization::Initialize(ShutdownCompleteCallback callback, bool createTerminationSignalHandler)
290290
{
291291
Instance().m_callback = callback;
292+
293+
// Force the creation of the TerminationSignalHandler singleton so that the process can listen for termination signals even if
294+
// it never attempts to run anything that explicitly registers for cancellation callbacks.
295+
if (createTerminationSignalHandler)
296+
{
297+
TerminationSignalHandler::Instance();
298+
}
292299
}
293300

294301
void ServerShutdownSynchronization::AddComponent(const ComponentSystem& component)

src/AppInstallerCLIE2ETests/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class Constants
3333
public const string SkipTestSourceParameter = "SkipTestSource";
3434
public const string ForcedExperimentalFeaturesParameter = "ForcedExperimentalFeatures";
3535
public const string InprocTestbedPathParameter = "InprocTestbedPath";
36+
public const string InprocTestbedUseTestPackageParameter = "InprocTestbedUseTestPackage";
3637

3738
// Test Sources
3839
public const string DefaultWingetSourceName = @"winget";

src/AppInstallerCLIE2ETests/Helpers/TestSetup.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ private TestSetup()
3131
this.VerboseLogging = this.InitializeBoolParam(Constants.VerboseLoggingParameter, true);
3232
this.LooseFileRegistration = this.InitializeBoolParam(Constants.LooseFileRegistrationParameter);
3333
this.SkipTestSource = this.InitializeBoolParam(Constants.SkipTestSourceParameter, this.IsDefault);
34+
this.InprocTestbedUseTestPackage = this.InitializeBoolParam(Constants.InprocTestbedUseTestPackageParameter);
3435

3536
// For packaged context, default to AppExecutionAlias
3637
this.AICLIPath = this.InitializeStringParam(Constants.AICLIPathParameter, this.PackagedContext ? "WinGetDev.exe" : TestCommon.GetTestFile("winget.exe"));
@@ -136,6 +137,11 @@ public static TestSetup Parameters
136137
/// </summary>
137138
public string InprocTestbedPath { get; }
138139

140+
/// <summary>
141+
/// Gets a value indicating whether to use the test package or not.
142+
/// </summary>
143+
public bool InprocTestbedUseTestPackage { get; }
144+
139145
/// <summary>
140146
/// Gets a value indicating whether to skip creating test source.
141147
/// </summary>

src/AppInstallerCLIE2ETests/InprocTestbedTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ public void OneTimeSetup()
7575
if (string.IsNullOrWhiteSpace(this.InprocTestbedPath))
7676
{
7777
string assemblyLocation = Assembly.GetExecutingAssembly().Location;
78-
this.InprocTestbedPath = Path.Combine(Path.GetDirectoryName(assemblyLocation), "..\\ComInprocTestbed\\ComInprocTestbed.exe");
78+
this.InprocTestbedPath = Path.Join(Path.GetDirectoryName(assemblyLocation), "..\\ComInprocTestbed\\ComInprocTestbed.exe");
7979
}
8080

81-
// If we are using the test source, target a package in it
82-
if (!TestSetup.Parameters.SkipTestSource)
81+
if (TestSetup.Parameters.InprocTestbedUseTestPackage)
8382
{
8483
this.TargetPackageInformation = $"-pkg {Constants.ExeInstallerPackageId} -src {Constants.TestSourceName} -url {Constants.TestSourceUrl}";
8584
}

templates/e2e-test.template.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ steps:
3333
-PowerShellModulePath $(buildOutDir)\PowerShell\Microsoft.WinGet.Client\Microsoft.WinGet.Client.psd1
3434
-LocalServerCertPath $(Agent.TempDirectory)\servercert.cer
3535
-SkipTestSource true
36+
-InprocTestbedUseTestPackage true
3637
-ForcedExperimentalFeatures ${{ parameters.experimentalFeatures }}'
3738
${{ else }}:
3839
overrideTestrunParameters: '-PackagedContext false
@@ -41,6 +42,7 @@ steps:
4142
-PowerShellModulePath $(buildOutDir)\PowerShell\Microsoft.WinGet.Client\Microsoft.WinGet.Client.psd1
4243
-LocalServerCertPath $(Agent.TempDirectory)\servercert.cer
4344
-SkipTestSource true
45+
-InprocTestbedUseTestPackage true
4446
-ForcedExperimentalFeatures ${{ parameters.experimentalFeatures }}'
4547

4648
- task: CmdLine@2

0 commit comments

Comments
 (0)