예제 #1
0
        public async Task InstalledPackagesMultiLibsSamePackage()
        {
            // Install the same package in 2 different libraries
            using (var eval = await _workflow.RSession.BeginEvaluationAsync()) {
                await TestRepositories.SetLocalRepoAsync(eval, _repoPath);

                await TestLibraries.SetLocalLibsAsync(eval, _libPath);
                await InstallPackageAsync(eval, TestPackages.RtvsLib1Description.Package, _libPath);

                await TestLibraries.SetLocalLibsAsync(eval, _lib2Path);
                await InstallPackageAsync(eval, TestPackages.RtvsLib1Description.Package, _lib2Path);

                await TestLibraries.SetLocalLibsAsync(eval, _libPath, _lib2Path);
            }

            var result = await _workflow.Packages.GetInstalledPackagesAsync();

            ValidateRtvslib1Installed(result, _libPath);

            using (var eval = await _workflow.RSession.BeginEvaluationAsync()) {
                await TestLibraries.SetLocalLibsAsync(eval, _lib2Path, _libPath);
            }

            result = await _workflow.Packages.GetInstalledPackagesAsync();

            ValidateRtvslib1Installed(result, _lib2Path);
        }
예제 #2
0
        public async Task LoadAndUnloadPackage()
        {
            using (var eval = await _workflow.RSession.BeginEvaluationAsync()) {
                await TestRepositories.SetLocalRepoAsync(eval, _repoPath);

                await TestLibraries.SetLocalLibsAsync(eval, _libPath);
                await InstallPackageAsync(eval, TestPackages.RtvsLib1Description.Package, _libPath);
            }

            await EvaluateCode("func1();", expectedError : "Error: could not find function \"func1\"");

            await _workflow.Packages.LoadPackageAsync(TestPackages.RtvsLib1Description.Package, null);

            await EvaluateCode("func1();", expectedResult : "func1");

            var loaded = await _workflow.Packages.GetLoadedPackagesAsync();

            loaded.Should().Contain("rtvslib1");

            await _workflow.Packages.UnloadPackageAsync(TestPackages.RtvsLib1Description.Package);

            await EvaluateCode("func1();", expectedError : "Error: could not find function \"func1\"");

            loaded = await _workflow.Packages.GetLoadedPackagesAsync();

            loaded.Should().NotContain("rtvslib1");
        }
        public async Task LibraryPaths()
        {
            await TestRepositories.SetLocalRepoAsync(_workflow.RSession, _repoPath);

            await TestLibraries.SetLocalLibsAsync(_workflow.RSession, _libPath);

            var result = await _workflow.Packages.GetLibraryPathAsync();

            result.Should().Be(_libPath.ToRPath());
        }
        public async Task InstalledPackagesCustomLibPathNoPackages()
        {
            // Setup library path to point to the test folder, don't install anything in it
            await TestLibraries.SetLocalLibsAsync(_workflow.RSession, _libPath);

            var result = await _workflow.Packages.GetInstalledPackagesAsync();

            // Since we can't remove Program Files folder from library paths,
            // we'll get some results, but nothing from the test folder.
            result.Should().NotBeEmpty().And.NotContain(pkg => pkg.LibPath == _libPath.ToRPath());
        }
예제 #5
0
        public async Task LibraryPaths()
        {
            using (var eval = await _workflow.RSession.BeginEvaluationAsync()) {
                await TestRepositories.SetLocalRepoAsync(eval, _repoPath);

                await TestLibraries.SetLocalLibsAsync(eval, _libPath);
            }

            var result = await _workflow.Packages.GetLibraryPathsAsync();

            result[0].Should().Be(_libPath.ToRPath());
        }
        public async Task InstallPackageDefaultLib()
        {
            await TestRepositories.SetLocalRepoAsync(_workflow.RSession, _repoPath);

            await TestLibraries.SetLocalLibsAsync(_workflow.RSession, _libPath);

            await _workflow.Packages.InstallPackageAsync(TestPackages.RtvsLib1Description.Package, null);

            var installed = await _workflow.Packages.GetInstalledPackagesAsync();

            ValidateRtvslib1Installed(installed, _libPath);
        }
