private static async Task <string> GetRemoteRtvsPackagePath(IRExpressionEvaluator eval) { const string windowsPath = "."; const string unixPath = "/usr/share/rtvs"; return(await eval.IsRSessionPlatformWindowsAsync() ? windowsPath : unixPath); }
public static async Task SetCodePageAsync(this IRExpressionEvaluator evaluation, int codePage, CancellationToken cancellationToken = default(CancellationToken)) { var cp = $".{codePage}"; if (codePage == 0) { cp = await evaluation.IsRSessionPlatformWindowsAsync() ? ".437" : "en_US.UTF-8"; } var script = Invariant($"Sys.setlocale('LC_CTYPE', '{cp}')"); await evaluation.ExecuteAsync(script, cancellationToken); }
private async Task <string> GetRemoteRtvsPackagePath(IRExpressionEvaluator eval) { var isWindows = await eval.IsRSessionPlatformWindowsAsync(); if (!isWindows) { // Remote Linux return("/usr/share/rtvs"); } // Check if there is 'rtvs' folder on remote var rtvsExists = await eval.FileExistsAsync("./rtvs/NAMESPACE"); if (rtvsExists) { return("."); } // Most probably tests are running remote broker locally var locator = BrokerExecutableLocator.Create(_fileSystem); var hostDirectory = Path.GetDirectoryName(locator.GetHostExecutablePath()); rtvsExists = _fileSystem.FileExists(Path.Combine(hostDirectory, @"rtvs\NAMESPACE")); return(rtvsExists ? hostDirectory : Path.GetFullPath(Path.Combine(hostDirectory, @"..\.."))); }
public static async Task SetCodePageAsync(this IRExpressionEvaluator evaluation, int codePage, CancellationToken cancellationToken = default) { string cp = null; if (codePage == 0) { // Non-Windows defaults to UTF-8, on Windows leave default alone. if (!await evaluation.IsRSessionPlatformWindowsAsync(cancellationToken)) { cp = "en_US.UTF-8"; } } else { cp = Invariant($".{codePage}"); } if (!string.IsNullOrEmpty(cp)) { var script = Invariant($"Sys.setlocale('LC_CTYPE', '{cp}')"); await evaluation.ExecuteAsync(script, cancellationToken); } }