#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include "ApplicationSettings.h"
#include "language_packages.h"
#include "utilityPathDetection.h"
struct EventListener: Catch::TestEventListenerBase
{
using TestEventListenerBase::TestEventListenerBase;
void testRunStarting(const Catch::TestRunInfo& testRunInfo) override
{
#ifdef __linux__
const std::string homedir = getenv("HOME");
if (!homedir.empty())
{
if (!ApplicationSettings::getInstance()->load(
FilePath(homedir + "/.config/sourcetrail/ApplicationSettings.xml")))
{
std::cout << "no settings" << std::endl;
return;
}
}
else
{
std::cout << "no homedir" << std::endl;
return;
}
#else
ApplicationSettings::getInstance()->load(FilePath(L"data/TestSettings.xml"));
#endif
#if BUILD_JAVA_LANGUAGE_PACKAGE
if (ApplicationSettings::getInstance()->getJavaPath().empty())
{
std::shared_ptr<PathDetector> pathDetector = utility::getJavaRuntimePathDetector();
const std::vector<FilePath> paths = pathDetector->getPaths();
if (!paths.empty())
{
ApplicationSettings::getInstance()->setJavaPath(paths.front());
std::cout << "Java path written to settings: "
<< ApplicationSettings::getInstance()->getJavaPath().str() << std::endl;
}
else
{
std::cout << "no Java" << std::endl;
}
}
else
{
std::cout << "Java path read form settings: "
<< ApplicationSettings::getInstance()->getJavaPath().str() << std::endl;
}
#endif
}
};
CATCH_REGISTER_LISTENER(EventListener)