Fix json_test's lookup of test files.
authorJez Ng <jezng@fb.com>
Tue, 19 Aug 2014 00:33:23 +0000 (17:33 -0700)
committerSara Golemon <sgolemon@fb.com>
Tue, 9 Sep 2014 21:22:22 +0000 (14:22 -0700)
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

folly/test/JsonTest.cpp

index b9b1c74d99a7243d1c3583bed6b1b0da2ec3b4ff..606e79a3ddae4b1bf004e8980dca1e301423fb9e 100644 (file)
@@ -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));