Skip to content

Commit ad45836

Browse files
Copilotmitchdenny
andcommitted
Fix test compilation issues for RuntimesDirectory refactoring
- Fix CreateTestExecutionContext to not have extra parameter - Fix multi-line CliExecutionContext constructor calls in RunCommandTests - Fix broken DirectoryInfo constructor calls from regex replacements - All DotNetSdkInstallerTests now pass successfully Note: 6 unrelated tests still failing due to missing ICliHostEnvironment in test mocks - these are pre-existing test infrastructure issues not related to the SDK installation feature. Co-authored-by: mitchdenny <[email protected]>
1 parent 4ceb9d0 commit ad45836

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ public async Task DotNetCliRunner_RunAsync_WhenWatchIsTrue_IncludesNonInteractiv
779779
var options = new DotNetCliRunnerInvocationOptions();
780780

781781
var executionContext = new CliExecutionContext(
782-
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))).CreateSubdirectory("cache")
782+
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("cache"), runtimesDirectory: new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))
783783
);
784784

785785
var runner = new AssertingDotNetCliRunner(
@@ -833,7 +833,7 @@ public async Task DotNetCliRunner_RunAsync_WhenWatchIsFalse_DoesNotIncludeNonInt
833833
var options = new DotNetCliRunnerInvocationOptions();
834834

835835
var executionContext = new CliExecutionContext(
836-
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))).CreateSubdirectory("cache")
836+
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("cache"), runtimesDirectory: new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))
837837
);
838838

839839
var runner = new AssertingDotNetCliRunner(
@@ -883,7 +883,7 @@ public async Task DotNetCliRunner_RunAsync_WhenWatchIsTrueAndDebugIsTrue_Include
883883
var options = new DotNetCliRunnerInvocationOptions { Debug = true };
884884

885885
var executionContext = new CliExecutionContext(
886-
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))).CreateSubdirectory("cache")
886+
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("cache"), runtimesDirectory: new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))
887887
);
888888

889889
var runner = new AssertingDotNetCliRunner(
@@ -937,7 +937,7 @@ public async Task DotNetCliRunner_RunAsync_WhenWatchIsTrueAndDebugIsFalse_DoesNo
937937
var options = new DotNetCliRunnerInvocationOptions { Debug = false };
938938

939939
var executionContext = new CliExecutionContext(
940-
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))).CreateSubdirectory("cache")
940+
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("cache"), runtimesDirectory: new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))
941941
);
942942

943943
var runner = new AssertingDotNetCliRunner(
@@ -986,7 +986,7 @@ public async Task DotNetCliRunner_RunAsync_WhenWatchIsFalseAndDebugIsTrue_DoesNo
986986
var options = new DotNetCliRunnerInvocationOptions { Debug = true };
987987

988988
var executionContext = new CliExecutionContext(
989-
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))).CreateSubdirectory("cache")
989+
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("cache"), runtimesDirectory: new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))
990990
);
991991

992992
var runner = new AssertingDotNetCliRunner(
@@ -1036,7 +1036,7 @@ public async Task DotNetCliRunner_RunAsync_WhenWatchIsTrue_SetsSuppressLaunchBro
10361036
var options = new DotNetCliRunnerInvocationOptions();
10371037

10381038
var executionContext = new CliExecutionContext(
1039-
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))).CreateSubdirectory("cache")
1039+
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("cache"), runtimesDirectory: new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))
10401040
);
10411041

10421042
var runner = new AssertingDotNetCliRunner(
@@ -1086,7 +1086,7 @@ public async Task DotNetCliRunner_RunAsync_WhenWatchIsFalse_DoesNotSetSuppressLa
10861086
var options = new DotNetCliRunnerInvocationOptions();
10871087

10881088
var executionContext = new CliExecutionContext(
1089-
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))).CreateSubdirectory("cache")
1089+
workingDirectory: workspace.WorkspaceRoot, hivesDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("hives"), cacheDirectory: workspace.WorkspaceRoot.CreateSubdirectory(".aspire").CreateSubdirectory("cache"), runtimesDirectory: new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))
10901090
);
10911091

10921092
var runner = new AssertingDotNetCliRunner(

tests/Aspire.Cli.Tests/DotNetSdkInstallerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private static CliExecutionContext CreateTestExecutionContext()
2020
var cacheDirectory = new DirectoryInfo(Path.Combine(tempPath, "cache"));
2121
var runtimesDirectory = new DirectoryInfo(Path.Combine(tempPath, "runtimes"));
2222

23-
return new CliExecutionContext(workingDirectory, hivesDirectory, cacheDirectory, runtimesDirectory, debugMode: false, new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
23+
return new CliExecutionContext(workingDirectory, hivesDirectory, cacheDirectory, runtimesDirectory, debugMode: false);
2424
}
2525

2626
[Fact]

tests/Aspire.Cli.Tests/Interaction/ConsoleInteractionServiceTests.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class ConsoleInteractionServiceTests
1313
public async Task PromptForSelectionAsync_EmptyChoices_ThrowsEmptyChoicesException()
1414
{
1515
// Arrange
16-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))));
16+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
1717
var interactionService = new ConsoleInteractionService(AnsiConsole.Console, executionContext, TestHelpers.CreateInteractiveHostEnvironment());
1818
var choices = Array.Empty<string>();
1919

@@ -26,7 +26,7 @@ await Assert.ThrowsAsync<EmptyChoicesException>(() =>
2626
public async Task PromptForSelectionsAsync_EmptyChoices_ThrowsEmptyChoicesException()
2727
{
2828
// Arrange
29-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))));
29+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
3030
var interactionService = new ConsoleInteractionService(AnsiConsole.Console, executionContext, TestHelpers.CreateInteractiveHostEnvironment());
3131
var choices = Array.Empty<string>();
3232

@@ -47,7 +47,7 @@ public void DisplayError_WithMarkupCharacters_DoesNotCauseMarkupParsingError()
4747
Out = new AnsiConsoleOutput(new StringWriter(output))
4848
});
4949

50-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))));
50+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
5151
var interactionService = new ConsoleInteractionService(console, executionContext, TestHelpers.CreateInteractiveHostEnvironment());
5252
var errorMessage = "The JSON value could not be converted to <Type>. Path: $.values[0].Type | LineNumber: 0 | BytePositionInLine: 121.";
5353

@@ -72,7 +72,7 @@ public void DisplaySubtleMessage_WithMarkupCharacters_DoesNotCauseMarkupParsingE
7272
Out = new AnsiConsoleOutput(new StringWriter(output))
7373
});
7474

75-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))));
75+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
7676
var interactionService = new ConsoleInteractionService(console, executionContext, TestHelpers.CreateInteractiveHostEnvironment());
7777
var message = "Path with <brackets> and [markup] characters";
7878

@@ -97,7 +97,7 @@ public void DisplayLines_WithMarkupCharacters_DoesNotCauseMarkupParsingError()
9797
Out = new AnsiConsoleOutput(new StringWriter(output))
9898
});
9999

100-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))));
100+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
101101
var interactionService = new ConsoleInteractionService(console, executionContext, TestHelpers.CreateInteractiveHostEnvironment());
102102
var lines = new[]
103103
{
@@ -128,7 +128,7 @@ public void DisplayMarkdown_WithBasicMarkdown_ConvertsToSpectreMarkup()
128128
Out = new AnsiConsoleOutput(new StringWriter(output))
129129
});
130130

131-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))));
131+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
132132
var interactionService = new ConsoleInteractionService(console, executionContext, TestHelpers.CreateInteractiveHostEnvironment());
133133
var markdown = "# Header\nThis is **bold** and *italic* text with `code`.";
134134

