Skip to content

Commit 2a861fb

Browse files
committed
Improve untitled script test by checking $MyInvocation
1 parent 932d3b2 commit 2a861fb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/PowerShellEditorServices.Test.E2E/DebugAdapterProtocolMessageTests.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,8 @@ public async Task CanStepPastSystemWindowsForms()
305305
[Fact]
306306
public async Task CanLaunchScriptWithCommentedLastLineAsync()
307307
{
308-
string script = GenerateScriptFromLoggingStatements("a log statement") + "# a comment at the end";
309-
Assert.Contains(Environment.NewLine + "# a comment", script);
310-
Assert.EndsWith("at the end", script);
308+
string script = GenerateScriptFromLoggingStatements("$($MyInvocation.Line)") + "# a comment at the end";
309+
Assert.EndsWith(Environment.NewLine + "# a comment at the end", script);
311310

312311
// NOTE: This is horribly complicated, but the "script" parameter here is assigned to
313312
// PsesLaunchRequestArguments.Script, which is then assigned to
@@ -317,8 +316,13 @@ public async Task CanLaunchScriptWithCommentedLastLineAsync()
317316

318317
ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(true);
319318
Assert.NotNull(configDoneResponse);
319+
// We can check that the script was invoked as expected, which is to dot-source a script
320+
// block with the contents surrounded by newlines. While we can't check that the last
321+
// line was a curly brace by itself, we did check that the contents ended with a
322+
// comment, so if this output exists then the bug did not recur.
320323
Assert.Collection(await GetLog().ConfigureAwait(true),
321-
(i) => Assert.Equal("a log statement", i));
324+
(i) => Assert.Equal(". {", i),
325+
(i) => Assert.Equal("", i));
322326
}
323327

324328
[SkippableFact]

0 commit comments

Comments
 (0)