language-extensions/R/test/src/RExtensionLibraryApiTests.cpp
//----------------------------------------------------------------------------------------------
// Name: DependencyInstallTest
//
// Description:
//  Installs a package that requires a dependency, without the dependency first - then with
//  the dependency.
//
DependencyInstallTest
Description:
Installs a package that requires a dependency, without the dependency first - then with
the dependency.
DependencyInstallTest Description : Installs a package that requires a dependency without the dependency first - then with the dependency .
TEST_F(RExtensionLibraryApiTests, DependencyInstallTest)
	{
		string libName = "bindrcpp";
		string version = "0.2.2";
		string zipFileName =
			sm_PrivateDbIdUserIdPrefix + libName + "_" + version + x_FileExtension;
		fs::path pkgPath = sm_packagesSourcePath / x_OsName / zipFileName;
		EXPECT_TRUE(fs::exists(pkgPath));
		bool isLinux = x_OsName.compare("linux") == 0;
		InstallAndTest(
			libName,
			pkgPath.string(),
			sm_privateLibraryPath,
			version,
			sm_privateLibraryPath,
			!isLinux,  successfulInstall
			false);    successfulLoad
		 bindrcpp depends on bindr and Rcpp; rcpp is already installed.
		 install bindr here.
		string dependencyLibName = "bindr";
		string dependencyVersion = "0.1.1";
		string dependencyZipFileName =
			sm_PublicDbIdUserIdPrefix + dependencyLibName + "_"
			+ dependencyVersion + x_FileExtension;
		fs::path dependencyPkgPath = sm_packagesSourcePath / x_OsName / dependencyZipFileName;
		EXPECT_TRUE(fs::exists(dependencyPkgPath));
		 Install the dependency.
		InstallAndTest(
			dependencyLibName,
			dependencyPkgPath.string(),
			sm_publicLibraryPath,
			dependencyVersion);
		string linkLibName = "plogr";
		if (isLinux)
		{
			 If it is linux, need to install plogr as well
			 since bindrcpp links to it while building.
			string linkLibVersion = "0.2.0";
			string linkLibraryZipFileName =
				sm_PublicDbIdUserIdPrefix + linkLibName + "_"
				+ linkLibVersion + x_FileExtension;
			fs::path linkLibraryPkgPath = sm_packagesSourcePath / x_OsName / linkLibraryZipFileName;
			EXPECT_TRUE(fs::exists(linkLibraryPkgPath));
			 Install the link library.
			InstallAndTest(
				linkLibName,
				linkLibraryPkgPath.string(),
				sm_publicLibraryPath,
				linkLibVersion);
		}
		 Install bindrcpp now that all the dependencies are installed.
		 Here we try installing the top package into private, which will get the dependency
		 from public.
		InstallAndTest(
			libName,
			pkgPath.string(),
			sm_privateLibraryPath,
			version);
		 Detach bindr library which would have been loaded when bindrcpp is loaded.
		DetachLibrary(dependencyLibName);
		UninstallAndTest(
			dependencyLibName,
			sm_publicLibraryPath);
		if (isLinux)
		{
			DetachLibrary(linkLibName);
			UninstallAndTest(
				linkLibName,
				sm_publicLibraryPath);
		}
		UninstallAndTest(
			libName,
			sm_privateLibraryPath);
	}
TEST_F ( RExtensionLibraryApiTests , DependencyInstallTest ) { string libName = " " ; string version = " " ; string zipFileName = sm_PrivateDbIdUserIdPrefix + libName + " " + version + x_FileExtension ; fs :: path pkgPath = sm_packagesSourcePath / x_OsName / zipFileName ; EXPECT_TRUE ( fs :: exists ( pkgPath ) ) ; bool isLinux = x_OsName . compare ( " " ) == 0 ; InstallAndTest ( libName , pkgPath . string ( ) , sm_privateLibraryPath , version , sm_privateLibraryPath , ! isLinux , false ) ; string dependencyLibName = " " ; string dependencyVersion = " " ; string dependencyZipFileName = sm_PublicDbIdUserIdPrefix + dependencyLibName + " " + dependencyVersion + x_FileExtension ; fs :: path dependencyPkgPath = sm_packagesSourcePath / x_OsName / dependencyZipFileName ; EXPECT_TRUE ( fs :: exists ( dependencyPkgPath ) ) ; InstallAndTest ( dependencyLibName , dependencyPkgPath . string ( ) , sm_publicLibraryPath , dependencyVersion ) ; string linkLibName = " " ; if ( isLinux ) { string linkLibVersion = " " ; string linkLibraryZipFileName = sm_PublicDbIdUserIdPrefix + linkLibName + " " + linkLibVersion + x_FileExtension ; fs :: path linkLibraryPkgPath = sm_packagesSourcePath / x_OsName / linkLibraryZipFileName ; EXPECT_TRUE ( fs :: exists ( linkLibraryPkgPath ) ) ; InstallAndTest ( linkLibName , linkLibraryPkgPath . string ( ) , sm_publicLibraryPath , linkLibVersion ) ; } InstallAndTest ( libName , pkgPath . string ( ) , sm_privateLibraryPath , version ) ; DetachLibrary ( dependencyLibName ) ; UninstallAndTest ( dependencyLibName , sm_publicLibraryPath ) ; if ( isLinux ) { DetachLibrary ( linkLibName ) ; UninstallAndTest ( linkLibName , sm_publicLibraryPath ) ; } UninstallAndTest ( libName , sm_privateLibraryPath ) ; }
Name: DependencyInstallTest
Description:
Installs a package that requires a dependency, without the dependency first - then with
the dependency.
Name : DependencyInstallTest Description : Installs a package that requires a dependency without the dependency first - then with the dependency .
// Successful install possible only on Windows since on Linux we can't even build // without the link library being installed. // // successfulInstall // successfulLoad // bindrcpp depends on bindr and Rcpp; rcpp is already installed. // install bindr here. // // Install the dependency. // // If it is linux, need to install plogr as well // since bindrcpp links to it while building. // // Install the link library. // // Install bindrcpp now that all the dependencies are installed. // Here we try installing the top package into private, which will get the dependency // from public. // // Detach bindr library which would have been loaded when bindrcpp is loaded. //