public async Task CanLaunchScriptWithNoBreakpointsAsync() { string filePath = NewTestFile("'works' > \"$PSScriptRoot/testFile.txt\""); LaunchResponse launchResponse = await PsesDebugAdapterClient.RequestLaunch(new PsesLaunchRequestArguments { NoDebug = false, Script = filePath, Cwd = "", CreateTemporaryIntegratedConsole = false, }).ConfigureAwait(false); Assert.NotNull(launchResponse); // This will check to see if we received the Initialized event from the server. await Task.Run( async() => await _dapTestsFixture.Started.Task.ConfigureAwait(false), new CancellationTokenSource(2000).Token).ConfigureAwait(false); ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(false); Assert.NotNull(configDoneResponse); // At this point the script should be running so lets give it time await Task.Delay(2000).ConfigureAwait(false); string testFile = Path.Join(Path.GetDirectoryName(filePath), "testFile.txt"); string contents = await File.ReadAllTextAsync(testFile).ConfigureAwait(false); Assert.Equal($"works{Environment.NewLine}", contents); }
public async Task CanLaunchScriptWithNoBreakpointsAsync() { string filePath = NewTestFile(GenerateScriptFromLoggingStatements("works")); await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(false); ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(false); Assert.NotNull(configDoneResponse); // At this point the script should be running so lets give it time await Task.Delay(2000).ConfigureAwait(false); string[] log = GetLog(); Assert.Equal("works", log[0]); }
public async Task CanStepPastSystemWindowsForms() { Skip.IfNot(PsesStdioProcess.IsWindowsPowerShell); Skip.If(PsesStdioProcess.RunningInConstainedLanguageMode); string filePath = NewTestFile(string.Join(Environment.NewLine, new [] { "Add-Type -AssemblyName System.Windows.Forms", "$form = New-Object System.Windows.Forms.Form", "Write-Host $form" })); await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(false); var setBreakpointsResponse = await PsesDebugAdapterClient.SetFunctionBreakpoints( new SetFunctionBreakpointsArguments { Breakpoints = new FunctionBreakpoint[] { new FunctionBreakpoint { Name = "Write-Host", } } }).ConfigureAwait(false); var breakpoint = setBreakpointsResponse.Breakpoints.First(); Assert.True(breakpoint.Verified); ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(false); Assert.NotNull(configDoneResponse); // At this point the script should be running so lets give it time await Task.Delay(2000).ConfigureAwait(false); var variablesResponse = await PsesDebugAdapterClient.RequestVariables( new VariablesArguments { VariablesReference = 1 }).ConfigureAwait(false); var form = variablesResponse.Variables.FirstOrDefault(v => v.Name == "$form"); Assert.NotNull(form); Assert.Equal("System.Windows.Forms.Form, Text: ", form.Value); }
public async Task CanSetBreakpointsAsync() { Skip.If( PsesStdioProcess.RunningInConstainedLanguageMode, "You can't set breakpoints in ConstrainedLanguage mode."); string filePath = NewTestFile(GenerateScriptFromLoggingStatements( "before breakpoint", "at breakpoint", "after breakpoint" )); await PsesDebugAdapterClient.LaunchScript(filePath, Started).ConfigureAwait(false); // {"command":"setBreakpoints","arguments":{"source":{"name":"dfsdfg.ps1","path":"/Users/tyleonha/Code/PowerShell/Misc/foo/dfsdfg.ps1"},"lines":[2],"breakpoints":[{"line":2}],"sourceModified":false},"type":"request","seq":3} SetBreakpointsResponse setBreakpointsResponse = await PsesDebugAdapterClient.SetBreakpoints(new SetBreakpointsArguments { Source = new Source { Name = Path.GetFileName(filePath), Path = filePath }, Lines = new long[] { 2 }, Breakpoints = new SourceBreakpoint[] { new SourceBreakpoint { Line = 2, } }, SourceModified = false, }).ConfigureAwait(false); var breakpoint = setBreakpointsResponse.Breakpoints.First(); Assert.True(breakpoint.Verified); Assert.Equal(filePath, breakpoint.Source.Path, ignoreCase: s_isWindows); Assert.Equal(2, breakpoint.Line); ConfigurationDoneResponse configDoneResponse = await PsesDebugAdapterClient.RequestConfigurationDone(new ConfigurationDoneArguments()).ConfigureAwait(false); Assert.NotNull(configDoneResponse); // At this point the script should be running so lets give it time await Task.Delay(2000).ConfigureAwait(false); string[] log = GetLog(); Assert.Single(log, (i) => i == "before breakpoint"); ContinueResponse continueResponse = await PsesDebugAdapterClient.RequestContinue(new ContinueArguments { ThreadId = 1, }).ConfigureAwait(true); Assert.NotNull(continueResponse); // At this point the script should be running so lets give it time await Task.Delay(2000).ConfigureAwait(false); log = GetLog(); Assert.Collection(log, (i) => Assert.Equal("before breakpoint", i), (i) => Assert.Equal("at breakpoint", i), (i) => Assert.Equal("after breakpoint", i)); }