1 /*
2  * Main.cpp
3  *
4  * Copyright (C) 2021 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant
7  * to the terms of a commercial license agreement with RStudio, then
8  * this program is licensed to you under the terms of version 3 of the
9  * GNU Affero General Public License. This program is distributed WITHOUT
10  * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
11  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
12  * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
13  *
14  */
15 
16 #include <iostream>
17 #include <fstream>
18 
19 #include <boost/test/minimal.hpp>
20 
21 #include <shared_core/Error.hpp>
22 #include <core/Log.hpp>
23 #include <core/FileSerializer.hpp>
24 #include <core/system/System.hpp>
25 
26 #include <core/r_util/RVersionsPosix.hpp>
27 
28 using namespace rstudio;
29 using namespace rstudio::core;
30 
test_main(int argc,char * argv[])31 int test_main(int argc, char * argv[])
32 {
33    try
34    {
35       // setup log
36       log::setLogLevel(log::LogLevel::WARN);
37       log::setProgramId("coredev")
38       system::initializeStderrLog("coredev", log::LogLevel::WARN);
39 
40       // ignore sigpipe
41       Error error = core::system::ignoreSignal(core::system::SigPipe);
42       if (error)
43          LOG_ERROR(error);
44 
45       using namespace r_util;
46       std::vector<RVersion> versions;
47       error = readRVersionsFromFile(FilePath("rstudio-some-r-versions"), &versions);
48       if (error)
49          return core::system::exitFailure(error, ERROR_LOCATION);
50 
51 
52       RVersion version = selectVersion("3.1.0", "/opt/R/3.1.0/lib/R", versions);
53 
54 
55       std::cerr << version << std::endl;
56 
57 
58       return EXIT_SUCCESS;
59    }
60    CATCH_UNEXPECTED_EXCEPTION
61 
62    // if we got this far we had an unexpected exception
63    return EXIT_FAILURE;
64 }
65 
66