Skip to content

Commit e95fa43

Browse files
committed
Add regression test for debugging script with dot-source operator
1 parent 7252de6 commit e95fa43

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,12 @@ private string GenerateScriptFromLoggingStatements(params string[] logStatements
130130
}
131131

132132
// Have script create file first with `>` (but don't rely on overwriting).
133-
StringBuilder builder = new StringBuilder().Append('\'').Append(logStatements[0]).Append("' > '").Append(s_testOutputPath).AppendLine("'");
133+
// NOTE: We don't quote the log statements so that we can use PowerShell variables.
134+
StringBuilder builder = new StringBuilder().Append(logStatements[0]).Append(" > '").Append(s_testOutputPath).AppendLine("'");
134135
for (int i = 1; i < logStatements.Length; i++)
135136
{
136137
// Then append to that script with `>>`.
137-
builder.Append('\'').Append(logStatements[i]).Append("' >> '").Append(s_testOutputPath).AppendLine("'");
138+
builder.Append(logStatements[i]).Append(" >> '").Append(s_testOutputPath).AppendLine("'");
138139
}
139140

140141
_output.WriteLine("Script is:");
@@ -164,6 +165,17 @@ public void CanInitializeWithCorrectServerSettings()
164165
Assert.True(PsesDebugAdapterClient.ServerSettings.SupportsSetVariable);
165166
}
166167

168+
[Fact]
169+
public async Task UsesDotSourceOperatorAndQuotes()
170+
{
171+
string filePath = NewTestFile(GenerateScriptFromLoggingStatements("$MyInvocation.Line"));
172+
await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(true);
173+
ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(true);
174+
Assert.NotNull(configDoneResponse);
175+
Assert.Collection(await GetLog().ConfigureAwait(true),
176+
(i) => Assert.StartsWith(". \"", i));
177+
}
178+
167179
[Fact]
168180
public async Task CanLaunchScriptWithNoBreakpointsAsync()
169181
{

0 commit comments

Comments
 (0)