Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FunctionMetadataTest : public ::testing::Test {
size_t expectedSize) {
json metadataList = functionMetadata_.at(name);
EXPECT_EQ(metadataList.size(), expectedSize);
std::string expectedStr = slurp(test::utils::getDataPath(expectedFile));
std::string expectedStr = slurp(test::utils::getDataPath("/github/presto-trunk/presto-native-execution/presto_cpp/main/functions/tests/data/", expectedFile));
auto expected = json::parse(expectedStr);
auto comparator = [](const json& a, const json& b) {
return (a["outputType"] < b["outputType"]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,26 @@
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>

using namespace std;

namespace facebook::presto::test::utils {

namespace {
const std::string applyClionDirFix(std::string& currentPath, const std::string& fileName) {
// CLion runs the tests from cmake-build-release/ or cmake-build-debug/
// directory. Hard-coded json files are not copied there and test fails with
// file not found. Fixing the path so that we can trigger these tests from
// CLion.
boost::algorithm::replace_all(currentPath, "cmake-build-release/", "");
boost::algorithm::replace_all(currentPath, "cmake-build-debug/", "");

return currentPath + "/data/" + fileName;
}
}

const std::string getDataPath(const std::string& fileName) {
std::string currentPath = boost::filesystem::current_path().c_str();
if (boost::algorithm::ends_with(currentPath, "fbcode")) {
if (boost::algorithm::ends_with(currentPath, "fbcode")) {
return currentPath +
"/github/presto-trunk/presto-native-execution/presto_cpp/main/types/tests/data/" +
fileName;
Expand All @@ -28,13 +43,16 @@ const std::string getDataPath(const std::string& fileName) {
fileName;
}

// CLion runs the tests from cmake-build-release/ or cmake-build-debug/
// directory. Hard-coded json files are not copied there and test fails with
// file not found. Fixing the path so that we can trigger these tests from
// CLion.
boost::algorithm::replace_all(currentPath, "cmake-build-release/", "");
boost::algorithm::replace_all(currentPath, "cmake-build-debug/", "");
return applyClionDirFix(currentPath, fileName);
}

const std::string getDataPath(const std::string& testDataDir, const std::string& fileName) {
std::string currentPath = boost::filesystem::current_path().c_str();
if (boost::algorithm::ends_with(currentPath, "fbcode")) {
return currentPath + testDataDir + fileName;
}

return currentPath + "/data/" + fileName;
return applyClionDirFix(currentPath, fileName);
}

} // namespace facebook::presto::test::utils
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
*/
namespace facebook::presto::test::utils {
const std::string getDataPath(const std::string& fileName);
const std::string getDataPath(const std::string& testDataDir, const std::string& fileName);
}
Loading