From: Jez Ng Date: Tue, 19 Aug 2014 00:33:23 +0000 (-0700) Subject: Fix json_test's lookup of test files. X-Git-Tag: v0.22.0~395 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=32a19232b18c348096f980a64805d1641deec630;p=folly.git 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 --- diff --git a/folly/test/JsonTest.cpp b/folly/test/JsonTest.cpp index b9b1c74d..606e79a3 100644 --- a/folly/test/JsonTest.cpp +++ b/folly/test/JsonTest.cpp @@ -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));