예제 #7
0
        public async Task GetPackageLockStateUnlocked()
        {
            using (var eval = await _workflow.RSession.BeginEvaluationAsync()) {
                await TestLibraries.SetLocalLibsAsync(eval, _libPath);
                await InstallPackageAsync(eval, "abn", _libPath);
            }

            var pkgs = await _workflow.Packages.GetInstalledPackagesAsync();

            var abn = pkgs.Should().ContainSingle(pkg => pkg.Package == "abn").Which;

            _workflow.Packages.GetPackageLockState(abn.Package, abn.LibPath).Should().Be(PackageLockState.Unlocked);
        }
        public async Task InstalledPackagesCustomLibPathOnePackage()
        {
            // Setup library path to point to the test folder, install a package into it
            await TestRepositories.SetLocalRepoAsync(_workflow.RSession, _repoPath);

            await TestLibraries.SetLocalLibsAsync(_workflow.RSession, _libPath);

            await InstallPackageAsync(_workflow.RSession, TestPackages.RtvsLib1Description.Package, _libPath);

            var result = await _workflow.Packages.GetInstalledPackagesAsync();

            ValidateRtvslib1Installed(result, _libPath);
        }
        public async Task GetPackageLockStateUnlocked()
        {
            await TestLibraries.SetLocalLibsAsync(_workflow.RSession, _libPath);

            await InstallPackageAsync(_workflow.RSession, "abn", _libPath);

            var pkgs = await _workflow.Packages.GetInstalledPackagesAsync();

            var abn = pkgs.Should().ContainSingle(pkg => pkg.Package == "abn").Which;

            var abnState = await _workflow.Packages.GetPackageLockStateAsync(abn.Package, abn.LibPath);

            abnState.Should().Be(PackageLockState.Unlocked);
        }
예제 #10
0
        public async Task InitializeAsync()
        {
            var settings = _services.GetService <IRSettings>();
            await _workflow.RSessions.TrySwitchBrokerAsync(nameof(RPackageManagerViewModelTest));

            await _workflow.RSession.EnsureHostStartedAsync(new RHostStartupInfo(settings.CranMirror, codePage : settings.RCodePage), null, 50000);

            await TestRepositories.SetLocalRepoAsync(_workflow.RSession, _testFiles);

            await TestLibraries.SetLocalLibraryAsync(_workflow.RSession, _testMethod, _testFiles);

            _packageManagerToolWindow = (TestToolWindow) await InUI(() => ((IRInteractiveWorkflowVisual)_workflow).ToolWindows.Packages());

            _packageManagerViewModel = (IRPackageManagerViewModel)_packageManagerToolWindow.ViewModel;
        }
