Commit 32a19232 authored by Jez Ng's avatar Jez Ng Committed by Sara Golemon

Fix json_test's lookup of test files.

Summary:
The test runner for folly seems to run from folly/test rather than the base fbcode directory. This hack ensures that we find the necessary test files in either case.

This fixes the breakage introduced by {D1493963}.

Test Plan: fbconfig -r folly && fbmake runtests

Reviewed By: davejwatson@fb.com

Subscribers: dipanshu

FB internal diff: D1502161
parent d77b369f
......@@ -381,17 +381,18 @@ TEST(Json, SortKeys) {
}
TEST(Json, StripComments) {
const std::string kTestFile =
"folly/test/json_test_data/commented.json";
const std::string kTestExpected =
"folly/test/json_test_data/commented.json.exp";
const std::string kTestDir = "folly/test/";
const std::string kTestFile = "json_test_data/commented.json";
const std::string kTestExpected = "json_test_data/commented.json.exp";
std::string testStr;
std::string expectedStr;
if (!folly::readFile(kTestFile.data(), testStr)) {
if (!folly::readFile(kTestFile.data(), testStr) &&
!folly::readFile((kTestDir + kTestFile).data(), testStr)) {
FAIL() << "can not read test file " << kTestFile;
}
if (!folly::readFile(kTestExpected.data(), expectedStr)) {
if (!folly::readFile(kTestExpected.data(), expectedStr) &&
!folly::readFile((kTestDir + kTestExpected).data(), expectedStr)) {
FAIL() << "can not read test file " << kTestExpected;
}
EXPECT_EQ(expectedStr, folly::json::stripComments(testStr));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment