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 IHttpActionResult Launch([FromUri, Required] LaunchRequest request) { using (var _db = new DatabaseContext()) { IAuthorizationManager authorizationManager = new AuthorizationManager(); Session session = authorizationManager.ValidateAndUpdateSession(_db, request.token); if (session == null) { return(Unauthorized()); } ILaunchManager launchManager = new LaunchManager(); LaunchResponse launchResponse = launchManager.SignLaunch(_db, session, request.appId); return(Ok(launchResponse)); } }
/// <summary> /// Called by ThwargLauncher /// </summary> public static LaunchResponse GetLaunchResponse(string ServerName, string AccountName, TimeSpan maxLatency) { var info = new LaunchResponse(); try { string filepath = FileLocations.GetCurrentLaunchResponseFilePath(ServerName: ServerName, AccountName: AccountName); if (string.IsNullOrEmpty(filepath)) { return(info); } if (!File.Exists(filepath)) { return(info); } var settings = (new SettingsFileLoader()).ReadSettingsFile(filepath); info.FileVersion = SettingHelpers.GetSingleStringValue(settings, "FileVersion"); if (!info.FileVersion.StartsWith(LaunchResponse.MASTER_FILE_VERSION_COMPAT)) { throw new Exception(string.Format( "Incompatible launch response file version: {0}", info.FileVersion)); } info.ResponseTime = SettingHelpers.GetSingleDateTimeValue(settings, "TimeUtc"); if (DateTime.UtcNow - info.ResponseTime.ToUniversalTime() >= maxLatency) { return(info); } info.ProcessId = SettingHelpers.GetSingleIntValue(settings, "ProcessId"); info.ThwargFilterVersion = SettingHelpers.GetSingleStringValue(settings, "ThwargFilterVersion"); info.ServerNameReported = SettingHelpers.GetSingleStringValue(settings, "ServerNameReported"); info.IsValid = true; } catch (Exception exc) { log.WriteError("GetLaunchResponse exception: {0}", exc); } return(info); }
public static async Task LaunchScript(this DebugAdapterClient debugAdapterClient, string filePath, TaskCompletionSource <object> started) { LaunchResponse launchResponse = await debugAdapterClient.RequestLaunch(new PsesLaunchRequestArguments { NoDebug = false, Script = filePath, Cwd = "", CreateTemporaryIntegratedConsole = false, }).ConfigureAwait(false); if (launchResponse == null) { throw new Exception("Launch response was null."); } // This will check to see if we received the Initialized event from the server. await Task.Run( async() => await started.Task.ConfigureAwait(false), new CancellationTokenSource(2000).Token).ConfigureAwait(false); }