예제 #11
0
        public async Task InitializeAsync()
        {
            var settings = _services.GetService <IRSettings>();
            await _workflow.RSessions.TrySwitchBrokerAsync(nameof(RPackageManagerViewModelTest));

            await _workflow.RSession.EnsureHostStartedAsync(new RHostStartupInfo(settings.CranMirror, codePage : settings.RCodePage), null, 50000);

            await TestRepositories.SetLocalRepoAsync(_workflow.RSession, _testFiles);

            await TestLibraries.SetLocalLibraryAsync(_workflow.RSession, _testMethod, _testFiles);

            var componentContainerFactory = _services.GetService <IRPackageManagerVisualComponentContainerFactory>();

            _packageManagerComponent = await InUI(() => _workflow.Packages.GetOrCreateVisualComponent(componentContainerFactory));

            _packageManagerViewModel = await InUI(() => _packageManagerComponent.Control.DataContext) as IRPackageManagerViewModel;
        }
        public async Task GetLoadedPackages()
        {
            await TestRepositories.SetLocalRepoAsync(_workflow.RSession, _repoPath);

            await TestLibraries.SetLocalLibsAsync(_workflow.RSession, _libPath);

            await InstallPackageAsync(_workflow.RSession, TestPackages.RtvsLib1Description.Package, _libPath);

            var results = await _workflow.Packages.GetLoadedPackagesAsync();

            results.Should().NotContain(new[] {
                "rtvslib1", ".GlobalEnv", "Autoloads",
            });
            results.Should().Contain(new[] {
                "stats", "graphics", "grDevices", "grDevices",
                "utils", "datasets", "methods", "base",
            });
        }
        public async Task InstallAndUninstallPackageSpecifiedLib()
        {
            await TestRepositories.SetLocalRepoAsync(_workflow.RSession, _repoPath);

            await _workflow.Packages.InstallPackageAsync(TestPackages.RtvsLib1Description.Package, _libPath);

            await TestLibraries.SetLocalLibsAsync(_workflow.RSession, _libPath);

            var installed = await _workflow.Packages.GetInstalledPackagesAsync();

            ValidateRtvslib1Installed(installed, _libPath);

            await _workflow.Packages.UninstallPackageAsync(TestPackages.RtvsLib1Description.Package, _libPath);

            installed = await _workflow.Packages.GetInstalledPackagesAsync();

            installed.Should().NotContain(pkg => pkg.Package == TestPackages.RtvsLib1Description.Package && pkg.LibPath == _libPath.ToRPath());
        }
        public async Task GetPackageLockStateLockByRSession()
        {
            await TestLibraries.SetLocalLibsAsync(_workflow.RSession, _libPath);

            await InstallPackageAsync(_workflow.RSession, "abn", _libPath);

            await _workflow.Packages.LoadPackageAsync("abn", null);

            var pkgs = await _workflow.Packages.GetInstalledPackagesAsync();

            var abn   = pkgs.Should().ContainSingle(pkg => pkg.Package == "abn").Which;
            var cairo = pkgs.Should().ContainSingle(pkg => pkg.Package == "Cairo").Which;

            var abnState = await _workflow.Packages.GetPackageLockStateAsync(abn.Package, abn.LibPath);

            abnState.Should().Be(PackageLockState.LockedByRSession);
            var cairoState = await _workflow.Packages.GetPackageLockStateAsync(cairo.Package, cairo.LibPath);

            cairoState.Should().Be(PackageLockState.LockedByRSession);
        }
예제 #15
0
        public async Task InitializeAsync()
        {
            var settings = _exportProvider.GetExportedValue <IRSettings>();
            await _workflow.RSessions.TrySwitchBrokerAsync(settings.LastActiveConnection.Name, settings.LastActiveConnection.Path);

            await _workflow.RSession.StartHostAsync(new RHostStartupInfo {
                Name                      = _testMethod.Name,
                CranMirrorName            = settings.CranMirror,
                RHostCommandLineArguments = settings.LastActiveConnection.RCommandLineArguments,
                CodePage                  = settings.RCodePage,
            }, null, 50000);

            await TestRepositories.SetLocalRepoAsync(_workflow.RSession, _testFiles);

            await TestLibraries.SetLocalLibraryAsync(_workflow.RSession, _testMethod, _testFiles);

            var componentContainerFactory = _exportProvider.GetExportedValue <IRPackageManagerVisualComponentContainerFactory>();

            _packageManagerComponent = await InUI(() => _workflow.Packages.GetOrCreateVisualComponent(componentContainerFactory));

            _packageManagerViewModel = await InUI(() => _packageManagerComponent.Control.DataContext) as IRPackageManagerViewModel;
        }
예제 #16
0
        public async Task InitializeAsync()
        {
            var settings = _exportProvider.GetExportedValue <IRSettings>();
            await _workflow.RSession.StartHostAsync(new RHostStartupInfo {
                Name      = _testMethod.Name,
                RBasePath = settings.RBasePath,
                RHostCommandLineArguments = settings.RCommandLineArguments,
                CranMirrorName            = settings.CranMirror,
                CodePage = settings.RCodePage,
            }, null, 50000);

            using (var eval = await _workflow.RSession.BeginEvaluationAsync()) {
                await TestRepositories.SetLocalRepoAsync(eval, _testFiles);

                await TestLibraries.SetLocalLibraryAsync(eval, _testMethod, _testFiles);
            }

            var componentContainerFactory = _exportProvider.GetExportedValue <IRPackageManagerVisualComponentContainerFactory>();

            _packageManagerComponent = await InUI(() => _workflow.Packages.GetOrCreateVisualComponent(componentContainerFactory));

            _packageManagerViewModel = await InUI(() => _packageManagerComponent.Control.DataContext) as IRPackageManagerViewModel;
        }