|
1 |
| -// Copyright (c) Microsoft Corporation. |
| 1 | +// Copyright (c) Microsoft Corporation. |
2 | 2 | // Licensed under the MIT License.
|
3 | 3 |
|
4 | 4 | using System;
|
@@ -297,5 +297,32 @@ public async Task CanStepPastSystemWindowsForms()
|
297 | 297 | Assert.NotNull(form);
|
298 | 298 | Assert.Equal("System.Windows.Forms.Form, Text: ", form.Value);
|
299 | 299 | }
|
| 300 | + |
| 301 | + // This tests the edge-case where a raw script (or an untitled script) has the last line |
| 302 | + // commented. Since in some cases (such as Windows PowerShell, or the script not having a |
| 303 | + // backing ScriptFile) we just wrap the script with braces, we had a bug where the last |
| 304 | + // brace would be after the comment. We had to ensure we wrapped with newlines instead. |
| 305 | + [Trait("Category", "DAP")] |
| 306 | + [Fact] |
| 307 | + public async Task CanLaunchScriptWithCommentedLastLineAsync() |
| 308 | + { |
| 309 | + string script = GenerateScriptFromLoggingStatements("a log statement") + "# a comment at the end"; |
| 310 | + Assert.Contains(Environment.NewLine + "# a comment", script); |
| 311 | + Assert.EndsWith("at the end", script); |
| 312 | + |
| 313 | + // NOTE: This is horribly complicated, but the "script" parameter here is assigned to |
| 314 | + // PsesLaunchRequestArguments.Script, which is then assigned to |
| 315 | + // DebugStateService.ScriptToLaunch in that handler, and finally used by the |
| 316 | + // ConfigurationDoneHandler in LaunchScriptAsync. |
| 317 | + await PsesDebugAdapterClient.LaunchScript(script, Started).ConfigureAwait(false); |
| 318 | + |
| 319 | + ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(false); |
| 320 | + Assert.NotNull(configDoneResponse); |
| 321 | + |
| 322 | + // At this point the script should be running so lets give it time |
| 323 | + await Task.Delay(2000).ConfigureAwait(false); |
| 324 | + |
| 325 | + Assert.Collection(GetLog(), (i) => Assert.Equal("a log statement", i)); |
| 326 | + } |
300 | 327 | }
|
301 | 328 | }
|
0 commit comments