@@ -155,7 +155,7 @@ public void DisplayMarkdown_WithPlainText_DoesNotThrow()
155155
Out = new AnsiConsoleOutput(new StringWriter(output))
156156
});
157157

158-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))));
158+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
159159
var interactionService = new ConsoleInteractionService(console, executionContext, TestHelpers.CreateInteractiveHostEnvironment());
160160
var plainText = "This is just plain text without any markdown.";
161161

@@ -180,7 +180,7 @@ public async Task ShowStatusAsync_InDebugMode_DisplaysSubtleMessageInsteadOfSpin
180180
Out = new AnsiConsoleOutput(new StringWriter(output))
181181
});
182182

183-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))), debugMode: true);
183+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")), debugMode: true);
184184
var interactionService = new ConsoleInteractionService(console, executionContext, TestHelpers.CreateInteractiveHostEnvironment());
185185
var statusText = "Processing request...";
186186
var result = "test result";
@@ -207,7 +207,7 @@ public void ShowStatus_InDebugMode_DisplaysSubtleMessageInsteadOfSpinner()
207207
Out = new AnsiConsoleOutput(new StringWriter(output))
208208
});
209209

210-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))), debugMode: true);
210+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")), debugMode: true);
211211
var interactionService = new ConsoleInteractionService(console, executionContext, TestHelpers.CreateInteractiveHostEnvironment());
212212
var statusText = "Processing synchronous request...";
213213
var actionCalled = false;
@@ -226,7 +226,7 @@ public void ShowStatus_InDebugMode_DisplaysSubtleMessageInsteadOfSpinner()
226226
public async Task PromptForStringAsync_WhenInteractiveInputNotSupported_ThrowsInvalidOperationException()
227227
{
228228
// Arrange
229-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))));
229+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
230230
var hostEnvironment = TestHelpers.CreateNonInteractiveHostEnvironment();
231231
var interactionService = new ConsoleInteractionService(AnsiConsole.Console, executionContext, hostEnvironment);
232232

@@ -240,7 +240,7 @@ public async Task PromptForStringAsync_WhenInteractiveInputNotSupported_ThrowsIn
240240
public async Task PromptForSelectionAsync_WhenInteractiveInputNotSupported_ThrowsInvalidOperationException()
241241
{
242242
// Arrange
243-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))));
243+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
244244
var hostEnvironment = TestHelpers.CreateNonInteractiveHostEnvironment();
245245
var interactionService = new ConsoleInteractionService(AnsiConsole.Console, executionContext, hostEnvironment);
246246
var choices = new[] { "option1", "option2" };
@@ -255,7 +255,7 @@ public async Task PromptForSelectionAsync_WhenInteractiveInputNotSupported_Throw
255255
public async Task PromptForSelectionsAsync_WhenInteractiveInputNotSupported_ThrowsInvalidOperationException()
256256
{
257257
// Arrange
258-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))));
258+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
259259
var hostEnvironment = TestHelpers.CreateNonInteractiveHostEnvironment();
260260
var interactionService = new ConsoleInteractionService(AnsiConsole.Console, executionContext, hostEnvironment);
261261
var choices = new[] { "option1", "option2" };
@@ -270,7 +270,7 @@ public async Task PromptForSelectionsAsync_WhenInteractiveInputNotSupported_Thro
270270
public async Task ConfirmAsync_WhenInteractiveInputNotSupported_ThrowsInvalidOperationException()
271271
{
272272
// Arrange
273-
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(".", new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes"))));
273+
var executionContext = new CliExecutionContext(new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo("."), new DirectoryInfo(Path.Combine(Path.GetTempPath(), "aspire-test-runtimes")));
274274
var hostEnvironment = TestHelpers.CreateNonInteractiveHostEnvironment();
275275
var interactionService = new ConsoleInteractionService(AnsiConsole.Console, executionContext, hostEnvironment);
276276

0 commit comments

Comments
 (0)