public void SetBreakpoints(string caller_trace) { foreach (var Breakpoints in SrcBreakpoints) { SetBreakpointsRequest setBreakpointsRequest = new SetBreakpointsRequest(); setBreakpointsRequest.arguments.source.name = Path.GetFileName(Breakpoints.Key); setBreakpointsRequest.arguments.source.path = Breakpoints.Key; setBreakpointsRequest.arguments.breakpoints.AddRange(Breakpoints.Value); setBreakpointsRequest.arguments.sourceModified = false; var ret = VSCodeDebugger.Request(setBreakpointsRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); SetBreakpointsResponse setBreakpointsResponse = JsonConvert.DeserializeObject <SetBreakpointsResponse>(ret.ResponseStr); // check, that we don't have hiddenly re-created breakpoints with different ids for (int i = 0; i < setBreakpointsResponse.body.breakpoints.Count; i++) { if (SrcBreakpointIds[Breakpoints.Key][i] == null) { CurrentBpId++; SrcBreakpointIds[Breakpoints.Key][i] = setBreakpointsResponse.body.breakpoints[i].id; } else { Assert.Equal(SrcBreakpointIds[Breakpoints.Key][i], setBreakpointsResponse.body.breakpoints[i].id, @"__FILE__:__LINE__" + "\n" + caller_trace); } } } }
public static void SetBreakpoints() { foreach (var Breakpoints in SrcBreakpoints) { SetBreakpointsRequest setBreakpointsRequest = new SetBreakpointsRequest(); setBreakpointsRequest.arguments.source.name = Path.GetFileName(Breakpoints.Key); setBreakpointsRequest.arguments.source.path = Breakpoints.Key; setBreakpointsRequest.arguments.breakpoints.AddRange(Breakpoints.Value); setBreakpointsRequest.arguments.sourceModified = false; var ret = VSCodeDebugger.Request(setBreakpointsRequest); Assert.True(ret.Success); SetBreakpointsResponse setBreakpointsResponse = JsonConvert.DeserializeObject <SetBreakpointsResponse>(ret.ResponseStr); // check, that we don't have hiddenly re-created breakpoints with different ids for (int i = 0; i < setBreakpointsResponse.body.breakpoints.Count; i++) { if (SrcBreakpointIds[Breakpoints.Key][i] == null) { CurrentBpId++; SrcBreakpointIds[Breakpoints.Key][i] = setBreakpointsResponse.body.breakpoints[i].id; } else { if (SrcBreakpointIds[Breakpoints.Key][i] != setBreakpointsResponse.body.breakpoints[i].id) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } } } } }
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)); }